Obtaining the values within the boundary of my map

5 ビュー (過去 30 日間)
Benyamin Nemati
Benyamin Nemati 2020 年 10 月 14 日
編集済み: Benyamin Nemati 2020 年 10 月 27 日
Hello everyone,
I have some plots that they're from a 180*360*12 matrix with a code like this:
for i = 1:12
load coast
figure(i)
hold on
imagesc(lambda-180,phi,EWT(:,:,i));
plot(long,lat,'k');
end
B_1 = shaperead('Aqueduct_river_basins_TIGRIS & EUPHRATES.shp'); %one of the shape files that ive loaded on my map
mapshow(B_1,'facecolor','none');
you can see the boundaries on the map,the north africa and middle east region, now my question is: how could i derive EWT values within these boundaries, i want the average values on these areas at the end.
thanks for your considerations.
  3 件のコメント
KSSV
KSSV 2020 年 10 月 14 日
inpolygon is your function..go for it.
Benyamin Nemati
Benyamin Nemati 2020 年 10 月 15 日
how can i use this function on my Z values (EWT(:,:,i)) as xq and yq ?
by considering my code, what is your suggestion?

サインインしてコメントする。

採用された回答

KSSV
KSSV 2020 年 10 月 15 日
Something like this:
[m,n,p] = size(EWT) ;
[X,Y] = meshgrid(lambda-180,phi) ;
B_1 = shaperead('Aqueduct_river_basins_TIGRIS & EUPHRATES.shp'); %one of the shape files that ive loaded on my map
N = length(B-1.X) ; % this should have different regions
iwant = cell(N,1) ;
for i = 1:N
% Get the indices insdie this polygon
idx = inpolygon(X,Y,B_1(i).X,B_i(i).Y) ;
% Get the mean of these points
thesum = 0 ;
for j = 1:p
T = EWT(:,:,i) ;
thesum = thesum+T(idx) ;
end
iwant{i} = thesum/p ;
end
The above code gives you inside the polygon points as scattered points. If you want grid, pick the chunk, use inpoltgon and make the outside indices data to NaN.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeElementary Polygons についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by