0

我收到此错误:FutureWarning: '+init=:' syntax is deprecated。':' 是首选的初始化方法。进行更改时,请注意轴顺序更改:https : //pyproj4.github.io/pyproj/stable/gotchas.html#axis-order-changes-in-proj-6 return _prepare_from_string(" ".join(pjargs ))

我从一个嵌入了谷歌地图的网站上抓取了美国城市的数据。我的数据没有crs,所以我做了研究,发现谷歌地图的epsg是3857。所以我把它设置为3857

gdf.crs = {'init': 'epsg:3857'}

最后,我想创建一张标有城市的美国地图。我知道该怎么做。我拥有的地图位于 epsg:4269 中。这就是为什么我用以下方法更改数据的crs:

gdf = gdf.to_crs({'init': 'epsg:4269'})

然后,当我使用以下命令创建 excel 文件时:

points_within = gp.sjoin(gdf, US, op='within') writer = pd.ExcelWriter('locationsUS3.xlsx', engine='xlsxwriter') points_within.to_excel(writer, sheet_name='Sheet1', index=False)
writer.save()

excel文件为空。

不是当我不执行该gdf = gdf.to_crs({'init': 'epsg:4269'})步骤时,而是我收到“用户警告:正在加入的帧的 CRS 不匹配!” 错误

那么这个 FutureWarning 错误描述了什么,我该如何分别解决这个问题,我如何在这个 excel 文件中获取我的数据?

感谢您在这里帮助我!

PS:'US'是来自美国的数据

4

1 回答 1

0

你的问题有两个部分。

1) FutureWarning 错误告诉你,你不应该使用{'init': 'epsg:3857'}CRS 规范的其他方式。它可以是公正的'epsg:3857',甚至3857可以做到。

to_crs2)如果您进行重新投影而不是如果您不进行重新投影,则您的 excel 为空的原因是您的USgdfGeoDataFrames 在开始时处于相同的投影中。您刚刚在 中分配了不正确的一个gdf.crs = {'init': 'epsg:3857'}。您的代码似乎应该如下所示:

gdf.crs = 'epsg:4269'  # assign correct CRS in the correct format here

points_within = gp.sjoin(gdf, US, op='within')
writer = pd.ExcelWriter('locationsUS3.xlsx', engine='xlsxwriter') 
points_within.to_excel(writer, sheet_name='Sheet1', index=False)
于 2020-06-18T16:11:25.377 回答