Color area outside of polygon/shapefile?

5 ビュー (過去 30 日間)
Ryan
Ryan 2016 年 3 月 9 日
回答済み: Erin Browne 2019 年 3 月 19 日
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!

回答 (2 件)

Chad Greene
Chad Greene 2016 年 3 月 9 日
Hi Ryan,
Perhaps you're looking for setm with the 'ffacecolor' option.
worldmap('world')
geoshow('landareas.shp')
setm(gca,'ffacecolor',rgb('ocean blue'))
Above I used rgb to get the rgb values of ocean blue.
  8 件のコメント
Ryan
Ryan 2016 年 4 月 11 日
Thanks for this Chad! Its a step in the right direction however I noticed that the resolution isn't very good on it. I may have to find another solution.
Chad Greene
Chad Greene 2016 年 4 月 11 日
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
Erin Browne 2019 年 3 月 19 日
Hi I am wondering instead of setting the ocean color how would you do that for the land masses?

Community Treasure Hunt

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

Start Hunting!

Translated by