MATLAB: Display of natural earth shapefile as polygon

geoshowMapping Toolboxmatlab 2017bmatlab 2020apolygonshapefileworldmap

Hi,
I am making a map in Matlab 2020a and only want to display data on land, mask out the data points over the ocean and display all oceans in white. I am using a shapefile from natural earth (ne_10m_ocean.shp). I have used the same code in the past to make maps and it always worked out. Now I have upgraded from 2017b to 2020a and suddenly my code is not working anymore and I am wondering why and how to fix it. Below is relevant piece of code. input_plot are my input data and the shapefile is supposed to be plotted on top.
O = shaperead(ocean_file,'UseGeoCoords',true);
oceanLat = extractfield(O,'Lat');
oceanLon = extractfield(O,'Lon');
figure
h = worldmap([-44 -10],[112 154]);
setm(h,'MapProjection','mercator');
getm(h,'MapProjection');
setm(h,'MlabelParallel','south');
geoimg = geoshow(Lon,Lat,input_plot,'Displaytype','texturemap');
hold on
geoshow(oceanLat, oceanLon,'DisplayType','polygon','FaceColor','white');
Thanks in advance.

Best Answer

Hi Hanna,
Try clipping the ocean polygon like this before calling geoshow:
[oceanLat,oceanLon] = maptriml(oceanLat,oceanLon,[-44 -10],[112 154]);
-- Rob
Related Question