필터 지우기
필터 지우기

Inpolygon 3D Array Processing

조회 수: 5 (최근 30일)
Timo
Timo 2018년 3월 28일
댓글: Timo 2018년 10월 15일
Hello everybody,
I am facing some problems related to the processing of a time series of geospatial data (satellite data). For example I have an array A with 300 rows indicating the latitude and 400 columns representing longitudinal values, both sorted (of course) in ascending order and forming my grid. Thus, I have 120000 values (1 value for each lat/lon combination. So far so good with inpolygon its simple to intersect a shapefile and get the grid cells that lie within this shapefile (and building my area of interest), represented and stored in the variable in. Afterwards it is no problem calculate the mean, sum or whatever I want for this region with:
m=mean(A(in))
s=sum(A(in))
But my problem is that my array A has a third dimension (length 100 for example) indicating the time step (100 months for example), so I want to calculate the mean, sum etc. for this region of my shapefile for each time step resulting in an output vector which stores the mean for each time step (thus an vector m of length 100 where each cell represents the mean for this region for this month). I guess there should a solution but until now I am only able to calculate my quantities of interest for the first time step. I really would appreciate some hints or advices and would be grateful :). If you need additional information or more precise information please let me know.
Thanks in advance

답변 (1개)

Timo
Timo 2018년 3월 28일
편집: Timo 2018년 3월 28일
Sorry for this stupid question :)
Simply do:
for i=1:size(A,3)
t=A(:,:,i);
m=mean(t(in));
s=mean(t(in));
end
Maybe it will still be helpful for someone else :)
Greetings
  댓글 수: 2
Shakir Hussain
Shakir Hussain 2018년 10월 10일
Timo, How did you extract 3D geospatial data with polygon? Can you share the codes here?
Timo
Timo 2018년 10월 15일
Of course. Let us assume you want to check the location of a shapefile within a grid:
shp=shaperead('shapefile location and shapefilename');
xcoord=shp.X
ycoord=shp.Y
xcoord=shp.X
lon=30:0.5:50 %longitude 30° - 50°
lat=10:0.5:45 %latitude 10° - 45°
[X Y]=meshgrid(lon,lat)
inside=inpolygon(X,Y,Xcoord,ycoord); %Gives back a logical array

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Reference Applications에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by