I did the following:
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 ge
Hi,
not sure if I did the right thing or not, but I just altered the table in
this
way
https://github.com/alphagov/land-availability-api/pull/20/files#diff-f8cf5fd1898b907b7e7cc07dcc455602R15
(yes, the code is opensource!) because I've also noticed that GeoDjango
doesn't have an equivalent of
There is a way to coerce the input to 2d. It's not pretty, but it works.
from django.contrib.gis.geos.prototypes.io import wkt_w
wkt = wkt_w(dim=2).write(input_geom).decode()
geom = GEOSGeometry(wkt, srid=4674)
Imagine that you get input_geom from somewhere. In our case it was coming
from a KML u
Jason: when you say create 2 geometry types one with 2 dimensions etc...
how do you specify how many dimensions to have?
Because I created the field in this way:
geom = models.MultiPolygonField(geography=True, spatial_index=True)
and let the Django migration do the job, but I don't know how to
I had a similar issue when uploading a kml to geojson conversion to postgis
using geodjango. There is no efficient way to do it in Django, so I ended
up doing a workaround
- Create two geometry types, one with dims=2 and other with dims=3.
Allow both to be null and set default to null
1. There a GeoDjango sublist, better place to ask.
2. Strip out the Z when doing the database import, you don't say which
db backend your're using.
2a. If you can't do it on import than do it with an update query.
http://gis.stackexchange.com/questions/78142/how-can-i-strip-out-z-values-in-postgis
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?*
7 matches
Mail list logo