【问题标题】:Clipping a Pandas dataframe to a shapefile using Python使用 Python 将 Pandas 数据框剪切到 shapefile
【发布时间】:2016-03-19 20:44:59
【问题描述】:

我有一个 Pandas 数据框,其中包含大量点的纬度和经度数据,我想将它们剪辑到 shapefile;即:shapefile 边界之外的所有内容都将被删除。

有没有办法在 Python 包(如 MatPlotLib)中实现这一点?

我在 Google 上搜索过,但“剪辑”似乎是指被地图图例/轴截断的数据,而不是我所描述的。

此图像显示了我所追求的 - 我在 ArcMap 中进行了此操作,但需要自动化该过程。灰点代表整个数据框,而红点被“剪裁”到下面的绿色 shapefile。

这是我正在运行的代码,用于覆盖点以防万一它有任何用处:

f, ax = plt.subplots(1, figsize=(12, 12))
ax.plot(Easting,Northing, 'bo', markersize=5)
IMD.plot(column='imd_score', colormap='Blues', linewidth=0.1, axes=ax)
locs, labels = plt.xticks()
plt.setp(labels, rotation=90)
plt.axis('equal')

【问题讨论】:

    标签: python pandas matplotlib clip arcmap


    【解决方案1】:

    你可以试试geopandas。这是一个非常好的库,基本上可以与 pandas 数据框一起使用,但是是地理定位的,即包含几何列。您可以直接在其中导入导出 shapefile,最后执行Intersection 之类的操作。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-06-04
      • 2021-02-11
      • 2021-06-04
      • 2018-10-21
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多