Utilizzando UTM con geodjango
Domanda
sto cercando in utilizzando le href="http://en.wikipedia.org/wiki/Universal_Transverse_Mercator_coordinate_system" sistema di coordinate con geodjango. E io non riesco a capire come ottenere i dati in modo corretto.
Ho passando in rassegna la documentazione e sembra che il " GEOSGeometry (geo_input, SRID = None) " o " OGRGeometry " potrebbe essere utilizzato con un EWKT, ma non riesco a capire come formattare i dati.
Sembra che l'UTM SRID IS: 2029
wikipedia articolo il formato è scritto in questo modo:
[ UTMZone ] [ N o S ] [ easting ] [ northing ]
17N 630.084 4.833.438
Così ho provato quanto segue senza fortuna:
>>> from django.contrib.gis.geos import *
>>> pnt = GEOSGeometry('SRID=2029;POINT(17N 630084 4833438)')
GEOS_ERROR: ParseException: Expected number but encountered word: '17N'
>>>
>>> from django.contrib.gis.gdal import OGRGeometry
>>> pnt = OGRGeometry('SRID=2029;POINT(17N 630084 4833438)')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python26\lib\site-packages\django\contrib\gis\gdal\geometries.py", line 106, in __init__
ogr_t = OGRGeomType(geom_input)
File "C:\Python26\lib\site-packages\django\contrib\gis\gdal\geomtype.py", line 31, in __init__
raise OGRException('Invalid OGR String Type "%s"' % type_input)
django.contrib.gis.gdal.error.OGRException: Invalid OGR String Type "srid=2029;point(17n 630084 4833438)"
Ci sono alcun esempio a disposizione per mostrare come si fa?
Può essere dovrei solo fare qualsiasi calulations necessarie UTM e convertire in gradi decimali?
In questo caso non GEOS o di altri strumenti a geodjango fornire utitilites convertion?
Soluzione
La zona UTM (17N) è già specificata dal sistema di riferimento spaziale - SRID 2029 , quindi non è necessario includerlo nel WKT si passa al costruttore GEOSGeometry
.
>>> from django.contrib.gis.geos import *
>>> pnt = GEOSGeometry('SRID=2029;POINT(630084 4833438)')
>>> (pnt.x, pnt.y)
(630084.0, 4833438.0)
>>> pnt.srid
2029
Quindi, per esempio:
>>> pnt.transform(4326) # Transform to WGS84
>>> (pnt.x, pnt.y)
(-79.387137066054038, 43.644504290860461)
>>> pnt.srid
4326