繁体   English   中英

GeoPandas 将 Lat/Lon 中的点重投影到 UTM 给出 Inf, Inf

[英]GeoPandas reprojection of Point in Lat/Lon to UTM give Inf, Inf

使用 geopandas 时,尝试将 Lat/Lon 中的一些点转换为 UTM。 但是,转换给了我点(inf inf)......我的代码有什么问题? 有人可以向我指出问题所在。 谢谢

GPS =  pd.read_excel('coordinates.xls', sheet_name='GPS', usecols = "A,B,F,G", header = 0)
GPS.columns = ['Date', 'Time', 'Lat', 'Lon']

GPS_LatLon = GPS[["Lat","Lon"]]
geodf = gpd.GeoDataFrame(GPS_LatLon,
                   crs={'init': 'epsg:4326'},
                   geometry=GPS_LatLon.apply(lambda row: shapely.geometry.Point((row.Lat, row.Lon)), axis=1))

geodf = geodf.to_crs({'init': 'epsg:32633'})

geodf["x"] = geodf.geometry.apply(lambda row:row.x)
geodf["y"] = geodf.geometry.apply(lambda row:row.y)

GPS_UTM = pd.DataFrame(geodf)
GPS_UTM.to_excel("GPS_utm.xls")

这是我在 GeoDataFrame 步骤之后的数据

        Lat         Lon               geometry
0     1.416176  13.869467  POINT (1.416 13.869)
1     1.416176  13.869466  POINT (1.416 13.869)
2     1.416176  13.869465  POINT (1.416 13.869)
3     1.416177  13.869465  POINT (1.416 13.869)
4     1.416178  13.869463  POINT (1.416 13.869)
5     1.416179  13.869462  POINT (1.416 13.869)
6     1.416180  13.869460  POINT (1.416 13.869)
7     1.416181  13.869458  POINT (1.416 13.869)

但是 output 给我

       Lat         Lon         geometry    x    y
0     1.416176  13.869467  POINT (inf inf)  inf  inf
1     1.416176  13.869466  POINT (inf inf)  inf  inf
2     1.416176  13.869465  POINT (inf inf)  inf  inf
3     1.416177  13.869465  POINT (inf inf)  inf  inf
4     1.416178  13.869463  POINT (inf inf)  inf  inf
5     1.416179  13.869462  POINT (inf inf)  inf  inf
6     1.416180  13.869460  POINT (inf inf)  inf  inf
7     1.416181  13.869458  POINT (inf inf)  inf  inf

我可能错了,但我认为你应该将 (lon, lat) 传递给 shapely.geometry.Point,而不是 (lat, lon)。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM