1

I've been given a DXF file with many different points, linestrings and polygons. Alongside these, there are some text annotations with arrows pointing to a particular feature. (The CAD-user's annotation of the area).

I'm using ogr2ogr to convert each layer as a shapefile like so:

ogr2ogr -f "ESRI Shapefile" C:/test/DXF_line.shp C:/test/Original_DXF.dxf -nlt Linestring  -s_srs EPSG:29902 -t_srs EPSG:29902 -skipfailures

However, I'm wondering is there a way to split the annotations from the points, etc? As they currently seem to be converted to a point feature making it hard to distinguish between actual features and points which are just notes

1 Answer 1

2

You can separate the data in this way:

ogr2ogr -f "ESRI Shapefile" -skipfailure  --config DXF_MERGE_BLOCK_GEOMETRIES TRUE --config DXF_INLINE_BLOCKS TRUE -nlt POINT      -sql "select *, ogr_style from entities where OGR_GEOMETRY LIKE '%POINT%'"         C:/test/annotations.shp C:/test/Original_DXF.DXF
ogr2ogr -f "ESRI Shapefile" -skipfailure  --config DXF_MERGE_BLOCK_GEOMETRIES TRUE --config DXF_INLINE_BLOCKS TRUE -nlt LINESTRING -sql "select *, ogr_style from entities where OGR_GEOMETRY LIKE '%LINE%'"          C:/test/line.shp C:/test/Original_DXF.DXF
ogr2ogr -f "ESRI Shapefile" -skipfailure  --config DXF_MERGE_BLOCK_GEOMETRIES TRUE --config DXF_INLINE_BLOCKS TRUE -nlt POLYGON    -sql "select *, ogr_style from entities where OGR_GEOMETRY LIKE '%POLYGON%'"       C:/test/polygon.shp C:/test/Original_DXF.DXF 
ogr2ogr -f "ESRI Shapefile" -skipfailure  --config DXF_MERGE_BLOCK_GEOMETRIES TRUE --config DXF_INLINE_BLOCKS TRUE -nlt POINT      -sql "select *, ogr_style from entities where OGR_GEOMETRY = 'GEOMETRYCOLLECTION'" C:/test/symbolpoint.shp C:/test/Original_DXF.DXF
ogr2ogr -f "ESRI Shapefile" -skipfailure  --config DXF_MERGE_BLOCK_GEOMETRIES TRUE --config DXF_INLINE_BLOCKS TRUE -nlt LINESTRING -sql "select *, ogr_style from entities where OGR_GEOMETRY = 'GEOMETRYCOLLECTION'" C:/test/symbollinestring.shp C:/test/Original_DXF.DXF
ogr2ogr -f "ESRI Shapefile" -skipfailure  --config DXF_MERGE_BLOCK_GEOMETRIES TRUE --config DXF_INLINE_BLOCKS TRUE -nlt POLYGON    -sql "select *, ogr_style from entities where OGR_GEOMETRY = 'GEOMETRYCOLLECTION'" C:/test/symbolpolygon.shp C:/test/Original_DXF.DXF

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.