Color area outside of polygon/shapefile?
Mostra commenti meno recenti
Hi,
I have a shapefile of the U.S.. I am simply looking to fill the outside of this shapefile with a particular color. I'm sure there is a simple solution but cannot find..
Thank you!
Risposte (2)
Chad Greene
il 9 Mar 2016
Hi Ryan,
Perhaps you're looking for setm with the 'ffacecolor' option.
worldmap('world')
geoshow('landareas.shp')
setm(gca,'ffacecolor',rgb('ocean blue'))

8 Commenti
Ryan
il 6 Apr 2016
Chad Greene
il 7 Apr 2016
[1 1 1] is white, so maybe you're not seeing it? [0 0 1] is blue, so maybe try that?
Ryan
il 7 Apr 2016
Chad Greene
il 8 Apr 2016
Modificato: Chad Greene
il 8 Apr 2016
Right, you're trying to set mmap, which is a shapefile. Try
setm(gca,'ffacecolor',[0 0 1])
We're only setting the color of the background axes.
Ryan
il 11 Apr 2016
Chad Greene
il 11 Apr 2016
Okay, so maybe you are trying to make some of your gridded data transparent so you can see the underlying background color? If yes, set the gridded data to NaN where you want to see the background. Here' I'm using landmask to get a logical matrix containing ones for all land areas. I'll set the gridded data to NaN for every grid point that is not land.
Z = flipud(drydays);
land = landmask(lat,lon);
Z(~land) = NaN;
pcolorm(lat,lon,Z)
Ryan
il 11 Apr 2016
Chad Greene
il 11 Apr 2016
If you have a shapefile, you can simply determine which pixels in your lat/lon grid fall within the bounds of the shapefile's polygon using inpolygon. If your shapefile contains multiple polygons, use Kelly Kearney's inpolygons.
Erin Browne
il 19 Mar 2019
0 voti
Hi I am wondering instead of setting the ocean color how would you do that for the land masses?
Categorie
Scopri di più su Map Display in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!