Extract data of a irregular shaped region from global data set
3 次查看(过去 30 天)
显示 更早的评论
Hi,
I would like to extract the field values corresponding to an irregular shaped region (E.g. a city, a country or a continent) from a global data set.
If I have the geographical boundary (longitudes and latitudes) of such region, is there a way to extract data within that region (including the boundary) from the available global data?
I tried using 'find' command but it is taking hours together just to search one day of the global data.
There must be a smart way of doing it.
Please help.
Thankyou.
0 个评论
回答(2 个)
Keegan Carvalho
2020-4-27
You will have to try indexing. Assuming you have a 3-d gridded data file (netcdf, etc.):
t % t is a variable (like temperature, precipitation, etc.)
lat
lon % lat and lon are latitude and longitude respectvely
longindex = find(lon==70.5);
latindex = find(lat==15.5);
newt = t(longindex,latindex,:); % newt is t values for a region of coordinates 70.5, 15.5
If your looking to find t values for an entire region, try using loops:
for i=1:length(latrange)
latindex(i)= find(lat==latrange(i));
end
for i=1:length(lonrange)
longindex(i)= find(lon==lonrange(i));
end
Hope this helps
0 个评论
Image Analyst
2020-4-27
Yes but what are you going to do? The easiest is if you convert the coordinates to a digital image, and then make a make a mask from the coordinates of the one region with poly2mask(). With that you can do things on "the field values" inside the mask such as get their mean or distribution or whatever.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 NetCDF 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!