Mapping Toolbox: missing values in gridded data sets
2 views (last 30 days)
Show older comments
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
Answers (0)
See Also
Categories
Find more on Blue in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!