0

我正在运行一个简单的 python 脚本来将 longlat Nad83 转换为 Ky State Plane South Nad83(epsg 4269 到 6474)。当我将输入投影设置为:

inProj = pyproj.Proj(proj='longlat', datum ='NAD83') 

我得到一个答案(这似乎是正确的)。当我设置输入投影时:

inProj = pyproj.Proj('epsg:4269') 

我得到了不同的答案。我两次都打印出 inProj 并且看起来都是一样的。


运行 1:

import pyproj
import numpy as np

# nad 83 latt and longs      
inProj        = pyproj.Proj('epsg:4269')      

#  KY State Nad83 Meter (2011)
outProj  = pyproj.Proj("epsg:6474") #  KY State South Nad83 Meter (2011)

long = np.array([-83.88259259,-83.88259259,-83.55083333,-83.55083333])
latt = np.array([ 36.49333333, 36.79203704, 36.79203704, 36.49333333])

x,y = pyproj.transform(inProj, outProj ,long ,latt)

print('\ninProj = ',inProj,'\n\noutProj = ',outProj,'\n')

for i in range(len(long)):
    print('long = ',long[i],'latt = ',latt[i],
          'x = ',x[i],'y = ',y[i]) 

输出:

inProj =  Proj('+proj=longlat +datum=NAD83 +no_defs', preserve_units=True) 

outProj =  Proj('+proj=lcc +lat_0=36.3333333333333 +lon_0=-85.75 +lat_1=37.9333333333333 +lat_2=36.7333333333333 +x_0=500000 +y_0=500000 +ellps=GRS80 +units=m +no_defs', preserve_units=True) 

long =  -83.88259259 latt =  36.49333333 x =  72927331.14729036 y =  -11599224.291812904
long =  -83.88259259 latt =  36.79203704 x =  72992044.27873956 y =  -11370127.68625123
long =  -83.55083333 latt =  36.79203704 x =  70702668.24198839 y =  -10727351.707669286
long =  -83.55083333 latt =  36.49333333 x =  70639998.82021627 y =  -10949213.198204307

运行2:

import pyproj
import numpy as np

# nad 83 latt and longs   
inProj        = pyproj.Proj(proj='longlat', datum ='NAD83')     


#  KY State Nad83 Meter (2011)
outProj  = pyproj.Proj("epsg:6474") #  KY State South Nad83 Meter (2011)

long = np.array([-83.88259259,-83.88259259,-83.55083333,-83.55083333])
latt = np.array([ 36.49333333, 36.79203704, 36.79203704, 36.49333333])

x,y = pyproj.transform(inProj, outProj ,long ,latt)

print('\ninProj = ',inProj,'\n\noutProj = ',outProj,'\n')

for i in range(len(long)):
    print('long = ',long[i],'latt = ',latt[i],
          'x = ',x[i],'y = ',y[i]

输出:

inProj =  Proj('+proj=longlat +datum=NAD83 +no_defs', preserve_units=True) 

outProj =  Proj('+proj=lcc +lat_0=36.3333333333333 +lon_0=-85.75 +lat_1=37.9333333333333 +lat_2=36.7333333333333 +x_0=500000 +y_0=500000 +ellps=GRS80 +units=m +no_defs', preserve_units=True) 

long =  -83.88259259 latt =  36.49333333 x =  667315.2681430576 y =  519409.6151513982
long =  -83.88259259 latt =  36.79203704 x =  666660.1039730347 y =  552551.2004212044
long =  -83.55083333 latt =  36.79203704 x =  696263.6061808041 y =  553188.4213983886
long =  -83.55083333 latt =  36.49333333 x =  697035.1458569702 y =  520049.34113333403

Pyproj 似乎将输入参数视为相同,但结果却大不相同。

4

1 回答 1

0

您正在遇到 PROJ 6 引入的轴顺序更改:

传统上,顺序是东(x)北(y),如 PROJ 参数版本所示:

>>> from pyproj import CRS
>>> CRS("+proj=longlat +datum=NAD83")
<Geographic 2D CRS: +proj=longlat +datum=NAD83 +type=crs>
Name: unknown
Axis Info [ellipsoidal]:
- lon[east]: Longitude (degree)
- lat[north]: Latitude (degree)
Area of Use:
- undefined
Datum: North American Datum 1983
- Ellipsoid: GRS 1980
- Prime Meridian: Greenwich

但是,在 EPSG 版本中,它是 North(y),East(x) 顺序:

>>> CRS("EPSG:4269")
<Geographic 2D CRS: EPSG:4269>
Name: NAD83
Axis Info [ellipsoidal]:
- Lat[north]: Geodetic latitude (degree)
- Lon[east]: Geodetic longitude (degree)
Area of Use:
- name: North America - NAD83
- bounds: (167.65, 14.92, -47.74, 86.46)
Datum: North American Datum 1983
- Ellipsoid: GRS 1980
- Prime Meridian: Greenwich

所以,如果你想让它给出正确的输出,要么:

  1. 切换输入顺序:
>>> transformer = Transformer.from_crs("EPSG:4269", "epsg:6474")
>>> long, latt = -83.88259259, 36.49333333
>>> transformer.transform(latt, long)
(667315.2681430576, 519409.6151513982)
  1. 使用always_xy
>>> transformer_xy = Transformer.from_crs("EPSG:4269", "epsg:6474", always_xy=True)
>>> transformer_xy.transform(long, latt)
(667315.2681430576, 519409.6151513982)

我还建议阅读: https ://pyproj4.github.io/pyproj/stable/gotchas.html#axis-order-changes-in-proj-6

于 2020-03-02T13:42:09.427 回答