hide NaNs in geoshow

33 visualizaciones (últimos 30 días)
Sagar
Sagar el 5 de Nov. de 2015
Comentada: Walter Roberson el 22 de Sept. de 2023
I am plotting some data using geoshow as below: geoshow (yy, xx, data, 'displaytype', 'texturemap'); The 'data' has a lot of NaNs in it and I do not want to show them (or display them as white) in the resulting image, neither in the colorbar (colorbar should not show the white color). The range of data is between 0 and 1.5. I tried using alphadata as below: t = geoshow (yy, xx, data, 'displaytype', 'texturemap'); set(t, 'AlphaData', ~isnan(data)); but I get the error 'value must be numeric'. I looked in the forums and there are not really clean solution to this problem. Could you please provide a nice, clean solution?
Thank you,
-Sagar

Respuestas (3)

Amy Haskins
Amy Haskins el 10 de Nov. de 2015
Try using 'DisplayType', 'surface' instead of 'texturemap'. Also try looking at the fourth example on the geoshow doc page "Create Map of Korea and Display NaNs as Transparent".
  4 comentarios
Darcy Cordell
Darcy Cordell el 24 de Nov. de 2018
This does not work if you are plotting other types of data on the map.
For example, if you are plotting points using
p = geopoint(x,y);
geoshow(p)
The points will not show up because they will be "below" the surface or something. They are still there, but hiding. Not sure if there is a nice work-around...
Chien-Han Su
Chien-Han Su el 27 de Jul. de 2020
I agree with @Darcy Cordell. My application needs me to show my both data and coastlines, but using 'surface' as the 'DisplayType' makes the coastline covered by the data in some portion and therefore imcomplete.
Currently, I fixed this through customizing the colormap (adding one additional color to represent the NaN value). But still, I wonder if there is a better solution ...

Iniciar sesión para comentar.


Zelong
Zelong el 2 de Mzo. de 2023
Editada: Walter Roberson el 22 de Sept. de 2023
I also encountered this problem today and found the answer on a web page :( https://gis.stackexchange.com/questions/192577/set-nan-values-to-transparent-in-matlab-geoshow-function )
The sample code is as follows.
[lat,lon]= meshgrid(0:10);% sample lat/lon
data = peaks(11); % sample data
data(:,2:3) = NaN; % some NaN values
geoimg = geoshow(lat,lon,data,'DisplayType', 'texturemap') % save object
geoimg =
Surface with properties: EdgeColor: [0 0 0] LineStyle: 'none' FaceColor: 'texturemap' FaceLighting: 'flat' FaceAlpha: 1 XData: [11×11 double] YData: [11×11 double] ZData: [11×11 double] CData: [11×11 double] Show all properties
geoimg.AlphaDataMapping = 'none'; % interpet alpha values as transparency values
geoimg.FaceAlpha = 'texturemap'; % Indicate that the transparency can be different each pixel
alpha(geoimg,double(~isnan(data))) % Change transparency to matrix where if data==NaN --> transparency = 1, else 0.
  1 comentario
Walter Roberson
Walter Roberson el 22 de Sept. de 2023
@Yan Tong comments
This answer has solved the question perferctly!

Iniciar sesión para comentar.


Chad Greene
Chad Greene el 6 de Nov. de 2015
Hey Sagar,
Yeah, that set AlphaData trick works for imagesc but not for geoshow. You can try to work around it by converting the logical to numeric like this:
set(t, 'AlphaData',double(~isnan(data)));
But I doubt it will work the way you want it to. I tend to avoid using geoshow because I'm never quite sure how it will behave. It decides which plotting function to call based on what you enter, so why not call the plotting function directly? Can you use pcolor, pcolorm or imagesc?
  3 comentarios
Matthew Cooper
Matthew Cooper el 9 de Jul. de 2019
For this to work you need to also set 'FaceAlpha' to 'texturemap' which tells geoshow to map the AlphaData values to the FaceAlpha values.
set(t,'FaceAlpha','texturemap','AlphaData',double(~isnan(data)));
SUBHASMITA DASH
SUBHASMITA DASH el 29 de Jun. de 2023
Great! It worked for pcolorm/surfacem. Thanks a lot!

Iniciar sesión para comentar.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by