use*_*798 0 python pandas geopandas
使用 geopandas 时,尝试将纬度/经度中的一些点转换为 UTM。但是,转换给了我 Point(inf inf)...我的代码有什么问题?有人可以向我指出问题吗。Thks
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")
Run Code Online (Sandbox Code Playgroud)
这是 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)
Run Code Online (Sandbox Code Playgroud)
但输出给了我
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
Run Code Online (Sandbox Code Playgroud)