Inpolygon 3D Array Processing

3 次查看(过去 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