【发布时间】:2016-04-07 17:41:16
【问题描述】:
这是我的问题:
- 二维 numpy 数组数据表示每个网格空间的某些属性
- shapefile 作为研究区域(如城市)的行政区划。
例如:
http://i4.tietuku.com/84ea2afa5841517a.png
整个区域有40x40的网格网络,我想提取紫色区域内的数据。换句话说,我想屏蔽行政之外的数据。 边界到 np.nan。
我的早期尝试
我标记网格编号并选择特定的数组数据到 np.nan 中。
http://i4.tietuku.com/523df4783bea00e2.png
value[0,:] = np.nan
value[1,:] = np.nan
.
.
.
.
谁能告诉我一个更简单的方法来实现目标?
添加
找到答案here 可以将栅格数据绘制到shapefile中,但数据本身不会改变。
更新-2016-01-16
在一些答案的启发下,我已经解决了这个问题。
对此目标感兴趣的人,请查看我问过的这两个帖子:
1.Testing point with in/out of a vector shapefile
2.How to use set clipped path for Basemap polygon
关键步骤是测试我已经转换为 shapely.polygon 的 shapefile 内部/外部的点。
【问题讨论】:
标签: python arrays numpy matplotlib matplotlib-basemap