将Lat / Lon中的Point的GeoPandas重新投影到UTM给Inf,Inf

时间:2019-11-13 05:35:37

标签: python pandas geopandas

使用地理熊猫时,尝试将纬度/经度中的某些点转换为UTM。但是,该转换给了我Point(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)

但是输出给了我

       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

1 个答案:

答案 0 :(得分:1)

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