16EAGLE / getSpatialData

An R package 📦 making it easy to query, preview, download and preprocess multiple kinds of spatial data 🛰 via R. All beta.
https://jakob.schwalb-willmann.de/getSpatialData
GNU General Public License v3.0
299 stars 63 forks source link

Add Sen2Cor L2A functionality to generate atmospheric-corrected Sentinel-2 L2A imagery #10

Open aTnT opened 5 years ago

aTnT commented 5 years ago

Sen2Cor is a processor for Sentinel-2 Level 2A product generation and formatting; it performs the atmospheric-, terrain and cirrus correction of Top-Of- Atmosphere Level 1C input data. Sen2Cor creates Bottom-Of-Atmosphere, optionally terrain- and cirrus corrected reflectance images; additional, Aerosol Optical Thickness-, Water Vapor-, Scene Classification Maps and Quality Indicators for cloud and snow probabilities. Its output product format is equivalent to the Level 1C User Product: JPEG 2000 images, three different resolutions, 60, 20 and 10 m.

Sec2Cor ESA webpage: http://step.esa.int/main/third-party-plugins-2/sen2cor/

Sen2Cor on Docker: https://hub.docker.com/r/atavares/sen2cor/ https://bitbucket.org/atntavares/sen2cor/src/master/

16EAGLE commented 5 years ago

Good idea, will do so as soon as I find time to continue with the prep functions. Will include a function that binds to a present sen2cor installation.

aTnT commented 5 years ago

FYI, i was able to run Sen2Cor with Docker (i have created my own Sen2Cor docker image) with the output of getSentinel_data() and run prepSentinel(). The output of running Sen2Cor on Sentinel-2 L1C imagery + running prepSentinel() is equivalent to getting L2A imagery with getSentinel_data() + running `prepSentinel(). Note that L2A seems to be only available in the servers in Europe, so outside Europe one has to run Sen2Cor to generate L2A imagery. The steps i do to generate L2A imagery from L1C are:

  1. use getSentinel_data() to download L1C imagery
  2. unzip the .zip file to make the .SAFE folder available
  3. use the Docker image atavares\sen2cor to convert L1C to L2A imagery. An example usage command is docker run --rm -ti -v {/host/machine/mapped/folder/where/the/.SAFE/folder/is/located}:/data atavares/sen2cor /data/{name_of_SAFE_folder.SAFE}
  4. zip the generated output L2A .SAFE folder
  5. Run prepSentinel() on the L2A .zip file

Maybe some improvements to add to prepSentinel() are:

band.order <- list("aux" = c("AOT", "CLD", "SCL", "TCI", "WVP", "SNW"), "refl" = c("B01", "B02", "B03", "B04", "B05", "B06", "B07", "B08", "B8A", "B09", "B10", "B11", "B12"))

hfisser commented 5 years ago

In the sen2r package is a Sentinel-2 preprocessing function accessing the Sen2Cor software. It also installs the software if not yet on the machine.

https://github.com/ranghetti/sen2r/blob/master/R/sen2cor.R