[GIS] ogr2ogr coverting DXF to shapefile, why am I losing part of the feature

convertgdalogrogr2ogr

I'm starting to mess around with some of the GDAL toolsets, specifically the ogr2ogr.

I'm working with converting a 2000 ACSII DXF file to shapefiles depending on geometry.

Everything seems to work fine, but I'm not getting the complete feature.

Here's an example of my command:

ogr2ogr -where "OGR_GEOMETRY='LINESTRING' AND LAYER='E-TRANSFORMER'" -f "ESRI Shapefile" transformers.shp System_Map.dxf

Now this does create a polyline shapefile with a good amount of data, but I'm losing a key part I need, here's an example of what I need:

enter image description here

The problem is that the conversion is only giving me the line up to the circle.

Each pie of the circle is its own feature and the line is its own feature. So in this picture there are 4 separate features, but they are all part of the E-TRANSFORMER layer.

Can you think of a reason I am only getting the line leading up to the circle and not the circle too?

FME converts it fine, but I'd rather use GDAL if I could.

Thanks for any help.

Best Answer

It appears your geometry is unknown to ogr. It doesn't see your geometries as one type and reports:

kyle@kyle-workstation:Downloads$ ogrinfo -so -al Example.dxf 
INFO: Open of `Example.dxf'
      using driver `DXF' successful.

Layer name: entities
Geometry: Unknown (any)
Feature Count: 7886
Extent: (2481827.566011, 337655.197584) - (3104773.310852, 676755.941142)
Layer SRS WKT:
(unknown)
Layer: String (0.0)
SubClasses: String (0.0)
ExtendedEntity: String (0.0)
Linetype: String (0.0)
EntityHandle: String (0.0)
Text: String (0.0)

Remove your geometry restriction: OGR_GEOMETRY='LINESTRING' and specify -skipfailures. There appear to be points in the layer that need to be discarded:

kyle@kyle-workstation:Downloads$ ogr2ogr -skipfailures -where "LAYER='E-TRANSFORMER'" -f "ESRI Shapefile" transformers.shp Example.dxf
Warning 6: Normalized/laundered field name: 'ExtendedEntity' to 'ExtendedEn'
Warning 6: Normalized/laundered field name: 'EntityHandle' to 'EntityHand'
ERROR 1: Attempt to write non-linestring (POINT) geometry to ARC type shapefile.
ERROR 1: Attempt to write non-linestring (POINT) geometry to ARC type shapefile.
ERROR 1: Attempt to write non-linestring (POINT) geometry to ARC type shapefile.

It worked for me in QGIS, at least I got the linestring and the pie.