display of natural earth shapefile as polygon

14 次查看(过去 30 天)
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.

采纳的回答

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

更多回答(0 个)

产品


版本

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by