python - 如何从线串中获取经度/纬度
问题描述
我有一个带有一列线串的数据框。我想将线串转换为其相应的纬度/经度,以便我可以用底图绘制它。我的代码如下:
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
几何列如下所示:几何列
如何转换长字符串数据?
解决方案
我想你可以简单地使用
Lats, Lons = LineStringObject.coords.xy
它将分别返回纬度和经度数组。
推荐阅读
- c - ESP32 println 给出乱码输出 Arduino IDE
- amazon-web-services - 如何扩展 AWS 应用程序负载均衡器以应对意外的流量峰值?
- django - 如何在 Django 3.1 ModelForm 中动态设置内置 MinValueValidator 的 limit_value
- php - 如何在 url 自定义帖子类型中获取类别/子类别/帖子名称
- ubuntu - Ubuntu / Windows 双启动:尝试在 NTFS 安装卷上写入时如何解决“只读”问题?
- sql - 我可以在 SELECT 查询中使用 INSERT...RETURNING 的返回值吗?
- java - 如何在 Java Spring 中限制对操作或 URL 的访问?
- visual-studio - Visual Studio 2019 异常设置可扩展性
- excel - 自动将使用条件格式的单元格的背景颜色复制到另一个单元格
- java - 如何检查收到的信标是持续 2 分钟的信标?