Reading a Complex banded geotiff

조회 수: 7 (최근 30일)
Randall Bonnell
Randall Bonnell 2022년 10월 11일
댓글: Randall Bonnell 2023년 9월 11일
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