Reading a Complex banded geotiff

7 次查看(过去 30 天)
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!

采纳的回答

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

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Data Import and Analysis 的更多信息

产品


版本

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by