I like to convert this DXF file to ESRI Shapefiles. I tried the following command:
ogr2ogr -f "ESRI Shapefile" test.shp Umweltzone-Neu-Ulm.dxf
… which output the following warnings and errors:
Warning 6: Normalized/laundered field name: 'ExtendedEntity' to 'ExtendedEn'
Warning 6: Normalized/laundered field name: 'EntityHandle' to 'EntityHand'
ERROR 1: Attempt to write non-polygon (LINESTRING) geometry to POLYGON type shapefile.
ERROR 1: Unable to write feature 1 from layer entities.
ERROR 1: Terminating translation prematurely after failed
translation of layer entities (use -skipfailures to skip errors)
Inspecting the file with ogrinfo does not give a helpful advice for me:
ogrinfo -so -al Umweltzone-Neu-Ulm.dxf
INFO: Open of `Umweltzone-Neu-Ulm.dxf'
using driver `DXF' successful.
Layer name: entities
Geometry: Unknown (any)
Feature Count: 3
Extent: (573038.389500, 5359699.934800) - (576023.432710, 5361356.286500)
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)
Also, from the Extent
I am guessing that the EPSG code is different to 4326
. But which?
What is the correct command to perform the conversion?
Best Answer
I guessed the SRS to EPSG:25832 (UTM 32N) by looking at the DXF file with QGIS.
With ogr2ogr:
you can create a geojson file. Looking at the source file, it shows there are three features: a point, a linestring and a polygon.
Limiting the feature (and knowing the polygon is the first one) gives you the polygon. You can omit the limit parameter and you'll get all three features.
edit: with
-f 'ESRI Shapefile'
instead of GeoJson you will get a shapefileedit: to create a Shapefile for each feature type you have to run ogr2ogr for each type
You have to use the
-skipfailures
parameter, because it is not possible to write different geometry types to one shapefile.