Extracting latitude/longitude metadata from LANDSAT Earth Explorer

조회 수: 5 (최근 30일)
I am just starting to use MATLAB. My assignment for work is to calculate the mean of a surface temperature matrix for each cell with dimensions 1 degree latitude by 1 degree longitude. I downloaded, read, converted data types, and calculated the mean of the surface temperature matrix.
My issue is with reading latitude/longitude data as an array/matrix. I found the latitude/longitude data for a tile in its metadata and downloaded its metadata as an xml and html file. I'm not sure what the steps are for reading it into MATLAB, though. Here is the latitude/longitude data I want to convert into a matrix:
<CORNER_UL_LAT_PRODUCT>39.23687</CORNER_UL_LAT_PRODUCT>
<CORNER_UL_LON_PRODUCT>-103.19598</CORNER_UL_LON_PRODUCT>
<CORNER_LR_LAT_PRODUCT>37.81339</CORNER_LR_LAT_PRODUCT>
<CORNER_LR_LON_PRODUCT>-101.34833</CORNER_LR_LON_PRODUCT>
<CORNER_UL_PROJECTION_X_PRODUCT>-615585.000</CORNER_UL_PROJECTION_X_PRODUCT>
<CORNER_UL_PROJECTION_Y_PRODUCT>1814805.000</CORNER_UL_PROJECTION_Y_PRODUCT>
<CORNER_LR_PROJECTION_X_PRODUCT>-465585.000</CORNER_LR_PROJECTION_X_PRODUCT>
<CORNER_LR_PROJECTION_Y_PRODUCT>1664805.000</CORNER_LR_PROJECTION_Y_PRODUCT>
I tried parsexml('filename') and xmlread('filename') on the xml file of the metadata, and I tried extractHTMLtext('filename'), but I got "Invalid expression" errors. I'm not sure what to do.
Let me know if anything I said was unclear or if you have advice!
  댓글 수: 2
Kojiro Saito
Kojiro Saito 2022년 5월 26일
Could you tell us the detail of Landsat products (Landsat Legacy? or Landsat Collections)? Not every product has .xml and .html file, some contain only .txt files.
Eric Williams
Eric Williams 2022년 5월 26일
Yes of course, I am using LANDSAT Collection 2 U.S. Analysis Ready Data (ARD).

댓글을 달려면 로그인하십시오.

채택된 답변

Kojiro Saito
Kojiro Saito 2022년 5월 27일
From R2021a, readstruct and readtable can read xml files.
I have tested with a xml file of "C2 ARD Tile Metadata Bundle" of "LANDSAT Collection 2 U.S. Analysis Ready Data".
% Read XML file as a structure
str = readstruct('LC09_AK_000010_20220521_20220526_02.xml');
% Extract TILE_METADATA -> PROJECTION_ATTRIBUTES
projAttr = str.TILE_METADATA.PROJECTION_ATTRIBUTES;
% Get values
cornerUlLatLon = [projAttr.CORNER_UL_LAT_PRODUCT, projAttr.CORNER_UL_LON_PRODUCT];
cornerLrLatLon = [projAttr.CORNER_LR_LAT_PRODUCT, projAttr.CORNER_LR_LON_PRODUCT];
cornerUlProjXY = [projAttr.CORNER_UL_PROJECTION_X_PRODUCT, projAttr.CORNER_UL_PROJECTION_Y_PRODUCT];
cornerLrProjXY = [projAttr.CORNER_LR_PROJECTION_X_PRODUCT, projAttr.CORNER_LR_PROJECTION_Y_PRODUCT];
  댓글 수: 2
Eric Williams
Eric Williams 2022년 5월 31일
Thank you very much for your help! That saved me, because I used this code to get my lat/long values right before my meeting with my supervisor!
One more general question: since the values in projAttr are for the upper left corner and lower right corner, that covers the spatial extend of the entire tile, right? I just want to make sure I don't worry about the lower left and upper right corners being "missing" from projAttr.
Kojiro Saito
Kojiro Saito 2022년 5월 31일
Great to hear that!
projAttr contains <PROJECTION_ATTRIBUTES> tag and upper left corner and lower right corner exist in <PROJECTION_ATTRIBUTES> tag. So, I think it covers the spatial extend of the entire tile.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 MATLAB Report Generator에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by