How can I read a single band, from a multi-band GeoTiff file?

7 次查看(过去 30 天)
Hi, i have spent a lot of time to figure out how can i read only a specific band from a geoTiff file.
I have a GeoTiff file with a lot of bands and i need to import to my code, only one of them.
I tried:
imread( 'mybigdata.tif' , 3 );
%Error message : Invalid TIFF image index 3.
tiffreadVolume( 'mybigdata.tif' , 'PixelRegion' , { [1 1 inf] , [1 1 inf] , [3 3] });
%Error message Requested slice 3 is greater than the number of slices (1) in the volume.
if i use X = tiffreadVolume( 'mybigdata.tif' , 'PixelRegion' , { [1 1 inf] , [1 1 inf] , [1 1] });
Name Size Bytes Class Attributes
X 1698x1493x1x13 131825928 single
I can see the 13 bands in this example, in 4th dimension for some reason, but i dont know how to read only the one of them
if i use X = imread( 'mybigdata.tif' ); , the whole image is imported again:
Name Size Bytes Class Attributes
X 1698x1493x13 131825928 single
My tiff file was created using: geotiffwrite.
Any ideas?
Thanks in Advance.

回答(1 个)

Ashish Uthama
Ashish Uthama 2024-5-10
Please try the 'Bands' Name-Value argument in readgeoraster.

类别

Help CenterFile Exchange 中查找有关 Import, Export, and Conversion 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by