Accurate plotting a raster within the coastlines

12 views (last 30 days)
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

Answers (1)

Supraja
Supraja on 5 May 2023
‘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
  1 Comment
Fyodor Tatarinov
Fyodor Tatarinov on 8 May 2023
Thanks for the answer. But it seems that it is not the solution, because landmask anyway will not increase the spatial resolution of original matrix, which is rather rough. But the resolution of the land map should be like in the example from MATLAB helper:
land = readgeotable("landareas.shp");
figure
newmap
geoplot(land)
But the land area should be coloured according to X values smoothed to the necessary resolution

Sign in to comment.

Products


Release

R2023a

Community Treasure Hunt

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

Start Hunting!