如何从matlab中的shapefile中读取多边形的子集



我正试图从shapefile中读取多边形的一个子集。我使用"shaperead"来读取shapefile,但我似乎不能只拉出我想要的多边形。我知道我应该使用'选择器'对值参数,但在线的例子对我来说没有意义:

S = shaperead('concord_roads.shp','Selector',...
       {@(v1,v2) (v1 >= 4) && (v2 >= 200),'CLASS','LENGTH'})

在我的shapefile中有一个'station number'属性,用于标识我的每个多边形。我想做的是能够指定要映射的多边形(基于前面的聚类分析)。

wanted_stations = [...]; % as previously defined
[S,C] = shaperead(filename,'selector',{@(v1) any(ismember(wanted_stations,v1)) ,'station_number'}); % assuming the attribute name is 'station_number'

基本上,对于每个多边形,shaperead将属性'station_number'的值赋给v1,然后计算匿名函数。wanted_stations向量的在定义函数时合并到函数中。

最新更新