I did the following:
On Monday, 7 March 2016 20:43:05 UTC+2, Jônatas Castro wrote:
-- from django.contrib.gis.geos import GEOSGeometry, WKTWriter
wkt_w = WKTWriter()
wkt_w.outdim = 2 # This sets the writer to output 2D WKT
polygon = GEOSGeometry(json.dumps(item['geometry'])) # The 3D geometry
temp = wkt_w.write(polygon)
polygon = GEOSGeometry(temp) # The 3D geometry
Here it is in the docs: https://docs.djangoproject.com/en/1.11/ref/contrib/gis/geos/#django.contrib.gis.geos.WKBWriter.outdim
On Monday, 7 March 2016 20:43:05 UTC+2, Jônatas Castro wrote:
In my project I need to import shapefiles and same some geometry.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 2Dobj=MyModel(geometry=GEOSGeometry(layers[0].geom. hex)) obj.save()
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/377d3f34-c092-46dd-92f1-5d9e806c6f59%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment