1

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.

Nathan Villaescusa
  • 17,331
  • 4
  • 53
  • 56
Developer
  • 8,258
  • 8
  • 49
  • 58

2 Answers2

2

Have you tried the SDXF library ?

Gianluca
  • 3,227
  • 2
  • 34
  • 35
  • Thanks for the answer. I wonder how to convert Shapely objects to SDXF objects. Is there any possibility? – Developer Feb 23 '12 at 13:46
0

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")
gyger
  • 197
  • 1
  • 10