Strip Z dimension on GeoDjango (Force 2D geometry)

Viewed 1574

In my project I need to import some geometry from shapefiles.

Some of these are MULTIPOLYGON Z type, but all Z coordinates are 0-value.

When I try to save the geometry, I get the error:

"Geometry has Z dimension but column does not"

What is the best way to strip the Z dimension?

My code:

ds = DataSource(file_path, encoding='ISO-8859-1')
layers = ds[0]

#need something HERE to coerce geometry to 2D

obj=MyModel(geometry=GEOSGeometry(layers[0].geom.hex))
obj.save()
2 Answers
Related