Colorbar from an array

5 views (last 30 days)
Diego Mauricio Beramendi Ortega
Answered: Voss on 28 Jun 2022
Hi all,
I am plotting geotiff files that have only one band. To do so I followed the next suggestions: https://uk.mathworks.com/matlabcentral/answers/517443-how-i-can-view-this-tif-file?s_tid=prof_contriblnk
I would like to know how to get a colobar according the array I used in the color map. Bellow I show my code:
[A,R1] = geotiffread('MOD06_L2.A2018001.1500.CER.WGS84.RAMIS.tif');
A = uint16(A);
brown_color = [0.5 0.2 0.1];
t = linspace(0, 1, max(A,[],'all'))';
cmap = t.*brown_color + (1-t);
gs = geoshow(A, cmap, R1);
Thanks in advance!!!!

Accepted Answer

Voss
Voss on 28 Jun 2022
unzip data.zip
[A,R1] = geotiffread('MOD06_L2.A2018001.1500.CER.WGS84.RAMIS.tif');
A = uint16(A);
brown_color = [0.5 0.2 0.1];
t = linspace(0, 1, max(A,[],'all'))';
cmap = t.*brown_color + (1-t);
gs = geoshow(A, cmap, R1);
caxis([1 size(cmap,1)]);
colormap(cmap);
colorbar();

More Answers (0)

Categories

Find more on Colormaps 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!