overlay geotiffs with transparency using different colormaps

12 ビュー (過去 30 日間)
Ruth
Ruth 2014 年 10 月 22 日
コメント済み: Chad Greene 2014 年 10 月 27 日
If I have one geotiff plotted (using geoshow) in color how do I overlay another geotiff in black and white and make it partially tranparent?

採用された回答

Chad Greene
Chad Greene 2014 年 10 月 23 日
編集済み: Chad Greene 2014 年 10 月 23 日
I do this often when I overlay semitransparent ice speed over satellite images of glaciers. That image was created with these steps:
  1. Plot the satellite image in grayscale.
  2. Use freezeColors to allow a second color map.
  3. Plot ice speed using pcolorm(lat,lon,speed,'facealpha',.3).
  4. Set the second color map to jet(256).
The same can be done with geoshow instead of pcolorm as Bruno pointed out. However, if you're using Matlab pre-2014b, there's a bug that might make Matlab crash when pairing geoshow texture maps with marker data. pcolorm is not ideal because it discards a row and a column of data, and plots data offset by half a pixel, but if your data is dense enough it should not be a problem, and it's better than risking a total crash.
  3 件のコメント
Ruth
Ruth 2014 年 10 月 27 日
This works but I am not able to save the figure showing both layers. Only the pcolorm layer is saved. Any ideas?
Chad Greene
Chad Greene 2014 年 10 月 27 日
This is likely an issue with the renderer. Only the opengl renderer supports transparency, so try typing
set(gcf,'renderer','opengl')
Then save. If that doesn't work, use export_fig with the -opengl tag.

サインインしてコメントする。

その他の回答 (1 件)

Bruno Pop-Stefanov
Bruno Pop-Stefanov 2014 年 10 月 23 日
編集済み: Bruno Pop-Stefanov 2014 年 10 月 23 日
Calling geoshow a second time will overlay over what was previously displated. Use the 'FaceAlpha' property when calling geoshow for the second time to set the transparency.
For example, using the Display EGM96 Geoid Heights Masking Out Land Areas example in the doc page for geoshow:
% Load geoid and display
load geoid
% Create a figure with an Eckert projection
figure
axesm eckert4;
framem; gridm;
axis off
% Display the geoid as a texture map
geoshow(geoid, geoidrefvec, 'DisplayType', 'texturemap');
% Create a colorbar and title
hcb = colorbar('southoutside');
set(get(hcb,'Xlabel'),'String','EGM96 Geoid Heights in Meters.')
% Add the land in black with 30% transparency
geoshow('landareas.shp', 'FaceAlpha', 0.3, 'FaceColor','black');

Community Treasure Hunt

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

Start Hunting!

Translated by