【发布时间】:2019-07-14 12:11:08
【问题描述】:
基本上这个想法是在不使用 Qgis 的情况下自动化一些工作流程。
我未能获得与 Geopandas 中 Qgis 功能“向点添加坐标”类似的结果,该功能允许您在当前投影中获取点的 x、y 坐标并为表格创建新属性。
所以我有一组我玩过的点。原始 shapefile 的 CRS 是 epsg 2154 (Lambert 93)。我需要以与 Google 地图兼容的格式获取经纬度。
Google 将 epsg 3857 用于 Google 地图。
points = pd.DataFrame({'Id': ['001', '002', '003'],'geometry': ['POINT (909149.3986619939 6881986.232659903)', 'POINT (909649.3986619939 6882486.232659903)', 'POINT (909149.3986619939 6882486.232659903)']})
这个想法是切换到 epsg 3857 (wgs84),然后从那里创建用 wgs84 坐标填充的纬度/经度列,例如 47.357955,1.7317783。
所以我所做的是明显改变了 CRS:
pointswgs84 = points.to_crs(espg=3857)
然后
pointswgs84['lon'] = pointswgs84.geometry.x
pointswgs84['lat'] = pointswgs84.geometry.y
但是我的纬度/经度列随后会填充与原始点数据框对应的坐标:
points = pd.DataFrame({'Id': ['001', '002', '003'],'geometry':['POINT (909149.3986619939 6881986.232659903)', 'POINT (909649.3986619939 6882486.232659903)', 'POINT (909149.3986619939 6882486.232659903)'],'long': ['6881986.232659903', '6882486.232659903', '6882486.232659903'], 'lat': ['909149.3986619939', '909649.3986619939', '909149.3986619939']})
看起来我在这里遗漏了一些东西,但由于我对 Python 和 Geopandas 比较陌生,所以我不确定是什么......
感谢您的帮助。
【问题讨论】:
标签: python pandas gis qgis geopandas