如何在Python中将UTM转换为Lat / Long?

时间:2018-06-09 11:30:52

标签: python django python-3.x geodjango

{
  "type": "MultiPolygon",
  "coordinates": [[[
        [6707794.77817316, 1952512.97762237],
        [6707794.43138905, 1952566.21209599],
        [6707897.49942442, 1952567.26754007],
        [6707897.9039513, 1952513.5347079],
        [6707794.77817316, 1952512.97762237]
      ]]]
}

这些是萨克拉门托市的UTM坐标

from pyproj import Proj
Lat = 52.063098675
Lon = -114.132980348
ZoneNo = "11" #Manually input or from other sources
myProj = Proj("+proj=utm +zone="+\
ZoneNo+", +north +ellps=WGS84 +datum=WGS84 +units=m +no_defs")
Lon2, Lat2 = myProj(UTMx, UTMy,inverse=True)



 [57.645243963689346, -97.82662155895939][57.64521883657446, 
-97.82633467103226][57.64520287229081, -97.82615238782866] 
[57.64518564728056, -97.82595574421379][57.646086991794625, 
-97.82587777819731][57.64614690939316, -97.8265560026529] 
[57.645243963689346, -97.82662155895939]

但这个返回坐标位于加拿大。但我想在萨克拉门托市找到这个纵向和横向的

任何人都可以帮我转换正确的格式,将UTM转换为LAN LONG坐标。

1 个答案:

答案 0 :(得分:0)

您的坐标使用"NAD83(NSRS2007) / California zone 2 (ftUS)"坐标系:

from django.contrib.gis.geos import Polygon
from pprint import pprint

DATA = [
    [6707794.77817316, 1952512.97762237],
    [6707794.43138905, 1952566.21209599],
    [6707897.49942442, 1952567.26754007],
    [6707897.9039513, 1952513.5347079],
    [6707794.77817316, 1952512.97762237]
]

poly_california = Polygon(DATA, srid=3492)
poly_gps = poly_california.transform(4326, clone=True)
pprint(poly_gps.coords)

结果:

(((-121.48923204074042, 38.52249222070792),
  (-121.48923220705949, 38.5226384001039),
  (-121.48887193496923, 38.52263970700418),
  (-121.48887157735834, 38.522492158296565),
  (-121.48923204074042, 38.52249222070792)),)

(提示:GeoJSON should only use WGS84