【发布时间】:2022-01-15 07:22:12
【问题描述】:
我是 python 新手,尝试使用具有两层的 geopandas 创建地图。一层是波特兰市社区的 shapefile,另一层是我要固定的波特兰经纬度数据集。
每个图都可以单独绘制(即我已经做到了那么远),但是分层不起作用,因为用于波特兰市地图的坐标不是经纬度形式。波特兰的开放数据网站上有关于如何使用 QGIS 将 shapefile 转换为 geoJSON 的说明,并在此过程中将 CRS 设置为 EPSG:4269,但我不知道如何在 Python 中使用 shapefile 执行此操作。
图像显示每个绘图都很好,直到我尝试将它们绘制在一起,注意轴...
fig,ax = plt.subplots(figsize = (15,15))
street_map.plot (ax = ax, alpha = .4, color ='grey')
fig,ax = plt.subplots(figsize = (15,15))
#street_map.plot (ax = ax, alpha = .4, color ='grey')
geo_df[geo_df['price']>250].plot(ax=ax, markersize = 20, color = 'blue', marker = "o")
fig,ax = plt.subplots(figsize = (15,15))
street_map.plot (ax = ax, alpha = .4, color ='grey')
geo_df[geo_df['price']>250].plot(ax=ax, markersize = 20, color = 'blue', marker = "o")
【问题讨论】:
-
欢迎来到python!如果您发布所有必要的代码以到达您卡住的地方,这将对我们有很大帮助 - 理想情况下包括指向 shapefile 的链接。正如一些答案指出的那样,您绝对可以对齐这些,但您需要知道 shapefile 的源 CRS。你是如何阅读 shapefile 的? Fiona 或 geopandas 还是别的什么?
标签: python geopandas shapefile