繁体   English   中英

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

[英]Extract data for each district from a matrix in Matlab

我有一个分辨率为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]);

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

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

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

平均为:

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

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

顺便说一句,我看不到第一个附件中的文件内容

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM