forked from ranghetti/sen2r
-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.Rmd
211 lines (175 loc) · 11.3 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
---
output:
github_document:
toc: yes
toc_depth: 2
fig_caption: no
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, echo = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "README-"
)
```
[![Travis-CI Build Status](https://travis-ci.org/ranghetti/sen2r.svg?branch=master)](https://travis-ci.org/ranghetti/sen2r)
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.1240384.svg)](https://doi.org/10.5281/zenodo.1240384)
[![CRAN_Status_Badge](http://www.r-pkg.org/badges/version/sen2r)](https://cran.r-project.org/package=sen2r)
[![License: GPL v3](https://img.shields.io/badge/License-GPL%20v3-blue.svg)](http://www.gnu.org/licenses/gpl-3.0)
<img src="man/figures/sen2r_logo_200px.png" width="200" height="113" align="right" />
# An R toolbox to find, download and preprocess Sentinel-2 data
<span style="color:#5793dd;vertical-align:top;font-size:90%;font-weight:normal;">sen</span><span style="color:#6a7077;vertical-align:baseline;font-size:115%;font-weight:bolder;">2</span><span style="color:#2f66d5;vertical-align:baseline;font-size:90%;font-weight:bold;">r</span>
is an R library which helps to download and preprocess Sentinel-2 optical images.
The purpose of the functions contained in the library is to provide the instruments
required to easily perform (and eventually automate) all the steps necessary
to build a complete Sentinel-2 processing chain, without the need of any manual
intervention nor the needing to manually integrate any external tool.
In particular,
<span style="color:#5793dd;vertical-align:top;font-size:90%;font-weight:normal;">sen</span><span style="color:#6a7077;vertical-align:baseline;font-size:115%;font-weight:bolder;">2</span><span style="color:#2f66d5;vertical-align:baseline;font-size:90%;font-weight:bold;">r</span>
allows to:
* retrieve the list of available products on a selected area
(which can be provided by specifying a bounding box, by loading a vector file
or by drawing it on a map) in a given time window;
* download the required SAFE Level-1C products, or
retrieve the required SAFE Level-2A products by downloading them (if available)
or downloading the corresponding Level-1C and correcting them with **sen2cor**;
* obtain the required products (Top of Atmosphere radiances, Bottom of Atmosphere
reflectances, Surface Classification Maps, True Colour Images) clipped on the
specified area (adjacent tiles belonging to the same frame are merged);
* mask cloudy pixels (using the Surface Classification Map as masking layer);
* computing spectral indices.
Setting the execution of this processing chain is particularly easy using the
<span style="color:#5793dd;vertical-align:top;font-size:90%;font-weight:normal;">sen</span><span style="color:#6a7077;vertical-align:baseline;font-size:115%;font-weight:bolder;">2</span><span style="color:#2f66d5;vertical-align:baseline;font-size:90%;font-weight:bold;">r</span>
GUI, which allows to set the parameters, to directly launch the main function
or to save them in a JSON file which can be used to launch the processing at a later stage.
The possibility to launch the processing with a set of parameters saved in a JSON file
(or directly passed as function arguments) makes easy to build scripts to
automatically update an archive of Sentinel-2 products.
Specific processing operations (i.e. applying **sen2cor** on Level-1c SAFE products,
merging adjacent tiles, computing spectral indices from existing products)
can also be performed using intermediate functions (see [usage](#usage)).
## Warning
This package is under construction (current version is [pre-release 0.3.3](https://github.com/ranghetti/sen2r/releases/tag/v0.3.3)).
Please refer to the [crontab of release 0.4.0](https://github.com/ranghetti/sen2r/milestone/3)
to know which implementations should already be performed.
## Installation
<span style="color:#5793dd;vertical-align:top;font-size:90%;font-weight:normal;">sen</span><span style="color:#6a7077;vertical-align:baseline;font-size:115%;font-weight:bolder;">2</span><span style="color:#2f66d5;vertical-align:baseline;font-size:90%;font-weight:bold;">r</span>
is supported over Linux and Windows operating systems;
the support for Mac will be added soon.
The package can be installed from GitHub with the R package **devtools**.
To do it:
1. install the package **devtools**, if missing:
```{r, eval = FALSE}
install.packages("devtools")
```
2. load it and install
<span style="color:#5793dd;vertical-align:top;font-size:90%;font-weight:normal;">sen</span><span
style="color:#6a7077;vertical-align:baseline;font-size:115%;font-weight:bolder;">2</span><span
style="color:#2f66d5;vertical-align:baseline;font-size:90%;font-weight:bold;">r</span>:
```{r, eval = FALSE}
library(devtools)
install_github("ranghetti/sen2r")
```
This will install the R package along with its R dependences,
containing all the functions necessary to preprocess data.
To run the functions correctly, some external dependences are required:
* [**GDAL**](http://www.gdal.org) (with support for JP2OpenJPEG format):
this is a mandatory dependency, needed for all the processing operations
and to retrieve metadata from SAFE products;
* [**sen2cor**](http://step.esa.int/main/third-party-plugins-2/sen2cor)
is used to perform atmospheric correction of Sentinel-2 Level-1C products:
it is required by the package, unless you choose not to correct products locally
(using only Level-1C – TOA products or dowloading directly Level-2A products).
* **Wget** is the downloader used by the package; it is required to work online.
* [**aria2**](https://aria2.github.io) is an alternative downloader which
can be used to faster the download of SAFE archives; it can be optionally
installed and used.
These dependences can be graphically checked launching the function
```{r, eval = FALSE}
library(sen2r)
check_sen2r_deps()
```
This function opens a GUI which help to check that they are satisfied;
if some of them are missing, follow the instructions provided by the GUI
to install them (on Windows, the GUI allows to install them directly).
<!-- Atmospheric correction is performed using [sen2cor](http://step.esa.int/main/third-party-plugins-2/sen2cor):
the package will automatically download and install it at first use,
or by running function [`install_sen2cor()`](reference/install_sen2cor.md).
Please notice that the use of sen2cor algorythm was not yet possible under MAC.
Preprocessing functions make use of [GDAL](http://www.gdal.org), which must
support JPEG2000 format. On Windows, it is strongly recommended to install it
using the [OSGeo4W installer](http://download.osgeo.org/osgeo4w/osgeo4w-setup-x86_64.exe)
in advanced mode, and checking the installation of `openjpeg` library. -->
## Usage
The simplest way to use
<span style="color:#5793dd;vertical-align:top;font-size:90%;font-weight:normal;">sen</span><span style="color:#6a7077;vertical-align:baseline;font-size:115%;font-weight:bolder;">2</span><span style="color:#2f66d5;vertical-align:baseline;font-size:90%;font-weight:bold;">r</span>
is to execute it in interactive mode:
```{r, eval = FALSE}
library(sen2r)
sen2r()
```
this opens a GUI which allows to set the required processing parameters,
and then launches the main function.
<p style="text-align:center;">
<a href="https://raw.githubusercontent.com/ranghetti/sen2r/devel/man/figures/sen2r_gui_sheet1.jpg" target="_blank">
<img src="man/figures/sen2r_gui_sheet1_small.png">
</a>
<a href="https://raw.githubusercontent.com/ranghetti/sen2r/devel/man/figures/sen2r_gui_sheet2.jpg" target="_blank">
<img src="man/figures/sen2r_gui_sheet2_small.png">
</a>
<a href="https://raw.githubusercontent.com/ranghetti/sen2r/devel/man/figures/sen2r_gui_sheet3.jpg" target="_blank">
<img src="man/figures/sen2r_gui_sheet3_small.png">
</a>
<a href="https://raw.githubusercontent.com/ranghetti/sen2r/devel/man/figures/sen2r_gui_sheet4.jpg" target="_blank">
<img src="man/figures/sen2r_gui_sheet4_small.png">
</a>
</p>
Alternatively,
[`sen2r()`](reference/sen2r.md)
can be launched with a list of parameters (created with
[`s2_gui()`](reference/s2_gui.md))
or passing manually the parameters as arguments of the function
(see [the documentation of the function](reference/sen2r.md) for further details).
Other specific functions can be used to run single steps separately:
* [`s2_list()`](reference/s2_list.md)
to retrieve the list of available Sentinel-2 products basing on input parameters;
* [`s2_download()`](reference/s2_download.md)
to download Sentinel-2 products;
* [`sen2cor()`](reference/sen2cor.html)
to correct level-1C products using [sen2cor](http://step.esa.int/main/third-party-plugins-2/sen2cor);
* [`s2_translate()`](reference/s2_translate.md)
to convert Sentinel-2 products from SAFE format to a format managed by GDAL;
* [`s2_merge()`](reference/s2_merge.md)
to merge Sentinel-2 tiles which have the same date and orbit;
* [`gdal_warp()`](reference/gdal_warp.md)
to clip, reproject and warp raster files (this is a wrapper to call
[gdal_translate](http://www.gdal.org/gdal_translate.html) or
[gdalwarp](http://www.gdal.org/gdalwarp.html) basing on input parameters);
* [`s2_mask()`](reference/s2_mask.md)
to apply a cloud mask to Sentinel-2 products;
* [`s2_calcindices()`](reference/s2_calcindices.md)
to compute maps of spectral indices from Sentinel-2 Surface Reflectance multiband raster files;
* [`s2_thumbnails()`](reference/s2_thumbnails.md)
to generate RGB thumbnails (JPEG or PNG) of the products.
## Credits
<a href="http://www.irea.cnr.it" ref="_blank"> <img src="man/figures/irea_logo_200px.png" height="100" align="left" /></a>
<span style="color:#5793dd;vertical-align:top;font-size:90%;font-weight:normal;">sen</span><span style="color:#6a7077;vertical-align:baseline;font-size:115%;font-weight:bolder;">2</span><span style="color:#2f66d5;vertical-align:baseline;font-size:90%;font-weight:bold;">r</span>
is being developed by Luigi Ranghetti and Lorenzo Busetto
([IREA-CNR](http://www.irea.cnr.it)),
and it is released under the [GNU General Public License version 3](https://www.gnu.org/licenses/gpl-3.0.html) (GPL‑3).
The [<span style="color:#5793dd;vertical-align:top;font-size:90%;font-weight:normal;">sen</span><span style="color:#6a7077;vertical-align:baseline;font-size:115%;font-weight:bolder;">2</span><span style="color:#2f66d5;vertical-align:baseline;font-size:90%;font-weight:bold;">r</span> logo](https://raw.githubusercontent.com/ranghetti/sen2r/devel/man/figures/sen2r_logo_200px.png),
partially derived from the [R logo](https://www.r-project.org/logo),
is released under the [Creative Commons Attribution-ShareAlike 4.0 International license](https://creativecommons.org/licenses/by-sa/4.0) (CC-BY-SA 4.0).
To cite this library, please use the following entry:
Ranghetti, L.\ and Busetto, L.\ (2018). *sen2r: an R toolbox to find, download and preprocess Sentinel-2 data*. R package version 0.3.3. DOI: [10.5281/zenodo.1240384](https://ranghetti.github.io/sen2r).
```bibtex
@Manual{sen2r,
title = {sen2r: an R toolbox to find, download and preprocess Sentinel-2 data},
author = {Luigi Ranghetti and Lorenzo Busetto},
year = {2018},
note = {R package version 0.3.3},
doi = {10.5281/zenodo.1240384},
url = {https://ranghetti.github.io/sen2r},
}
```