首页 > 解决方案 > 如何从线串中获取经度/纬度

问题描述

我有一个带有一列线串的数据框。我想将线串转换为其相应的纬度/经度,以便我可以用底图绘制它。我的代码如下:

gdf = gpd.read_file('./call2016.shp') #read the data into a variable

streetsaslinestring = gdf.loc[: , "geometry"] #getting the linestring column

接下来,我想将数据转换为 lon/lat。

streetsinlatlong    = convert_etrs89_to_lonlat(streetsaslinestring)

streetsinlatlong.to_file('./streetslonglat.shp') #store it as .shp in order to plot it with basemap

m.readshapefile('./streetslonglat', 'streets') #read as shape file

几何列如下所示:几何列

如何转换长字符串数据?

标签: pythonmatplotlib-basemapgeopandasmultilinestring

解决方案


我想你可以简单地使用

Lats, Lons = LineStringObject.coords.xy

它将分别返回纬度和经度数组。


推荐阅读