Friday, May 3, 2013

[Matlab] remove the water bodies in a m_map figure

function m_nolakes(lakeColor)
% delete the water bodies patches in figures created by m_map
%           default lakeColor is white ([1 1 1])
% usage:
%           m_nolakes(lakeColor)
%           http://scriptdemo.blogspot.com

if nargin==0
   lakeColor=[1 1 1];
elseif nargin~=1
   help m_nolakes
   return
end

gshhstypes={'c','l','i','h','f'};
for nt=1:numel(gshhstypes)
    eval(['hw=findobj(gcf,''type'',''patch'',''tag'',''m_gshhs_',gshhstypes{nt},''',''facecolor'',lakeColor);']);
    if ~isempty(hw)
       delete(hw);
    end
end
hw=findobj(gcf,'type','patch','tag','m_coast','facecolor',lakeColor);
if ~isempty(hw)
   delete(hw);
end

ShowCalendar