Extracting latitude/longitude metadata from LANDSAT Earth Explorer
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Eric Williams
am 25 Mai 2022
Kommentiert: Kojiro Saito
am 31 Mai 2022
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 Kommentare
Kojiro Saito
am 26 Mai 2022
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.
Akzeptierte Antwort
Kojiro Saito
am 27 Mai 2022
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 Kommentare
Kojiro Saito
am 31 Mai 2022
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.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu MATLAB Report Generator finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!