Using shapely package for Python how to export the resulting shapely objects such as buffer to a DXF file?
|
|
|
Shapely doesn't directly support exporting to DXF - it supports export to Well Known Text (WKT), Well Known Binary (WKB), Numpy arrays and GeoJSON objects (interoperation from the Shapely manual). As such you need a package that can transform from one of these formats to DXF. I'd suggest OGR as the way to go for my money. The easiest method would be to simply export your shapely geometries to a GeoJSON file through Python using
Then simply use the ogr2ogr utility to transform the GeoJSON to a DXF file, e.g.
Then, if you're keen you can look up the GDAL/OGR Python bindings and do it within a single script. Hope this helps! |
|||||||||||||||
|
|
BTW, if you appreciate Shapely, you may also appreciate Fiona. The Fiona example in https://gist.github.com/1886782 could be adapted to convert a shapefile to DXF.
It coughs up a lot of warnings about mismatch between GIS simple feature and DXF data models but does write a file of entities. |
|||||||||
|