使用UTM和geodjango

mon*_*kut 1 python django gdal geodjango geos

我正在研究使用UTM坐标系统和geodjango.我无法弄清楚如何正确获取数据.

我一直在浏览文档,似乎" GEOSGeometry(geo_input,srid = None) "或" OGRGeometry "可以与EWKT一起使用,但我无法弄清楚如何格式化数据.

看起来UTM SRID是:2029

维基百科文章中,格式如下:

[ UTMZone ] [ N或S ] [ 东向 ] [ 北向 ]

17N 630084 4833438

所以我试了以下没有运气:

>>> 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)"
Run Code Online (Sandbox Code Playgroud)

有没有可用的例子来说明这是如何完成的?

可能我应该在UTM中进行任何必要的计算并转换为十进制度数?
在这种情况下,GEOS或geodjango中的其他工具是否提供转换utitilites?

tca*_*uce 6

UTM区域(17N)已由空间参考系统SRID 2029指定,因此您无需将其包含在传递给GEOSGeometry构造函数的WKT中.

>>> from django.contrib.gis.geos import *
>>> pnt = GEOSGeometry('SRID=2029;POINT(630084 4833438)')
>>> (pnt.x, pnt.y)
(630084.0, 4833438.0)
>>> pnt.srid
2029
Run Code Online (Sandbox Code Playgroud)

然后,例如:

>>> pnt.transform(4326)   # Transform to WGS84
>>> (pnt.x, pnt.y)
(-79.387137066054038, 43.644504290860461)
>>> pnt.srid
4326
Run Code Online (Sandbox Code Playgroud)