Developer
Developer

Reputation: 8400

Python: export to DXF file the Shapely objects

How to export the results come from spatial operations such as buffer function on points using Shapely package for Python to a DXF file? BTW, googling wasn't so helpful this time.

Upvotes: 1

Views: 1979

Answers (2)

gyger
gyger

Reputation: 207

One way is thanks to the __geo_interface__ interface standard and the ezdxf library.

A sample code could be below were shapes holds your e.g. MultiPolygon

from shapely.geometry import mapping
import ezdxf
import ezdxf.addons.geo

doc = ezdxf.new()
geoproxy = ezdxf.addons.geo.GeoProxy.parse(mapping(shapes))

msp = doc.modelspace()

# Use LWPOLYLINE instead of hatch.
for entity in geoproxy.to_dxf_entities(polygon=2): 
    msp.add_entity(entity)

doc.saveas("test.dxf")

Upvotes: 0

user1092803
user1092803

Reputation: 3297

Have you tried the SDXF library ?

Upvotes: 2

Related Questions