Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/304.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何将熊猫中的NAD83坐标转换为常规gps坐标(lat/lon)?_Python_Pandas_Gps_Coordinates_Gis - Fatal编程技术网

Python 如何将熊猫中的NAD83坐标转换为常规gps坐标(lat/lon)?

Python 如何将熊猫中的NAD83坐标转换为常规gps坐标(lat/lon)?,python,pandas,gps,coordinates,gis,Python,Pandas,Gps,Coordinates,Gis,我在python/pandas中找不到任何library.function来将坐标从NAD83标准转换为GPS纬度/经度 下面是一个重现这种情况的例子。我正在寻找一个功能,将这些NAD83坐标转换为常规GPS lat/lon。以下所有点预计位于密苏里州圣路易斯附近(即约38.6270°N,90.1994°W) 也就是说 xcoords ycoords 894557.5 1025952.0 880625.2 996012.7 896551.8 1025333.0 896

我在python/pandas中找不到任何library.function来将坐标从NAD83标准转换为GPS纬度/经度

下面是一个重现这种情况的例子。我正在寻找一个功能,将这些NAD83坐标转换为常规GPS lat/lon。以下所有点预计位于密苏里州圣路易斯附近(即约
38.6270°N
90.1994°W

也就是说

xcoords     ycoords 
894557.5    1025952.0
880625.2    996012.7
896551.8    1025333.0
896551.8    1025333.0
896497.6    997157.3
903061.1    1033547.0
数据源=


metadata=(参见
XCoord和YCoord-这些坐标是什么?

首先,我们需要确定密苏里州圣路易斯的SPC或FIPS区域。从我们得到的区域#2401。然后,我们从下载相应的项目字符串(或者,您可以从NOAA手册第68页附录A中获取必要的数据)。利用这些数据,我们可以使用以下方法将SPCS数据转换为gps lon/lat值:

结果:

    xcoords    ycoords        lon        lat
0  894557.5  1025952.0 -90.239655  38.650896
1  880625.2   996012.7 -90.288682  38.568784
2  896551.8  1025333.0 -90.232678  38.649181
3  896551.8  1025333.0 -90.232678  38.649181
4  896497.6   997157.3 -90.233154  38.571814
5  903061.1  1033547.0 -90.209794  38.671681

有点晚了,但是…-下面是我如何将SLMPD x,y坐标转换为lat lon的。首先是找出我们所处的EPSG区域是“EPSG 3602 NAD83(NSRS2007)/密苏里东部”。这是从中检索到的。从一般研究中,我将其转换为espg:4326“3D系统的水平组件。用于GPS卫星导航系统和北约军事大地测量。”


我认为
lon
应该在+90左右,而不是-90左右。一个负号与现实不同!哈这真的让我很困惑,因为我现在运行它时得到了不同的数字!!例如,对于第一行(894557.5 1025952.0),我得到:(-82.355684 44.781735)负经度意味着西,正东,圣路易斯莫绝对是格林威治以西:)你也可以通过谷歌验证。例如,数据框中的第一行(csv中的第二行)在csv文件中有地址4124 Page Blvd。谷歌地图给出了这个地址的-90.239668/38.650908,这相当接近从转换中获得的-90.239655/38.650896。出于某种原因,当我运行上面的确切脚本时,我得到了不同的结果。例如,对于(894557.5 1025952.0)的第一行,我得到(-82.355684 44.781735),但您得到(-90.239655 38.650896)。有什么想法吗?
import pandas as pd
import pyproj

xcoords = [894557.5, 880625.2, 896551.8, 896551.8, 896497.6, 903061.1]
ycoords = [1025952, 996012.7, 1025333, 1025333, 997157.3, 1033547]
df = pd.DataFrame({'xcoords':xcoords, 'ycoords':ycoords})

fips2401 = pyproj.Proj("+proj=tmerc +lat_0=35.83333333333334 +lon_0=-90.5 +k=0.9999333333333333 +x_0=250000 +y_0=0 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192 +no_defs")
wgs84 = pyproj.Proj("+init=EPSG:4326")

df[['lon', 'lat']] = pd.DataFrame(pyproj.transform(fips2401, wgs84, df.xcoords.to_numpy(), df.ycoords.to_numpy())).T
    xcoords    ycoords        lon        lat
0  894557.5  1025952.0 -90.239655  38.650896
1  880625.2   996012.7 -90.288682  38.568784
2  896551.8  1025333.0 -90.232678  38.649181
3  896551.8  1025333.0 -90.232678  38.649181
4  896497.6   997157.3 -90.233154  38.571814
5  903061.1  1033547.0 -90.209794  38.671681
from pyproj import Transformer 

#transformer to convert from (epsg 3602 NAD83(NSRS2007) / Missouri East) to 4326 (WGS84 - World Geodetic System 1984, used in GPS)

transformer = Transformer.from_crs( "epsg:3602","epsg:4326",always_xy=False)

#empty lists to hold converted x y coordinates
lat = []
lon = []

#loop through columns 'XCoord' and 'YCoord' and declare variables x and y to use in transformer. 
#note I had to change the column values from feet to meters for the transformer to correctly work
for index, row in df.iterrows():
    x = (row['XCoord'] / 3.28)
    y = (row['YCoord'] / 3.28)
    
    #call transformer
    x1, y1 = transformer.transform(x,y)
      
    #append to lists    
    lat.append(x1)
    lon.append(y1)
    
# add new columns to df     
df['Lat'] = lat
df['Lon'] = lon