Mapping Toolbox: missing values in gridded data sets

2 views (last 30 days)
Hi all,
I have a gridded data set that I'm trying to map with the Mapping Toolbox. The data set only contains values for land, so I want the non-land cells (essentially missing data) to show a specific color. I tried passing NaNs for the non-land cells but it seems that NaNs are simply given the color for the lowest value in the data set, e.g. dark blue for the jet colormap. I tried adding an extra color to bottom of the colormap matrix, but this causes land cells with very low values to be plotted in the same color. See below for a minimal example. What I want is to change the color if the "missing data cells" (eye(20)). I also tried to do this by setting the transparency of the non-land cells, as shown below as well but I'm getting an error message.
Thanks in advance for advice!
data = rand([20,20]);
data(eye(20)==1)=nan; % missing data
lat = linspace(-90,90,21);
lon = linspace(0,360,21);
[latM lonM] = meshgrat(lat,lon);
figure
h_ax = axesm('MapProjection', 'eqdcylin','grid','on','MaplonLimit',[0 360]);
h_map = geoshow(latM,lonM,data,'DisplayType','texturemap')
% add extra color to bottom of colormap; doesn't work
set(gcf,'colormap',[get(gcf,'colormap'); [1 1 1]]);
% set missing data cells to transparent; doesn't work
set(h_map,'alphaData',eye(20))
set(h_map,'faceAlpha','flat')
  2 Comments
Maarten
Maarten on 24 Feb 2014
"Warning: FaceAlpha Texture is only possible if FaceColor is Texture and if size(AlphaData) equals size(CData)" 2 times. After running these command the axes are empty.

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!