[GIS] Specifying element type for DXF creation using ogr2ogr

ogr2ogr

I am trying to create a DXF from a Polygon Shapefile using ogr2ogr:

ogr2ogr -f DXF parcels.dxf parcels.shp

The problem is that the polygons are written as hatch elements.

How do I specify that ogr2ogr should create LWPOLYLINE elements (Or any other supported type)?

I have tried this from command line and from QGIS 'save as' option with the same result. I don't remember this being an issue in the past, but seems like it started with GDAL version 1.10.x.

Best Answer

You can use -nlt option to force type of object. You can test -nlt MULTILINESTRING or -nlt LINESTRING with your command. I think it can work.

ogr2ogr -f DXF parcels.dxf parcels.shp -nlt MULTILINESTRING

In the documentation your can read:

-nlt type: Define the geometry type for the created layer. One of NONE, GEOMETRY, POINT, LINESTRING, POLYGON, GEOMETRYCOLLECTION, MULTIPOINT, MULTIPOLYGON or MULTILINESTRING. Add "25D" to the name to get 2.5D versions. Starting with GDAL 1.10, PROMOTE_TO_MULTI can be used to automatically promote layers that mix polygon or multipolygons to multipolygons, and layers that mix linestrings or multilinestrings to multilinestrings. Can be usefull when converting shapefiles to PostGIS (and other target drivers) that implements strict checks for geometry type.