Sentinel-2-L2A xml metadata to a raster in R #155
Replies: 4 comments 2 replies
-
Dear Mitro
I am cc your message to Felipe Souza and Rolf Simoes, who are the developers and maintainers of “rstac”, and work in my team in Brazil. I hope they are able to help you.
All the best
Gilberto
============================
Prof Dr Gilberto Camara
Senior Researcher
National Institute for Space Research (INPE), Brazil
https://gilbertocamara.org/
=============================
… On 3 Jan 2023, at 10:51, MullerMitro ***@***.***> wrote:
I have been using rstac and gdalcubes R packages to compute zonal statistics from time series of Sentinel-2-L2A data. I would like to be able to extract the sun zenith angle information at each location also. The Sentinel-2 STAC item collection includes asset named "granule-metadata". This data is stored in xml format. It seems to store gridded information on incidence angles with 5km spatial resolution (Geometric_Info$Tile_Angles$Sun_Angles_Grid$Zenith).
I am searching for a solution on how to parse the xml data and transform the gridded sun zenith angle values to a raster band.
Any suggestions how to solve this in R?
—
Reply to this email directly, view it on GitHub <#155>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/ABOHEDKOI6YB4C622B5QENDWQQVHRANCNFSM6AAAAAATPWYFGA>.
You are receiving this because you are subscribed to this thread.
|
Beta Was this translation helpful? Give feedback.
-
xref to stactools-packages/sentinel2#50, which is requesting that this information be added to the stactools package, so that it's available through the STAC metadata. |
Beta Was this translation helpful? Give feedback.
-
I don't know any solution in R for transforming the gridded sun zenith and azimuth angle values to a raster. However, I have found a possible solution in the paper "Sentinel-2 MultiSpectral Instrument (MSI) data processing for aquatic science applications: Demonstrations and validations" by Pahlevan et al. (2017). The paper includes a Python script in the annex that can be used to compute the angles. The script, written in Python 2.7, implements an algorithm for determining the orbit and viewing angle observations of the Sentinel-2A sensor. It reads the values from the XML file that you have mentioned. The algorithm then computes the angles for each pixel from an orbit model. To run the script, you must download a Sentinel-2 image in the SAFE format. Then, you should uncompress the file and specify the MTD_TL.xml file located in the granule folder as the script argument. Note that the script must also access the QI_DATA subfolder inside the SAFE structure. The script can generate a raster of sun azimuth and zenith angles in HDR format, but you might be able to adapt this for your purposes. You can find additional information in the following ESA forum issues:
@OldLipe, do you know any other solution? |
Beta Was this translation helpful? Give feedback.
-
Dear all, https://drive.google.com/drive/folders/1g_hG5LB1HeHEA2_lz1WDSDlnbQT0npLK?usp=drive_link I had to make some modifications, for example, the file s2_angles.R became s2_angles_rev.R due to an intervention at line 146. There is no full agreement between the angles derived using these scripts and those derived from SNAP (see scatterplots for reference), but this may be due to simplifications introduced in the scripts to produce the SAA and OAA angles, as well as the 500x500 m grid adopted in SNAP. Kind regard |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I have been using rstac and gdalcubes R packages to compute zonal statistics from time series of Sentinel-2-L2A data. I would like to be able to extract the sun zenith angle information at each location also. The Sentinel-2 STAC item collection includes asset named "granule-metadata". This data is stored in xml format. It seems to store gridded information on incidence angles with 5km spatial resolution (Geometric_Info$Tile_Angles$Sun_Angles_Grid$Zenith).
I am searching for a solution on how to parse the xml data and transform the gridded sun zenith angle values to a raster band.
Any suggestions how to solve this in R?
Beta Was this translation helpful? Give feedback.
All reactions