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.


1 Answer 1


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.

  • Unbelievable. I read and reread the documentation and still missed it. And that's after doing the same thing with the -zfield option.
    – Scro
    Commented Dec 17, 2013 at 22:44

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.