从Matlab中的矩阵中提取每个地区的数据

时间:2019-01-19 19:02:19

标签: matlab matrix mapping spatial shapefile

我有一个分辨率为0.1度的数据矩阵(331X301),包含整个印度,还有一个以districtName作为属性的地区级shapefile。我通常从ArcGIS的矩阵栅格中提取每个地区的数据。有没有一种方法可以提取Matlab中所有地区的均值数据(该地区所有0.1度网格的均值)?

shapefile的链接:https://1drv.ms/f/s!Ajxh9oeoND9bhOcwrzoLfEqBUNUTOg

数据链接:https://1drv.ms/u/s!Ajxh9oeoND9bhOcva9i-ByW45YBwoA

注意:数据为3维-331x301x12。

在数据上覆盖shapefile的代码如下:

但是,shapefile S具有2299个属性,我无法为这2299个属性中的每一个提取z2的值

Reading the shapefile
S=shaperead('C:\shpfiles\india_adm3.shp');

%selecting the first month from the data of 321x321x12
z2= data(:,:,1)

%makking dummy coordinates for the data
x = linspace(67, 97, 301);
y = linspace(5, 38, 331);
[x,y] = meshgrid(x,y);
y=flipud(y);

%Clipping the data to the coastlines
isin = inpolygon(x,y,S.X,S.Y);
z2(~isin) = NaN;


figure('color','w');

mx=geoshow('landareas.shp', 'FaceColor', 'White');

contourf(x,y,z2,'LineColor','none');

hold on

displaying the shapefile
S1=shaperead('C:\shpfiles\india_adm3.shp','Attributes',{'BoundingBox'});

lon1 = [S1.X]';
lat1 = [S1.Y]';
plot(lon1,lat1,'Linewidth',2,'color',[0 0 0]);

1 个答案:

答案 0 :(得分:0)

因此,您基本上有一组12张图像...

您大致可以将第一张地图(及以下地图)描述为:

imshow(data(:,:,1),[0 400])

平均为:

imshow(mean(data,3),[0 400])

但是我怕你还需要其他东西吗?

通过这种方式,我无法在第一个附件中看到文件内容