2

我有一个成功加载的旧金山 shapefile,但我需要将坐标转换为经度/纬度形式。我拥有的变量如下:

w1 = x 坐标 w2 = y 坐标

目前坐标如下所示:

print(w1[0], w2[0])
6017864.66784 2104744.54451

我试图像这样转换点:

from pyproj import Proj, transform
inProj = Proj(init='epsg2227')
outProj = Proj(init='epsg4326')
x1, y1 = w1[0], w2[0]
x2, y2 = transform(inProj, outProj, x1, y1)
print(x2, y2)
-70.44154167927961 41.036642156063856

旧金山的坐标约为西 -122 度和北纬 37.7 度。我相信我的问题是我的 inProj 和 outProj 命令有错误的 epsg 但我不知道我应该是什么。任何帮助将不胜感激。

4

1 回答 1

0

我对 pyproj 的了解比我最初的预期要多:

您需要做的就是添加preserve_units = True到您的 Projection 别名:

w1=[1]
w2=[1]
w1[0]=6010936.158609
w2[0]=2090667.302531
from pyproj import Proj, transform
inProj = Proj(init='epsg:2227', preserve_units=True)
outProj = Proj(init='epsg:4326', preserve_units=True)
x1, y1 = w1[0], w2[0]
x2, y2 = transform(inProj, outProj, x1, y1)
print(x2, y2)

[out]: -122.4, 37.8

基本上所有preserve_units的都会使用本地单位而不是标准米。

这是git页面

这是转换页面

基本上 2227 以美国测量英尺为单位,4326 以度为单位,并将两者都视为米

于 2016-06-07T00:43:02.210 回答