Search code examples
matlabmatlab-figuretiffsentinelgeotiff

Plotting geotiff in matlab with pcolor


I would like to use a scheme like this to plot satellite imagery. I'm soliciting ideas surrounding data types and scaling.

`ffn' is a .tiff, a proper geoTiff wit good metadata which looks like:

         Filename: '.\2017-04-04_Sentinel-2A_L1C_True_color.tiff'
      FileModDate: '13-Aug-2019 20:10:04'
         FileSize: 31465344
           Format: 'tif'
    FormatVersion: []
           Height: 2144
            Width: 4892
         BitDepth: 32
        ColorType: 'truecolor'
        ModelType: 'ModelTypeGeographic'
              PCS: ''
       Projection: ''
           MapSys: ''
             Zone: []
     CTProjection: ''
         ProjParm: []
       ProjParmId: ''
              GCS: 'WGS 84'
            Datum: 'World Geodetic System 1984'
        Ellipsoid: 'WGS 84'
        SemiMajor: 6378137
        SemiMinor: 6.3568e+06
               PM: 'Greenwich'
PMLongToGreenwich: 0
        UOMLength: ''
UOMLengthInMeters: []
         UOMAngle: 'degree'
UOMAngleInDegrees: 1
        TiePoints: [1×1 struct]
       PixelScale: [3×1 double]
       SpatialRef: [1×1 map.rasterref.GeographicCellsReference]
        RefMatrix: [3×2 double]
      BoundingBox: [2×2 double]
     CornerCoords: [1×1 struct]
     GeoTIFFCodes: [1×1 struct]
      GeoTIFFTags: [1×1 struct]

intensity_range = 2^16;

% call geoimread
[A, x, y, I] = geoimread(ffn, LON, LAT, 0);

% I.BitDepth shows that image is 32-bit, single type
% The range of A is: 0.0470 - 1

% index image
[X, map] = rgb2ind(A, intensity_range);

% get the size of the colormap
% size(map) yields 4923, 3

figure;
pcolor(x, y, X);

All I see is black.

I suspect A must be scaled prior to being converted to an indexed image.


Solution

  • The displayed result is black because the black grid hides the image.

    When you zoom in, you can see the image data.

    You can hide the gird as follows:

    h = pcolor(x, y, X);
    s = findobj(h, 'type', 'surface');
    s.EdgeColor = 'none';
    

    You may also display just a small part of the image, or zoom in (e.g. zoom(100)).

    You can also try resizing the image:

    pcolor(imresize(x, [100, 100]), imresize(y, [100, 100]), imresize(X, [100, 100]));