flaviostutz / sentinelloader

Sentinel-2 satellite tiles images downloader from Copernicus. Minimizes data download and combines multiple tiles to return a single area of interest.
MIT License
44 stars 18 forks source link

Selecting view and sun angles #12

Open ei-con opened 3 years ago

ei-con commented 3 years ago

I tried the Sentinelloader for my study site, and works well, thank you. I am in fact not interested in downloading the optical bands but the raster layers of sun and view angles: view_zenith_mean, view_azimuth_mean, sun_zenith, sun_azimuth. Is it possible to download those layers instead of the band selection?

flaviostutz commented 3 years ago

If this is a regular band from Sentinel API (I really don't remember this as being a band name), you can set the band name on sentinel loader's call, on the band parameter (I don't remember the exact name, please take a look).

Could you please send me something from the docs explaining about those bands for me to check?

ei-con commented 3 years ago

Looking at file in the SAFE format that I download from the Copernicus hub, they are not available as .jp2 files that I can call directly. Yet, if you open the file is SNAP, they are available as rasters (e.g. screenshot below).

Screenshot 2021-10-06 at 10 54 22

and here is an extract describing them from the ESA's documentation https://sentinel.esa.int/documents/247904/685211/Sentinel-2-Products-Specification-Document

Screenshot 2021-10-06 at 11 01 35
flaviostutz commented 3 years ago

Hm… interesting… is it a geolocalized raster image as well? Could you send a print of this image for me to give a look?

Sent from my iPhone

On 6 Oct 2021, at 11:14, ei-con @.***> wrote:

 Looking at file in the SAFE format that I download from the Copernicus hub, they are not available as .jp2 files that I can call directly. Yet, if you open the file is SNAP, they are available as rasters (e.g. screenshot below).

and here is an extract describing them from the ESA's documentation https://sentinel.esa.int/documents/247904/685211/Sentinel-2-Products-Specification-Document

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

ei-con commented 3 years ago

Here is just a view of the images, and yes they are geolocalized. But, in the SAFE file format, I only found them in the MTD_TL.xml in the GRANULE subdirectory and are sampled at 5000m,

e.g. for Viewing_Incidence_Angles_Grids, here is an extract

  _</Viewing_Incidence_Angles_Grids>
  <Viewing_Incidence_Angles_Grids bandId="0" detectorId="5">
    <Zenith>
      <COL_STEP unit="m">5000</COL_STEP>
      <ROW_STEP unit="m">5000</ROW_STEP>
      <Values_List>
        <VALUES>NaN NaN NaN NaN NaN NaN NaN 4.06849 3.73064 3.40345 3.09056 2.79688 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN</VALUES>
        <VALUES>NaN NaN NaN NaN NaN NaN 4.3193 3.97529 3.64006 3.31648 3.00826 2.72084 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN</VALUES>
        <VALUES>NaN NaN NaN NaN NaN NaN 4.22447 3.88267 3.55035 3.2305 2.92744 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN</VALUES>

so, maybe what is best is to extract the MTD_TL.xml through the Sentinelloader, and then I can create rasters from the data? Is that possible?

Screenshot 2021-10-06 at 12 54 58
flaviostutz commented 3 years ago

I think so. We can render a Geo raster from the data from the xml and interpret this data request as another “band name”. Is that the thing you were thinking?

The sun positioning info is meant to be in sync with the time the sensors data were captured, right?

I didn’t realize the difference between azimuth and azimuth_mean. Do you know what is it? One is related to sun incidence and the other is related to which view? Aren't the satellites always facing earth at the same angle?

Sent from my iPhone

On 6 Oct 2021, at 13:14, ei-con @.***> wrote:

 Here is just a view of the images, and yes they are geolocalized. But, in the SAFE file format, I only found them in the MTD_TL.xml in the GRANULE subdirectory and are sampled at 5000m,

e.g. for Viewing_Incidence_Angles_Grids, here is an extract

_

5000 5000 NaN NaN NaN NaN NaN NaN NaN 4.06849 3.73064 3.40345 3.09056 2.79688 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 4.3193 3.97529 3.64006 3.31648 3.00826 2.72084 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 4.22447 3.88267 3.55035 3.2305 2.92744 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN so, maybe what is best is to extract the MTD_TL.xml through the Sentinelloader, and then I can create rasters from the data? Is that possible? — You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.
ei-con commented 3 years ago

I think so. We can render a Geo raster from the data from the xml and interpret this data request as another “band name”. Is that the thing you were thinking?

Sounds perfect. If too complicated, we can just get the XML files through Sentinelloader and then I work on them.

The sun positioning info is meant to be in sync with the time the sensors data were captured, right?

yes

I didn’t realize the difference between azimuth and azimuth_mean. Do you know what is it? One is related to sun incidence and the other is related to which view? Aren't the satellites always facing earth at the same angle?

The mean bands are available for the view angles (not sun angles). In fact, here it is a bit tricky because the view angles are originally provided per band due to the sensor's specs. Yet, a mean value per grid cell of all band view angles are provided in the mean value layer (mean azimuth and mean zenith). Those mean layers are what I use and work well for my purpose. The screenshot below shows you an overview of how the layers are

Screenshot 2021-10-06 at 14 12 52
flaviostutz commented 3 years ago

The problem with "getting the XML" is that the result from SentinelLoader e a geolocalized raster... for returning the XML files we need a context (this is what the "product" does). I am not sure how to create an interface for this. For a single call to sentinelloader, sometimes I call multiple Copernicus products and then merge, cut and glue them together in order to compose the final desired area. I am not sure on how to "merge" those XMLs without rastering it.

It could help if you find a utility that rasters those XML files from Python so I can evaluate how hard it could be to add this feature here. If you have an idea of an API interface for returning those XML files I can think on something as well...

ei-con commented 3 years ago

I found this. https://github.com/brazil-data-cube/s2-angs

flaviostutz commented 3 years ago

Great, @ei-con. It seems like a useful tool for our needs. I will try to give this a try on the following days.

ei-con commented 3 years ago

looking forward! let me know if i can help.