How to set map limits on mapshow?
Afficher commentaires plus anciens
Hi all!
I currently plotted a shapefile (attached "Expot.shp") on to the world map. However, I wanted to shorten the limits. Here is my code:
landAreas = readgeotable("landareas.shp"); %taken from MATLAB documentation on mapshow
land = readgeotable("landareas.shp");
S = shaperead("Expot.shp") ;
N = length(S) ;
cmap = jet(N) ;
figure
hold on
for i = 1:N
x = S(i).X ; y = S(i).Y ;
x(isnan(x))=[] ;
y(isnan(y))=[] ;
patch(x,y,cmap(i,:)) ;
end
colorbar
C = [S.Corr] ;
caxis([min(C) max(C)])
hold on
geoshow(land,"FaceColor",[0.15 0.5 0.15])

I have tried using XLim and YLim but seem to get errors. Hence, I would like to know how to get the map limits to the coordinate limits:
Latitudes: 20N to 80N
Longitudes: -180 to -30W; basically the map showing part of North America and Greenland with my shapefile.
Would appreciate any help on this. Thanks!
Réponse acceptée
Plus de réponses (1)
xlim / ylim seems to work here:
% landAreas = readgeotable("landareas.shp"); %taken from MATLAB documentation on mapshow
land = readgeotable("landareas.shp");
% S = shaperead("Expot.shp") ;
unzip('Expot.zip')
S = shaperead("./Expot/Expot.shp") ;
N = length(S) ;
cmap = jet(N) ;
figure
hold on
for i = 1:N
x = S(i).X ; y = S(i).Y ;
x(isnan(x))=[] ;
y(isnan(y))=[] ;
patch(x,y,cmap(i,:)) ;
end
colorbar
C = [S.Corr] ;
caxis([min(C) max(C)])
hold on
geoshow(land,"FaceColor",[0.15 0.5 0.15])
xlim([-180 -30])
ylim([20 80])
% this also works:
% set(gca(),'XLim',[-180 -30],'YLim',[20 80])
What errors did you get with xlim / ylim when you tried it?
1 commentaire
Keegan Carvalho
le 28 Juin 2022
Catégories
En savoir plus sur Lighting, Transparency, and Shading dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!





