Reading a Complex banded geotiff

7 visualizzazioni (ultimi 30 giorni)
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!

Risposta accettata

Maneet Kaur Bagga
Maneet Kaur Bagga il 11 Set 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 Commento
Randall Bonnell
Randall Bonnell il 11 Set 2023
Thank you, Maneet. I solved this question last year, but forgot to close it. I had success using the multibandread function.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Data Import and Analysis in Help Center e File Exchange

Prodotti


Release

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by