Accurate plotting a raster within the coastlines
12 次查看(过去 30 天)
显示 更早的评论
I have a global raster data X as matrix (long*lat) 288x192 and additional vectors of longitudes (1:288) and latitudes (1:192). I need to make a nice map of X within land area. Someone recommended me to use a skript landmask.m. So, I run the following subscript (under Matlab 2023a)
land(1:288,1:192) = 0;
for i=1:288
for j=1:192
land(i,j)=landmask(lat(j),lon(i));
end
end
It works, but shows many times the following warning:
Warning: The results from INPOLYGON may not be reliable. The size of the polygon is approaching the lower limit of what can be handled with reasonable accuracy.
Then I plot my data X under condition land~=0 (only land) using contourf. It works, but the result is very rough from the point of view of land presenting:
How can I combine my rather rough raster data (with ~1 degree step) with accurate coastline presentation?
Thanks
0 个评论
回答(1 个)
Supraja
2023-5-5
‘landmask’ function returns a logical array describing the landness of any given lat/lon arrays.
land = landmask(..., quality) specifies quality from 0 to 100. This option is provided because for large data sets, the land mask function can take quite some time. For example, a calculation of 180x360 land mask for all continents takes about 65 seconds at 100% quality. Default quality is 95, which takes about 6 seconds for the same dataset. The quality setting is only used when calculating the land mask using all of the world's continents. For single land masses, 100% quality is assumed.
You can try following the examples and functions given in the link here:https://www.mathworks.com/matlabcentral/fileexchange/48661-landmask?s_tid=srchtitle_landmask%2520_1
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!