Reading a Complex banded geotiff

7 vues (au cours des 30 derniers jours)
Randall Bonnell
Randall Bonnell le 11 Oct 2022
Commenté : Randall Bonnell le 11 Sep 2023
Hi there!
I am working with interferograms stored as geotiffs. They are 2-band geotiffs, the first band is the real component of the phase change in radians, while the second band is the imaginary component of the phase change. I am trying to use the following code to read in the bands:
%Read in the geotiff first (real) band
[Real,R_r] = readgeoraster(pathName,"OutputType","double","Bands",1);
%Read in the geotiff second (complex) band
[complex,R_i] = readgeoraster(pathName,"OutputType","double","Bands",2);
The first band reads in perfectly fine and I have been able to perform some preliminary analysis with it. The second band yields the following error:
"Error using readgeoraster
Unable to read band 2. Band values must be less than or equal to the total number of bands, 1."
I've read through the documentation on readgeoraster and there doesn't seem to be an argument that enables the function to read in complex numbers.
All that to say, how can I read into matlab a complex band from a geotiff?
Thanks in advance for any insight/help given!

Réponse acceptée

Maneet Kaur Bagga
Maneet Kaur Bagga le 11 Sep 2023
Hi Randall Bonnell,
As per my the understanding of the question there are two problems in the question, the first is the error encountered and the second to convert the band into an imaginary component:
  • The error "Unable to read band 2. Band values must be less than or equal to the total number of bands, 1", suggests that the GeoTIFF file may have only one band available and here more than one band is being accessed which is a possible reason for the error.
  • To verify the number of bands in the geotiff file, you may use the "geotiffinfo" function from the Mapping Toolbox as suggested below.
% Get information about the geotiff file
info = geotiffinfo(filename);
  • To create a complex array for the phase change, read the real and imaginary components separately and then combine them using the "complex" function as suggested below:
% Read in the geotiff first (real) band
[Real, R_r] = readgeoraster(pathName, "OutputType", "double", "Bands", 1);
% Read in the geotiff second (imaginary) band
[Imaginary, R_i] = readgeoraster(pathName, "OutputType", "double", "Bands", 2);
% Combine real and imaginary components into a complex array
Complex = complex(Real, Imaginary);
Please refer to the following MATLAB Documentation for better understanding of the functions:
geotiffinfo
complex function
I hope this helps!
Thank You
Maneet Bagga
  1 commentaire
Randall Bonnell
Randall Bonnell le 11 Sep 2023
Thank you, Maneet. I solved this question last year, but forgot to close it. I had success using the multibandread function.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Data Import and Analysis dans Help Center et File Exchange

Produits


Version

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by