display of natural earth shapefile as polygon

12 vues (au cours des 30 derniers jours)
Hanna H
Hanna H le 9 Juil 2020
Commenté : Hanna H le 10 Mar 2021
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.

Réponse acceptée

Rob Comer
Rob Comer le 3 Mar 2021
Hi Hanna,
Try clipping the ocean polygon like this before calling geoshow:
[oceanLat,oceanLon] = maptriml(oceanLat,oceanLon,[-44 -10],[112 154]);
-- Rob
  1 commentaire
Hanna H
Hanna H le 10 Mar 2021
That is working, thanks very much!

Connectez-vous pour commenter.

Plus de réponses (0)

Produits


Version

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by