4

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.

  • 2
    My guess is that the circle portions are mathematically defined curves (that aren't supported in a shapefile) and are not getting converted to densified lines. – mkennedy Jul 18 '13 at 16:30
  • 1
    Do you see a way around this using ogr2ogr? Both FME and ESRI convert it fine, so it's disappointing that GDAL cannot. – ianbroad Jul 18 '13 at 16:37
  • can you provide the sample dxf – Antonio Locandro Aug 5 '13 at 22:05
  • arc-types are supported by "tesselating the arc into line segments" – Mike T Aug 6 '13 at 2:48
  • Can you explain what that means exactly and how it helps me? – ianbroad Aug 6 '13 at 12:54
6
+50

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.

  • Thanks! I was able to duplicate what you did. I'm still confused as to why using 'LINESTRING' as the OGR_GEOMETRY does not produce the same results? What geometry type are the pie shapes? I dug in a little more using the ogrinfo you showed me and it says the GEOMETRY of the pie shapes are indeed LINESTRING. Any idea why they don't show up when using the filter? – ianbroad Aug 7 '13 at 15:41
  • Not totally certain. The example file you posted came up as 'unknown' geometry. QGIS reported a GeometryCollection Layer too, which may be the issue. I know shapefiles can't handle GeometryCollections (or more than one geometry type for that matter). I'd have to dig deeper to get a definitive answer, if I have time, I will. – user10353 Aug 7 '13 at 19:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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