diff --git a/DESCRIPTION b/DESCRIPTION
index d920a147..8972709e 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -1,13 +1,12 @@
Package: sen2r
Type: Package
Title: Find, Download and Process Sentinel-2 Data
-Version: 1.3.9.9002
+Version: 1.4.0
Authors@R: c(person("Luigi", "Ranghetti",
email = "luigi@ranghetti.info",
role = c("aut", "cre"),
comment = c(ORCID = "0000-0001-6207-5188")),
person("Lorenzo", "Busetto",
- email = "lbusett@gmail.com",
role = c("aut"),
comment = c(ORCID = "0000-0001-9634-6038")))
Description: Functions to download Sentinel-2 optical images
diff --git a/NEWS.md b/NEWS.md
index ec0128b5..94f5f1e8 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -1,3 +1,41 @@
+# Version 1.4.0
+
+## Major changes
+- `gdal_warp()` was partially rewritten: now reshaped rasters conserve square
+ pixels also after warping operations. _This change also affects `sen2r()`
+ products if reshaping features (reprojection or custom resolution)
+ are required._
+ This update was necessary due to changes performed in GDAL since version
+ 3.2.0 (see [OSGeo/gdal♯3294](https://github.com/OSGeo/gdal/issues/3294)),
+ which did not grant homogeneity between outputs produced with different
+ GDAL versions.
+ Note that, in case the user wants to update an existing sen2r archive
+ produced with `{sen2r}` < 1.4.0, the old existing grid is maintained
+ so that product grids are equal (in order to produce outputs with the new
+ grid, users must create a new archive).
+- Manage images split in two SAFE products, to avoid producing black areas
+ in these [uncommon] cases (see #353 for an explanation).
+ As effects:
+ 1. now pixels outside footprints (including nodata outside orbits coverage)
+ are always set to nodata;
+ 2. now `s2_download()` is no more able to use existing products equivalent
+ to found ones.
+
+## Minor changes
+- Add templates for GitHub issues.
+- Do not return error in tests in case of SciHub server down (#354).
+
+## Changes in default values
+- Pixels outside footprints (because of previous point, or - more frequently -
+ because outside orbits coverage) are always set to NA even
+ if no cloud masking is performed.
+- `s2_download()` no more uses existing SAFE products instead than downloading
+ new equivalent ones (this in order to manage images split in two SAFE archives).
+
+## Documentation
+- Update vignette data (granting using online data) (#360).
+
+
# Version 1.3.9
## Bug fixes
diff --git a/R/abs2rel.R b/R/abs2rel.R
index 1792877f..92ccd818 100644
--- a/R/abs2rel.R
+++ b/R/abs2rel.R
@@ -18,9 +18,8 @@
#' @author Luigi Ranghetti, phD (2017) \email{luigi.ranghetti@@gmail.com}
#' @references L. Ranghetti, M. Boschetti, F. Nutini, L. Busetto (2020).
#' "sen2r": An R toolbox for automatically downloading and preprocessing
-#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473. DOI:
-#' \href{https://doi.org/10.1016/j.cageo.2020.104473}{10.1016/j.cageo.2020.104473},
-#' URL: \url{http://sen2r.ranghetti.info/}.
+#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473.
+#' \doi{10.1016/j.cageo.2020.104473}, URL: \url{http://sen2r.ranghetti.info/}.
#' @note License: GPL 3.0
#' @export
#'
diff --git a/R/add_rgb_image.R b/R/add_rgb_image.R
index 0f1dee1b..446cdccc 100644
--- a/R/add_rgb_image.R
+++ b/R/add_rgb_image.R
@@ -5,9 +5,8 @@
#' @author Luigi Ranghetti, phD (2019) \email{luigi@@ranghetti.info}
#' @references L. Ranghetti, M. Boschetti, F. Nutini, L. Busetto (2020).
#' "sen2r": An R toolbox for automatically downloading and preprocessing
-#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473. DOI:
-#' \href{https://doi.org/10.1016/j.cageo.2020.104473}{10.1016/j.cageo.2020.104473},
-#' URL: \url{http://sen2r.ranghetti.info/}.
+#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473.
+#' \doi{10.1016/j.cageo.2020.104473}, URL: \url{http://sen2r.ranghetti.info/}.
#' @note License: GPL 3.0
add_rgb_image <- function(s2_bands) {
diff --git a/R/add_tile_suffix.R b/R/add_tile_suffix.R
index 6c361003..20eb6dee 100644
--- a/R/add_tile_suffix.R
+++ b/R/add_tile_suffix.R
@@ -26,9 +26,8 @@
#' @author Luigi Ranghetti, phD (2020) \email{luigi@@ranghetti.info}
#' @references L. Ranghetti, M. Boschetti, F. Nutini, L. Busetto (2020).
#' "sen2r": An R toolbox for automatically downloading and preprocessing
-#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473. DOI:
-#' \href{https://doi.org/10.1016/j.cageo.2020.104473}{10.1016/j.cageo.2020.104473},
-#' URL: \url{http://sen2r.ranghetti.info/}.
+#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473.
+#' \doi{10.1016/j.cageo.2020.104473}, URL: \url{http://sen2r.ranghetti.info/}.
#' @note License: GPL 3.0
#' @examples
#' safe_names <- c(
diff --git a/R/build_example_param_file.R b/R/build_example_param_file.R
index c98b3591..c4da1880 100644
--- a/R/build_example_param_file.R
+++ b/R/build_example_param_file.R
@@ -11,9 +11,8 @@
#' @author Luigi Ranghetti, phD (2019) \email{luigi@@ranghetti.info}
#' @references L. Ranghetti, M. Boschetti, F. Nutini, L. Busetto (2020).
#' "sen2r": An R toolbox for automatically downloading and preprocessing
-#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473. DOI:
-#' \href{https://doi.org/10.1016/j.cageo.2020.104473}{10.1016/j.cageo.2020.104473},
-#' URL: \url{http://sen2r.ranghetti.info/}.
+#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473.
+#' \doi{10.1016/j.cageo.2020.104473}, URL: \url{http://sen2r.ranghetti.info/}.
#' @note License: GPL 3.0
#' @importFrom jsonlite toJSON
#' @export
diff --git a/R/calcindex.R b/R/calcindex.R
index 3080b544..5c7fc393 100644
--- a/R/calcindex.R
+++ b/R/calcindex.R
@@ -27,10 +27,9 @@
#'
#' @author Luigi Ranghetti, phD (2020) \email{luigi@@ranghetti.info}
#' @references L. Ranghetti, M. Boschetti, F. Nutini, L. Busetto (2020).
-#' "sen2r": An R toolbox for automatically downloading and preprocessing
-#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473. DOI:
-#' \href{https://doi.org/10.1016/j.cageo.2020.104473}{10.1016/j.cageo.2020.104473},
-#' URL: \url{http://sen2r.ranghetti.info/}.
+#' "sen2r": An R toolbox for automatically downloading and preprocessing
+#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473.
+#' \doi{10.1016/j.cageo.2020.104473}, URL: \url{http://sen2r.ranghetti.info/}.
#' @note License: GPL 3.0
calcindex_raster <- function(
diff --git a/R/check_gdal.R b/R/check_gdal.R
index 3d360cc5..56d387a6 100644
--- a/R/check_gdal.R
+++ b/R/check_gdal.R
@@ -24,9 +24,8 @@
#' @author Luigi Ranghetti, phD (2019) \email{luigi@@ranghetti.info}
#' @references L. Ranghetti, M. Boschetti, F. Nutini, L. Busetto (2020).
#' "sen2r": An R toolbox for automatically downloading and preprocessing
-#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473. DOI:
-#' \href{https://doi.org/10.1016/j.cageo.2020.104473}{10.1016/j.cageo.2020.104473},
-#' URL: \url{http://sen2r.ranghetti.info/}.
+#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473.
+#' \doi{10.1016/j.cageo.2020.104473}, URL: \url{http://sen2r.ranghetti.info/}.
#' @note License: GPL 3.0
#' @importFrom jsonlite toJSON
#' @export
diff --git a/R/check_gui_deps.R b/R/check_gui_deps.R
index e56f1a86..b1bdcda2 100644
--- a/R/check_gui_deps.R
+++ b/R/check_gui_deps.R
@@ -13,9 +13,8 @@
#' @author Luigi Ranghetti, phD (2020) \email{luigi@@ranghetti.info}
#' @references L. Ranghetti, M. Boschetti, F. Nutini, L. Busetto (2020).
#' "sen2r": An R toolbox for automatically downloading and preprocessing
-#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473. DOI:
-#' \href{https://doi.org/10.1016/j.cageo.2020.104473}{10.1016/j.cageo.2020.104473},
-#' URL: \url{http://sen2r.ranghetti.info/}.
+#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473.
+#' \doi{10.1016/j.cageo.2020.104473}, URL: \url{http://sen2r.ranghetti.info/}.
#' @note License: GPL 3.0
#' @export
#' @examples
diff --git a/R/check_param_list.R b/R/check_param_list.R
index d3c460d4..bbdc8aec 100644
--- a/R/check_param_list.R
+++ b/R/check_param_list.R
@@ -22,9 +22,8 @@
#' @author Luigi Ranghetti, phD (2019) \email{luigi@@ranghetti.info}
#' @references L. Ranghetti, M. Boschetti, F. Nutini, L. Busetto (2020).
#' "sen2r": An R toolbox for automatically downloading and preprocessing
-#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473. DOI:
-#' \href{https://doi.org/10.1016/j.cageo.2020.104473}{10.1016/j.cageo.2020.104473},
-#' URL: \url{http://sen2r.ranghetti.info/}.
+#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473.
+#' \doi{10.1016/j.cageo.2020.104473}, URL: \url{http://sen2r.ranghetti.info/}.
#' @note License: GPL 3.0
diff --git a/R/check_sen2r_deps.R b/R/check_sen2r_deps.R
index 9da3e014..941a5306 100644
--- a/R/check_sen2r_deps.R
+++ b/R/check_sen2r_deps.R
@@ -14,9 +14,8 @@
#' @author Luigi Ranghetti, phD (2019) \email{luigi@@ranghetti.info}
#' @references L. Ranghetti, M. Boschetti, F. Nutini, L. Busetto (2020).
#' "sen2r": An R toolbox for automatically downloading and preprocessing
-#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473. DOI:
-#' \href{https://doi.org/10.1016/j.cageo.2020.104473}{10.1016/j.cageo.2020.104473},
-#' URL: \url{http://sen2r.ranghetti.info/}.
+#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473.
+#' \doi{10.1016/j.cageo.2020.104473}, URL: \url{http://sen2r.ranghetti.info/}.
#' @note License: GPL 3.0
#' @importFrom utils capture.output
#' @importFrom httr RETRY write_disk progress
diff --git a/R/compute_s2_paths.R b/R/compute_s2_paths.R
index 1083bae9..cff6cd26 100644
--- a/R/compute_s2_paths.R
+++ b/R/compute_s2_paths.R
@@ -46,9 +46,8 @@
#' @author Luigi Ranghetti, phD (2019) \email{luigi@@ranghetti.info}
#' @references L. Ranghetti, M. Boschetti, F. Nutini, L. Busetto (2020).
#' "sen2r": An R toolbox for automatically downloading and preprocessing
-#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473. DOI:
-#' \href{https://doi.org/10.1016/j.cageo.2020.104473}{10.1016/j.cageo.2020.104473},
-#' URL: \url{http://sen2r.ranghetti.info/}.
+#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473.
+#' \doi{10.1016/j.cageo.2020.104473}, URL: \url{http://sen2r.ranghetti.info/}.
#' @note License: GPL 3.0
#' @import data.table
diff --git a/R/comsub.R b/R/comsub.R
index 4ec278a8..61c4be6b 100644
--- a/R/comsub.R
+++ b/R/comsub.R
@@ -11,9 +11,8 @@
#' @author Luigi Ranghetti, phD (2019) \email{luigi@@ranghetti.info}
#' @references L. Ranghetti, M. Boschetti, F. Nutini, L. Busetto (2020).
#' "sen2r": An R toolbox for automatically downloading and preprocessing
-#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473. DOI:
-#' \href{https://doi.org/10.1016/j.cageo.2020.104473}{10.1016/j.cageo.2020.104473},
-#' URL: \url{http://sen2r.ranghetti.info/}.
+#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473.
+#' \doi{10.1016/j.cageo.2020.104473}, URL: \url{http://sen2r.ranghetti.info/}.
#' @note Modified from a suggestion taken from
#' [stackoverflow](https://stackoverflow.com/questions/28273716/r-implementation-for-finding-the-longest-common-starting-substrings-in-a-set-of).
#' @export
diff --git a/R/create_indices_db.R b/R/create_indices_db.R
index fbbe8797..a3b941fc 100644
--- a/R/create_indices_db.R
+++ b/R/create_indices_db.R
@@ -20,9 +20,8 @@
#' @author Luigi Ranghetti, phD (2019) \email{luigi@@ranghetti.info}
#' @references L. Ranghetti, M. Boschetti, F. Nutini, L. Busetto (2020).
#' "sen2r": An R toolbox for automatically downloading and preprocessing
-#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473. DOI:
-#' \href{https://doi.org/10.1016/j.cageo.2020.104473}{10.1016/j.cageo.2020.104473},
-#' URL: \url{http://sen2r.ranghetti.info/}.
+#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473.
+#' \doi{10.1016/j.cageo.2020.104473}, URL: \url{http://sen2r.ranghetti.info/}.
#' @note License: GPL 3.0
#' @import data.table
#' @importFrom XML htmlTreeParse xmlRoot readHTMLTable xmlAttrs saveXML
@@ -195,11 +194,14 @@ create_indices_db <- function(xslt_path = NA,
}
- # last manual corrections on formulas
+ # last manual corrections on names
s2_table[,s2_formula:=gsub("par\\_([0-9])", "band_\\1", s2_table$s2_formula)] # some bands were wrongly classified as parameters
s2_table$name[s2_table$name=="TCI"] <- "TCIdx" # in order not to mess with TCI True Color Image product
s2_table$name[s2_table$name=="NDSI"] <- "NDSaI" # in order not to mess with Normalized Difference Snow Index
+ # last manual corrections on formulas
+ s2_table[name=="ARVI", s2_formula := gsub("band_8a", "band_8", s2_formula)] # revert manual change on IDB
+
# rename parameters (A, B, ...)
s2_table[,s2_formula:=gsub("par\\_([aALyY]r?)", "par_a", s2_table$s2_formula)] # first parameters (a, A, ar, y, Y, L) -> "a"
s2_table[,s2_formula:=gsub("par\\_([bB])", "par_b", s2_table$s2_formula)] # second parameters (b, B) -> "b"
diff --git a/R/create_s2_dop.R b/R/create_s2_dop.R
index 73b94be4..058aa55d 100644
--- a/R/create_s2_dop.R
+++ b/R/create_s2_dop.R
@@ -12,9 +12,8 @@
#' @author Luigi Ranghetti, phD (2019) \email{luigi@@ranghetti.info}
#' @references L. Ranghetti, M. Boschetti, F. Nutini, L. Busetto (2020).
#' "sen2r": An R toolbox for automatically downloading and preprocessing
-#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473. DOI:
-#' \href{https://doi.org/10.1016/j.cageo.2020.104473}{10.1016/j.cageo.2020.104473},
-#' URL: \url{http://sen2r.ranghetti.info/}.
+#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473.
+#' \doi{10.1016/j.cageo.2020.104473}, URL: \url{http://sen2r.ranghetti.info/}.
#' @note License: GPL 3.0
#' @import data.table
#' @importFrom jsonlite toJSON fromJSON
diff --git a/R/expand_path.R b/R/expand_path.R
index 9a013c71..52b77c97 100644
--- a/R/expand_path.R
+++ b/R/expand_path.R
@@ -20,9 +20,8 @@
#' @author Luigi Ranghetti, phD (2019) \email{luigi@@ranghetti.info}
#' @references L. Ranghetti, M. Boschetti, F. Nutini, L. Busetto (2020).
#' "sen2r": An R toolbox for automatically downloading and preprocessing
-#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473. DOI:
-#' \href{https://doi.org/10.1016/j.cageo.2020.104473}{10.1016/j.cageo.2020.104473},
-#' URL: \url{http://sen2r.ranghetti.info/}.
+#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473.
+#' \doi{10.1016/j.cageo.2020.104473}, URL: \url{http://sen2r.ranghetti.info/}.
#' @note License: GPL 3.0
@@ -81,9 +80,8 @@ expand_path <- function(path, parent=getwd(), silent=TRUE, normalize=TRUE) {
#' @author Luigi Ranghetti, phD (2019) \email{luigi@@ranghetti.info}
#' @references L. Ranghetti, M. Boschetti, F. Nutini, L. Busetto (2020).
#' "sen2r": An R toolbox for automatically downloading and preprocessing
-#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473. DOI:
-#' \href{https://doi.org/10.1016/j.cageo.2020.104473}{10.1016/j.cageo.2020.104473},
-#' URL: \url{http://sen2r.ranghetti.info/}.
+#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473.
+#' \doi{10.1016/j.cageo.2020.104473}, URL: \url{http://sen2r.ranghetti.info/}.
#' @note License: GPL 3.0
diff --git a/R/expect_equal_crs.R b/R/expect_equal_crs.R
index fc30c08e..b8b82e4b 100644
--- a/R/expect_equal_crs.R
+++ b/R/expect_equal_crs.R
@@ -8,9 +8,8 @@
#' @author Luigi Ranghetti, phD (2020) \email{luigi@@ranghetti.info}
#' @references L. Ranghetti, M. Boschetti, F. Nutini, L. Busetto (2020).
#' "sen2r": An R toolbox for automatically downloading and preprocessing
-#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473. DOI:
-#' \href{https://doi.org/10.1016/j.cageo.2020.104473}{10.1016/j.cageo.2020.104473},
-#' URL: \url{http://sen2r.ranghetti.info/}.
+#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473.
+#' \doi{10.1016/j.cageo.2020.104473}, URL: \url{http://sen2r.ranghetti.info/}.
#' @note License: GPL 3.0
expect_equal_crs <- function(crs1, crs2) {
diff --git a/R/fix_envi_format.R b/R/fix_envi_format.R
index 47981f4d..65268771 100644
--- a/R/fix_envi_format.R
+++ b/R/fix_envi_format.R
@@ -14,9 +14,8 @@
#' @author Luigi Ranghetti, phD (2019) \email{luigi@@ranghetti.info}
#' @references L. Ranghetti, M. Boschetti, F. Nutini, L. Busetto (2020).
#' "sen2r": An R toolbox for automatically downloading and preprocessing
-#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473. DOI:
-#' \href{https://doi.org/10.1016/j.cageo.2020.104473}{10.1016/j.cageo.2020.104473},
-#' URL: \url{http://sen2r.ranghetti.info/}.
+#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473.
+#' \doi{10.1016/j.cageo.2020.104473}, URL: \url{http://sen2r.ranghetti.info/}.
#' @note License: GPL 3.0
fix_envi_format <- function(infiles) {
diff --git a/R/gdalUtil.R b/R/gdalUtil.R
index 83249dd7..2ff4222e 100644
--- a/R/gdalUtil.R
+++ b/R/gdalUtil.R
@@ -26,9 +26,8 @@
#' @author Luigi Ranghetti, phD (2020) \email{luigi@@ranghetti.info}
#' @references L. Ranghetti, M. Boschetti, F. Nutini, L. Busetto (2020).
#' "sen2r": An R toolbox for automatically downloading and preprocessing
-#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473. DOI:
-#' \href{https://doi.org/10.1016/j.cageo.2020.104473}{10.1016/j.cageo.2020.104473},
-#' URL: \url{http://sen2r.ranghetti.info/}.
+#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473.
+#' \doi{10.1016/j.cageo.2020.104473}, URL: \url{http://sen2r.ranghetti.info/}.
#' @note License: GPL 3.0
#' @examples
#' # Define product names
@@ -50,8 +49,8 @@
#' options = c("-tr", "2", "2", "-r", "cubicspline", "-co", "COMPRESS=DEFLATE")
#' )
#' oldpar <- par(mfrow = c(1,2), mar = rep(0,4))
-#' image(stars::read_stars(examplename), rgb = c(11,8,4))
-#' image(stars::read_stars(outname1), rgb = c(11,8,4))
+#' image(stars::read_stars(examplename), rgb = c(11,8,4), useRaster = TRUE)
+#' image(stars::read_stars(outname1), rgb = c(11,8,4), useRaster = TRUE)
#'
#' ## gdalwarp
@@ -62,8 +61,8 @@
#' options = c("-t_srs", "EPSG:32633", "-co", "COMPRESS=DEFLATE")
#' )
#' oldpar <- par(mfrow = c(1,2), mar = rep(0,4))
-#' image(stars::read_stars(examplename), rgb = c(11,8,4))
-#' image(stars::read_stars(outname2), rgb = c(11,8,4))
+#' image(stars::read_stars(examplename), rgb = c(11,8,4), useRaster = TRUE)
+#' image(stars::read_stars(outname2), rgb = c(11,8,4), useRaster = TRUE)
#'
#' ## gdal_calc
#' outname3 <- tempfile(fileext = ".tif")
@@ -78,8 +77,8 @@
#' options = c("--A_band", "8", "--B_band", "4", "--type", "Int16")
#' )
#' oldpar <- par(mfrow = c(1,2), mar = rep(0,4))
-#' image(stars::read_stars(ndvirefname))
-#' image(stars::read_stars(outname3))
+#' image(stars::read_stars(ndvirefname), useRaster = TRUE)
+#' image(stars::read_stars(outname3), useRaster = TRUE)
#' }
diff --git a/R/gdal_abs2rel.R b/R/gdal_abs2rel.R
index 9743e9f4..3c7d5f9d 100644
--- a/R/gdal_abs2rel.R
+++ b/R/gdal_abs2rel.R
@@ -13,9 +13,8 @@
#' @author Luigi Ranghetti, phD (2019) \email{luigi@@ranghetti.info}
#' @references L. Ranghetti, M. Boschetti, F. Nutini, L. Busetto (2020).
#' "sen2r": An R toolbox for automatically downloading and preprocessing
-#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473. DOI:
-#' \href{https://doi.org/10.1016/j.cageo.2020.104473}{10.1016/j.cageo.2020.104473},
-#' URL: \url{http://sen2r.ranghetti.info/}.
+#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473.
+#' \doi{10.1016/j.cageo.2020.104473}, URL: \url{http://sen2r.ranghetti.info/}.
#' @note License: GPL 3.0
#' @export
#' @name gdal_abs2rel
diff --git a/R/gdal_warp.R b/R/gdal_warp.R
index 79344951..c0628874 100644
--- a/R/gdal_warp.R
+++ b/R/gdal_warp.R
@@ -58,9 +58,8 @@
#' @author Luigi Ranghetti, phD (2019) \email{luigi@@ranghetti.info}
#' @references L. Ranghetti, M. Boschetti, F. Nutini, L. Busetto (2020).
#' "sen2r": An R toolbox for automatically downloading and preprocessing
-#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473. DOI:
-#' \href{https://doi.org/10.1016/j.cageo.2020.104473}{10.1016/j.cageo.2020.104473},
-#' URL: \url{http://sen2r.ranghetti.info/}.
+#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473.
+#' \doi{10.1016/j.cageo.2020.104473}, URL: \url{http://sen2r.ranghetti.info/}.
#' @note License: GPL 3.0
#' @examples
#' \donttest{
@@ -87,12 +86,12 @@
#' # Show output
#' crop_bbox <- sf::st_as_sfc(sf::st_bbox(crop_line))
#' oldpar <- par(mfrow = c(1,3), mar = rep(0,4))
-#' image(stars::read_stars(ex_sel), rgb = 1:3)
+#' image(stars::read_stars(ex_sel), rgb = 1:3, useRaster = TRUE)
#' plot(crop_line, add = TRUE, col = "blue", lwd = 2)
#' plot(crop_bbox, add = TRUE, border = "red", lwd = 2)
-#' image(stars::read_stars(test1), rgb = 1:3)
+#' image(stars::read_stars(test1), rgb = 1:3, useRaster = TRUE)
#' plot(crop_bbox, add = TRUE, border = "red", lwd = 2)
-#' image(stars::read_stars(test2), rgb = 1:3)
+#' image(stars::read_stars(test2), rgb = 1:3, useRaster = TRUE)
#' plot(crop_line, add = TRUE, col = "blue", lwd = 2)
#'
#' # Warp on a reference raster
@@ -101,9 +100,9 @@
#'
#' # Show output
#' par(mfrow = c(1,3))
-#' par(mar = rep(0,4)); image(stars::read_stars(ex_sel), rgb = 1:3)
-#' par(mar = rep(2/3,4)); image(stars::read_stars(ex_ref))
-#' par(mar = rep(0,4)); image(stars::read_stars(test3), rgb = 1:3)
+#' par(mar = rep(0,4)); image(stars::read_stars(ex_sel), rgb = 1:3, useRaster = TRUE)
+#' par(mar = rep(2/3,4)); image(stars::read_stars(ex_ref), useRaster = TRUE)
+#' par(mar = rep(0,4)); image(stars::read_stars(test3), rgb = 1:3, useRaster = TRUE)
#'
#' # Reproject all the input file
#' test4 <- tempfile(fileext = "_test4.tif")
@@ -122,13 +121,13 @@
#' test1_bbox <- sf::st_as_sfc(sf::st_bbox(stars::read_stars(test1)))
#' test1_bbox_31N <- sf::st_transform(test1_bbox, 32631)
#' par(mfrow = c(1,4), mar = rep(0,4))
-#' image(stars::read_stars(ex_sel), rgb = 1:3)
+#' image(stars::read_stars(ex_sel), rgb = 1:3, useRaster = TRUE)
#' plot(crop_line, add = TRUE, col = "blue", lwd = 2)
#' plot(test1_bbox, add = TRUE, border = "red", lwd = 2)
-#' image(stars::read_stars(test4), rgb = 1:3)
-#' image(stars::read_stars(test5), rgb = 1:3)
+#' image(stars::read_stars(test4), rgb = 1:3, useRaster = TRUE)
+#' image(stars::read_stars(test5), rgb = 1:3, useRaster = TRUE)
#' plot(test1_bbox_31N, add = TRUE, border = "red", lwd = 2)
-#' image(stars::read_stars(test6), rgb = 1:3)
+#' image(stars::read_stars(test6), rgb = 1:3, useRaster = TRUE)
#' plot(crop_line_31N, add = TRUE, col = "blue", lwd = 2)
#'
#' # Use a reference raster with a different projection
@@ -146,13 +145,13 @@
#'
#' # Show output
#' par(mfrow = c(1,4), mar = rep(0,4))
-#' image(stars::read_stars(ex_sel), rgb = 1:3)
+#' image(stars::read_stars(ex_sel), rgb = 1:3, useRaster = TRUE)
#' plot(crop_line, add = TRUE, col = "blue", lwd = 2)
-#' image(stars::read_stars(test7), rgb = 1:3)
+#' image(stars::read_stars(test7), rgb = 1:3, useRaster = TRUE)
#' plot(crop_line_31N, add = TRUE, col = "blue", lwd = 2)
-#' image(stars::read_stars(test8), rgb = 1:3)
+#' image(stars::read_stars(test8), rgb = 1:3, useRaster = TRUE)
#' plot(test1_bbox_31N, add = TRUE, border = "red", lwd = 2)
-#' image(stars::read_stars(test9), rgb = 1:3)
+#' image(stars::read_stars(test9), rgb = 1:3, useRaster = TRUE)
#' plot(crop_line_31N, add = TRUE, col = "blue", lwd = 2)
#'
#' par(oldpar)
@@ -232,24 +231,6 @@ gdal_warp <- function(srcfiles,
}
}
- # if "ref" is specified, read ref parameters
- if (!is.null(ref)) {
- ref_metadata <- raster_metadata(ref, format = "list")[[1]]
- ref_res <- ref_metadata$res
- ref_size <- ref_metadata$size
- t_srs <- ref_metadata$proj
- ref_bbox <- ref_metadata$bbox
- ref_ll <- ref_bbox[c("xmin","ymin")]
- sel_of <- ifelse(is.null(of), ref_metadata$outformat, of)
-
- # round "tr" to ref grid
- if (is.null(tr)) {
- tr <- ref_res
- } else {
- tr <- ref_size*ref_res/round((ref_size*ref_res)/tr)
- }
- }
-
# define tmpdir
if (is.na(tmpdir)) {
tmpdir <- tempfile(pattern="gdalwarp_")
@@ -257,8 +238,13 @@ gdal_warp <- function(srcfiles,
tmpdir <- file.path(tmpdir, basename(tempfile(pattern="gdalwarp_")))
}
- # if "mask" is specified, take "mask" and "te" from it
- if (!is.null(mask)) {
+ # actions to perform if "mask" is specified
+ if (
+ !is.null(mask) &&
+ (!inherits(mask, "logical") || inherits(mask, "logical") && !anyNA(mask))
+ ) {
+
+ # cast "mask" to sf
mask <- st_zm(
if (is(mask, "sf") | is(mask, "sfc")) {
st_sf(mask)
@@ -304,9 +290,9 @@ gdal_warp <- function(srcfiles,
}
}
- # cast to multipolygon
+ # save as cropping cutline file (if cutline must be applied)
+ dir.create(tmpdir, recursive=FALSE, showWarnings=FALSE)
if (length(grep("POLYGON",st_geometry_type(mask)))>=1) {
- dir.create(tmpdir, recursive=FALSE, showWarnings=FALSE)
st_write(
st_cast(mask, "MULTIPOLYGON"),
mask_file <- file.path(
@@ -314,19 +300,43 @@ gdal_warp <- function(srcfiles,
),
quiet = TRUE
)
- } # if not, mask_polygon is not created
+ }
- # create mask_bbox if t_srs is specified;
- # otherwise, create each time within srcfile cycle
- if (!is.null(t_srs)) {
- mask_bbox <- matrix(
- st_bbox(st_transform(mask, t_srs)),
- nrow=2, ncol=2,
- dimnames=list(c("x","y"),c("min","max"))
- )
+ }
+
+ # if "ref" is specified, read ref parameters
+ if (length(ref) > 0) {
+
+ ref_metadata <- raster_metadata(ref, format = "list")[[1]]
+ ref_res <- ref_metadata$res
+ ref_size <- ref_metadata$size
+ t_srs <- ref_metadata$proj
+ ref_bbox <- ref_metadata$bbox
+ ref_offset <- ref_bbox %% ref_res
+ sel_of <- ifelse(is.null(of), ref_metadata$outformat, of)
+
+ # round "tr" to ref grid
+ if (is.null(tr)) {
+ tr <- ref_res
+ } else {
+ tr <- ref_size*ref_res/round((ref_size*ref_res)/tr)
+ }
+
+ # compute "te"
+ te <- if (is.null(mask)) {
+ ref_bbox
+ } else if (
+ !inherits(mask, "logical") || inherits(mask, "logical") && !anyNA(mask)
+ ) {
+ te_1 <- st_bbox(st_transform(mask, t_srs))
+ te_1 + c(0,0,ref_res) - (te_1-ref_offset) %% ref_res
+ } else {
+ NULL # define "sel_te" in the srcfile cycle
}
+
}
+
# cycle on each srcfile
for (i in seq_along(srcfiles)) {
srcfile <- srcfiles[i]
@@ -356,85 +366,16 @@ gdal_warp <- function(srcfiles,
r
}
- # get reprojected extent
- # (if already set it was referring to mask; in this case, to srcfile)
- sel_src_bbox <- suppressMessages(
- matrix(
- st_bbox(st_transform(st_as_sfc(sel_bbox), sel_t_srs)),
- nrow=2, ncol=2,
- dimnames=list(c("x","y"),c("min","max"))
- )
- )
-
- # dimnames(sel_src_bbox) <- list(c("x","y"), c("min","max"))
-
- # set the correct bounding box for srcfile
- if (is.null(ref)) {
- if (is.null(mask)) {
- # ref NULL & mask NULL: use bbox of srcfile, reprojected
- sel_te <- sel_src_bbox
- } else if (inherits(mask, "logical") && is.na(mask)) { # check if mask==NA
- # ref NULL & mask NA: the same (use bbox of srcfile, reprojected)
- sel_te <- sel_src_bbox
- } else {
- # ref NULL & mask provided: use bbox of mask, reprojected and aligned to src grid
- sel_mask_bbox <- if (exists("mask_bbox")) {
- mask_bbox
- } else {
- matrix(
- st_bbox(st_transform(mask, sel_t_srs)),
- nrow=2, ncol=2,
- dimnames = list(c("x","y"), c("min","max"))
- )
- }
- if (sel_t_srs == sel_s_srs) {
- sel_te <- (sel_mask_bbox - sel_ll) / sel_tr
- sel_te <- cbind(floor(sel_te[,1]), ceiling(sel_te[,2]))
- dimnames(sel_te) <- list(c("x","y"), c("min","max"))
- sel_te <- sel_te * sel_tr + sel_ll
- } else {
- sel_te <- sel_mask_bbox
- }
- }
- } else {
- if (is.null(mask)) {
- # ref provided & mask NULL: use bbox of ref
- sel_te <- ref_bbox
- } else if (inherits(mask, "logical") && is.na(mask)) {
- # ref provided & mask NA: use bbox of srcfile (reprojected and aligned to ref grid)
- if (sel_t_srs == sel_s_srs) {
- sel_te <- (sel_src_bbox - ref_ll) / sel_tr
- sel_te <- cbind(floor(sel_te[,1]), ceiling(sel_te[,2]))
- dimnames(sel_te) <- list(c("x","y"),c("min","max"))
- sel_te <- sel_te * sel_tr + ref_ll
- } else {
- sel_te <- sel_mask_bbox
- }
+ if (length(ref) > 0) {
+ sel_te <- if (!is.null(te)) {
+ te
} else {
- # ref provided & mask provided: use bbox of mask (reprojected and aligned to ref grid)
- sel_mask_bbox <- if (exists("mask_bbox")) {
- mask_bbox
- } else {
- matrix(
- st_bbox(st_transform(mask, sel_t_srs)),
- nrow=2, ncol=2,
- dimnames = list(c("x","y"), c("min","max"))
- )
- }
- if (sel_t_srs == sel_s_srs) {
- sel_te <- (sel_mask_bbox - ref_ll) / sel_tr
- sel_te <- cbind(floor(sel_te[,1]), ceiling(sel_te[,2]))
- dimnames(sel_te) <- list(c("x","y"),c("min","max"))
- sel_te <- sel_te * sel_tr + ref_ll
- } else {
- sel_te <- sel_mask_bbox
- }
+ sel_te_1 <- st_bbox(st_transform(st_as_sfc(sel_bbox), sel_t_srs))
+ sel_te_1 + c(0,0,ref_res) - (sel_te_1-ref_offset) %% ref_res
}
}
- # finally, apply gdal_warp or gdal_translate
- # temporary leave only gdal_warp to avoid some problems
- # (e.g., translating a 1001x1001 20m to 10m results in 2002x2002 instead of 200[12]x200[12])
+ # define CRS strings
sel_s_srs_string <- if (!is.na(sel_s_srs$epsg)) {
paste0("EPSG:",sel_s_srs$epsg)
} else {
@@ -456,18 +397,41 @@ gdal_warp <- function(srcfiles,
sel_t_srs_path
}
+ # Is cropping needed?
+ # if "ref" is defined, crop in the first step
+ # (this is possible because the output grid is known)
+ crop_in_step1 <- length(ref) > 0
+ # if "res" not defined and "mask" is provided, crop in a separate step
+ # (this is required because the grid applied by gdalwarp is unknown)
+ crop_in_step2 <- !is.null(mask) &&
+ (!inherits(mask, "logical") || inherits(mask, "logical") && !anyNA(mask)) &&
+ length(ref) == 0
+
+ # first gdal_warp application (all except cropping)
+ if (crop_in_step2) {
+ step1_dstfile <- file.path(
+ tmpdir,
+ basename(tempfile(pattern = "warp_", fileext = ".vrt"))
+ )
+ step1_of <- "VRT"
+ step1_co <- NULL
+ } else {
+ step1_dstfile <- dstfile
+ step1_of <- sel_of
+ step1_co <- co
+ }
gdalUtil(
"warp",
source = srcfile,
- destination = dstfile,
+ destination = step1_dstfile,
options = c(
"-s_srs", sel_s_srs_string,
"-t_srs", sel_t_srs_string,
- "-te", c(sel_te),
+ if (crop_in_step1) {c("-te", c(sel_te))},
if (exists("mask_file")) {c("-cutline", mask_file)},
if (!is.null(tr)) {c("-tr", as.vector(sel_tr))},
- if (!is.null(of)) {c("-of",as.vector(sel_of))},
- if (!is.null(co)) {unlist(lapply(co, function(x){c("-co", x)}))},
+ if (!is.null(step1_of)) {c("-of",as.vector(step1_of))},
+ if (!is.null(step1_co)) {unlist(lapply(step1_co, function(x){c("-co", x)}))},
"-r", sel_r,
if (!is.null(sel_nodata)) {
if (is.na(sel_nodata)) {
@@ -481,6 +445,40 @@ gdal_warp <- function(srcfiles,
quiet = TRUE
)
+ if (crop_in_step2) {
+
+ # retrieve gdalwarp_path1 grid info
+ step1_metadata <- raster_metadata(step1_dstfile, format = "list")[[1]]
+ step1_res <- step1_metadata$res
+ step1_offset <- step1_metadata$bbox %% step1_res
+
+ # get reprojected extent
+ sel_te_1 <- st_bbox(st_transform(mask, sel_t_srs))
+ sel_te <- sel_te_1 + c(0,0,step1_res) - (sel_te_1-step1_offset) %% step1_res
+
+ # final gdal_warp application (crop matching the out grid)
+ gdalUtil(
+ "warp",
+ source = step1_dstfile,
+ destination = dstfile,
+ options = c(
+ "-te", c(sel_te),
+ if (!is.null(of)) {c("-of",as.vector(sel_of))},
+ if (!is.null(co)) {unlist(lapply(co, function(x){c("-co", x)}))},
+ if (!is.null(sel_nodata)) {
+ if (is.na(sel_nodata)) {
+ c("-dstnodata", "None")
+ } else {
+ c("-dstnodata", sel_nodata)
+ }
+ },
+ if (overwrite) {"-overwrite"}
+ ),
+ quiet = TRUE
+ )
+
+ }
+
} # end of overwrite IF cycle
}
diff --git a/R/gdalwarp_grid.R b/R/gdalwarp_grid.R
index 4aae86df..00c967e2 100644
--- a/R/gdalwarp_grid.R
+++ b/R/gdalwarp_grid.R
@@ -19,9 +19,8 @@
#' @author Luigi Ranghetti, phD (2019) \email{luigi@@ranghetti.info}
#' @references L. Ranghetti, M. Boschetti, F. Nutini, L. Busetto (2020).
#' "sen2r": An R toolbox for automatically downloading and preprocessing
-#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473. DOI:
-#' \href{https://doi.org/10.1016/j.cageo.2020.104473}{10.1016/j.cageo.2020.104473},
-#' URL: \url{http://sen2r.ranghetti.info/}.
+#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473.
+#' \doi{10.1016/j.cageo.2020.104473}, URL: \url{http://sen2r.ranghetti.info/}.
#' @note License: GPL 3.0
#' @examples
#' \donttest{
@@ -41,9 +40,11 @@
#'
#' # Show output
#' oldpar <- par(mfrow = c(1,3), mar = rep(0,4))
-#' image(stars::read_stars(ex_sel), rgb = 4:2, maxColorValue = 3500)
-#' par(mar = rep(2/3,4)); image(stars::read_stars(ex_ref))
-#' par(mar = rep(0,4)); image(stars::read_stars(ex_out), rgb = 4:2, maxColorValue = 3500)
+#' image(stars::read_stars(ex_sel), rgb = 4:2, maxColorValue = 3500, useRaster = TRUE)
+#' par(mar = rep(2/3,4))
+#' image(stars::read_stars(ex_ref), useRaster = TRUE)
+#' par(mar = rep(0,4))
+#' image(stars::read_stars(ex_out), rgb = 4:2, maxColorValue = 3500, useRaster = TRUE)
#' par(oldpar)
#' }
diff --git a/R/gipp.R b/R/gipp.R
index b76ff0f3..e288a05e 100644
--- a/R/gipp.R
+++ b/R/gipp.R
@@ -14,9 +14,8 @@
#' @author Luigi Ranghetti, phD (2020) \email{luigi@@ranghetti.info}
#' @references L. Ranghetti, M. Boschetti, F. Nutini, L. Busetto (2020).
#' "sen2r": An R toolbox for automatically downloading and preprocessing
-#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473. DOI:
-#' \href{https://doi.org/10.1016/j.cageo.2020.104473}{10.1016/j.cageo.2020.104473},
-#' URL: \url{http://sen2r.ranghetti.info/}.
+#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473.
+#' \doi{10.1016/j.cageo.2020.104473}, URL: \url{http://sen2r.ranghetti.info/}.
#' @note License: GPL 3.0
#' @examples
#' \dontrun{
@@ -94,7 +93,7 @@ gipp_init <- function(gipp_sen2r_path = NA, force = FALSE, dem_warning = FALSE)
"To use ESA-CCI data-package, download it at ",
"http://maps.elie.ucl.ac.be/CCI/viewer/download.php and install it ",
"(further information can be found at ",
- "http://step.esa.int/main/third-party-plugins-2/sen2cor/)."
+ "http://step.esa.int/main/snap-supported-plugins/sen2cor/)."
)
}
@@ -132,9 +131,8 @@ gipp_init <- function(gipp_sen2r_path = NA, force = FALSE, dem_warning = FALSE)
#' @author Luigi Ranghetti, phD (2020) \email{luigi@@ranghetti.info}
#' @references L. Ranghetti, M. Boschetti, F. Nutini, L. Busetto (2020).
#' "sen2r": An R toolbox for automatically downloading and preprocessing
-#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473. DOI:
-#' \href{https://doi.org/10.1016/j.cageo.2020.104473}{10.1016/j.cageo.2020.104473},
-#' URL: \url{http://sen2r.ranghetti.info/}.
+#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473.
+#' \doi{10.1016/j.cageo.2020.104473}, URL: \url{http://sen2r.ranghetti.info/}.
#' @note License: GPL 3.0
#' @export
read_gipp <- function(gipp_names, gipp_path = NA) {
diff --git a/R/give_write_permission.R b/R/give_write_permission.R
index 86f94f40..790ae660 100644
--- a/R/give_write_permission.R
+++ b/R/give_write_permission.R
@@ -10,13 +10,12 @@
#' denied).
#' @return Logical: if TRUE, R was authorised saving in the directory;
#' if FALSE, it was not and a temporary directory is being used.
-#' @author Lorenzo Busetto, phD (2019) \email{lbusett@@gmail.com}
+#' @author Lorenzo Busetto, phD (2019)
#' @author Luigi Ranghetti, phD (2019) \email{luigi@@ranghetti.info}
#' @references L. Ranghetti, M. Boschetti, F. Nutini, L. Busetto (2020).
#' "sen2r": An R toolbox for automatically downloading and preprocessing
-#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473. DOI:
-#' \href{https://doi.org/10.1016/j.cageo.2020.104473}{10.1016/j.cageo.2020.104473},
-#' URL: \url{http://sen2r.ranghetti.info/}.
+#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473.
+#' \doi{10.1016/j.cageo.2020.104473}, URL: \url{http://sen2r.ranghetti.info/}.
#' @note License: GPL 3.0
give_write_permission <- function(agree = NA) {
diff --git a/R/helpers_extent.R b/R/helpers_extent.R
index 0fb83f4c..bd2fdb8c 100644
--- a/R/helpers_extent.R
+++ b/R/helpers_extent.R
@@ -4,9 +4,8 @@
#' @author Luigi Ranghetti, phD (2019) \email{luigi@@ranghetti.info}
#' @references L. Ranghetti, M. Boschetti, F. Nutini, L. Busetto (2020).
#' "sen2r": An R toolbox for automatically downloading and preprocessing
-#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473. DOI:
-#' \href{https://doi.org/10.1016/j.cageo.2020.104473}{10.1016/j.cageo.2020.104473},
-#' URL: \url{http://sen2r.ranghetti.info/}.
+#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473.
+#' \doi{10.1016/j.cageo.2020.104473}, URL: \url{http://sen2r.ranghetti.info/}.
#' @note License: GPL 3.0
#' @name load_extent_bbox
diff --git a/R/ignorelist.R b/R/ignorelist.R
index 03679105..d957327d 100644
--- a/R/ignorelist.R
+++ b/R/ignorelist.R
@@ -16,9 +16,8 @@
#' @author Luigi Ranghetti, phD (2020) \email{luigi@@ranghetti.info}
#' @references L. Ranghetti, M. Boschetti, F. Nutini, L. Busetto (2020).
#' "sen2r": An R toolbox for automatically downloading and preprocessing
-#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473. DOI:
-#' \href{https://doi.org/10.1016/j.cageo.2020.104473}{10.1016/j.cageo.2020.104473},
-#' URL: \url{http://sen2r.ranghetti.info/}.
+#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473.
+#' \doi{10.1016/j.cageo.2020.104473}, URL: \url{http://sen2r.ranghetti.info/}.
#' @note License: GPL 3.0
#' @name write_ignorelist
diff --git a/R/init_python.R b/R/init_python.R
index af565af0..b4bb8bca 100644
--- a/R/init_python.R
+++ b/R/init_python.R
@@ -5,9 +5,8 @@
#' @author Luigi Ranghetti, phD (2020) \email{luigi@@ranghetti.info}
#' @references L. Ranghetti, M. Boschetti, F. Nutini, L. Busetto (2020).
#' "sen2r": An R toolbox for automatically downloading and preprocessing
-#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473. DOI:
-#' \href{https://doi.org/10.1016/j.cageo.2020.104473}{10.1016/j.cageo.2020.104473},
-#' URL: \url{http://sen2r.ranghetti.info/}.
+#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473.
+#' \doi{10.1016/j.cageo.2020.104473}, URL: \url{http://sen2r.ranghetti.info/}.
#' @note License: GPL 3.0
init_python <- function() {
diff --git a/R/install_aria2.R b/R/install_aria2.R
index 89fd92db..2e1eeb46 100644
--- a/R/install_aria2.R
+++ b/R/install_aria2.R
@@ -9,9 +9,8 @@
#' @author Luigi Ranghetti, phD (2019) \email{luigi@@ranghetti.info}
#' @references L. Ranghetti, M. Boschetti, F. Nutini, L. Busetto (2020).
#' "sen2r": An R toolbox for automatically downloading and preprocessing
-#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473. DOI:
-#' \href{https://doi.org/10.1016/j.cageo.2020.104473}{10.1016/j.cageo.2020.104473},
-#' URL: \url{http://sen2r.ranghetti.info/}.
+#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473.
+#' \doi{10.1016/j.cageo.2020.104473}, URL: \url{http://sen2r.ranghetti.info/}.
#' @note License: GPL 3.0
#' @importFrom httr RETRY write_disk progress
#' @export
diff --git a/R/install_sen2cor.R b/R/install_sen2cor.R
index 4e4ee1a4..47472751 100644
--- a/R/install_sen2cor.R
+++ b/R/install_sen2cor.R
@@ -1,6 +1,6 @@
#' @title Download and install (or link) Sen2Cor
#' @description [install_sen2cor()] downloads and installs a standalone version of
-#' [Sen2Cor](http://step.esa.int/main/third-party-plugins-2/sen2cor/).
+#' [Sen2Cor](http://step.esa.int/main/snap-supported-plugins/sen2cor/).
#' @param sen2cor_dir Path where sen2cor will be installed or searched
#' (by default it is a subdirectory `"sen2cor"` of the default sen2r directory).
#' @param version (optional) Character: Sen2Cor version (one among
@@ -12,9 +12,8 @@
#' @author Luigi Ranghetti, phD (2019) \email{luigi@@ranghetti.info}
#' @references L. Ranghetti, M. Boschetti, F. Nutini, L. Busetto (2020).
#' "sen2r": An R toolbox for automatically downloading and preprocessing
-#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473. DOI:
-#' \href{https://doi.org/10.1016/j.cageo.2020.104473}{10.1016/j.cageo.2020.104473},
-#' URL: \url{http://sen2r.ranghetti.info/}.
+#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473.
+#' \doi{10.1016/j.cageo.2020.104473}, URL: \url{http://sen2r.ranghetti.info/}.
#' @note License: GPL 3.0
#' @importFrom jsonlite toJSON fromJSON
#' @importFrom utils download.file unzip
@@ -220,7 +219,7 @@ install_sen2cor <- function(
#' @name link_sen2cor
#' @rdname install_sen2cor
#' @description `link_sen2cor()` links an existing standalone version of
-#' [Sen2Cor](http://step.esa.int/main/third-party-plugins-2/sen2cor/) to sen2r.
+#' [Sen2Cor](http://step.esa.int/main/snap-supported-plugins/sen2cor/) to sen2r.
#' @export
link_sen2cor <- function(sen2cor_dir) {
diff --git a/R/list_indices.R b/R/list_indices.R
index 066f075f..0d9dbb8f 100644
--- a/R/list_indices.R
+++ b/R/list_indices.R
@@ -26,9 +26,8 @@
#' @author Luigi Ranghetti, phD (2019) \email{luigi@@ranghetti.info}
#' @references L. Ranghetti, M. Boschetti, F. Nutini, L. Busetto (2020).
#' "sen2r": An R toolbox for automatically downloading and preprocessing
-#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473. DOI:
-#' \href{https://doi.org/10.1016/j.cageo.2020.104473}{10.1016/j.cageo.2020.104473},
-#' URL: \url{http://sen2r.ranghetti.info/}.
+#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473.
+#' \doi{10.1016/j.cageo.2020.104473}, URL: \url{http://sen2r.ranghetti.info/}.
#' @note License: GPL 3.0
#' @examples
#' # Show index names
diff --git a/R/load_binpaths.R b/R/load_binpaths.R
index 25fbb5cf..fc97b5ed 100644
--- a/R/load_binpaths.R
+++ b/R/load_binpaths.R
@@ -10,9 +10,8 @@
#' @author Luigi Ranghetti, phD (2019) \email{luigi@@ranghetti.info}
#' @references L. Ranghetti, M. Boschetti, F. Nutini, L. Busetto (2020).
#' "sen2r": An R toolbox for automatically downloading and preprocessing
-#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473. DOI:
-#' \href{https://doi.org/10.1016/j.cageo.2020.104473}{10.1016/j.cageo.2020.104473},
-#' URL: \url{http://sen2r.ranghetti.info/}.
+#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473.
+#' \doi{10.1016/j.cageo.2020.104473}, URL: \url{http://sen2r.ranghetti.info/}.
#' @note License: GPL 3.0
#' @importFrom jsonlite fromJSON
#' @export
@@ -34,7 +33,7 @@ load_binpaths <- function(bins = NULL) {
# Define where the JSON with the paths is
binpaths_file <- file.path(
- if (dir.exists(normalize_path("~/.sen2r"))) {
+ if (dir.exists(normalize_path("~/.sen2r", mustWork = FALSE))) {
normalize_path("~/.sen2r")
} else {
tempdir()
diff --git a/R/mountpoint.R b/R/mountpoint.R
index a29fe998..191f6592 100644
--- a/R/mountpoint.R
+++ b/R/mountpoint.R
@@ -14,9 +14,8 @@
#' @author Luigi Ranghetti, phD (2019) \email{luigi@@ranghetti.info}
#' @references L. Ranghetti, M. Boschetti, F. Nutini, L. Busetto (2020).
#' "sen2r": An R toolbox for automatically downloading and preprocessing
-#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473. DOI:
-#' \href{https://doi.org/10.1016/j.cageo.2020.104473}{10.1016/j.cageo.2020.104473},
-#' URL: \url{http://sen2r.ranghetti.info/}.
+#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473.
+#' \doi{10.1016/j.cageo.2020.104473}, URL: \url{http://sen2r.ranghetti.info/}.
#' @note License: GPL 3.0
#' @export
diff --git a/R/nn.R b/R/nn.R
index 82a2e3c9..a85563c6 100644
--- a/R/nn.R
+++ b/R/nn.R
@@ -6,9 +6,8 @@
#' @author Luigi Ranghetti, phD (2019) \email{luigi@@ranghetti.info}
#' @references L. Ranghetti, M. Boschetti, F. Nutini, L. Busetto (2020).
#' "sen2r": An R toolbox for automatically downloading and preprocessing
-#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473. DOI:
-#' \href{https://doi.org/10.1016/j.cageo.2020.104473}{10.1016/j.cageo.2020.104473},
-#' URL: \url{http://sen2r.ranghetti.info/}.
+#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473.
+#' \doi{10.1016/j.cageo.2020.104473}, URL: \url{http://sen2r.ranghetti.info/}.
#' @note License: GPL 3.0
#'
#' @examples
diff --git a/R/path_check.R b/R/path_check.R
index 2d4e3346..de354243 100644
--- a/R/path_check.R
+++ b/R/path_check.R
@@ -7,7 +7,7 @@
#' permissions
#' @rdname path_check
#' @author Luigi Ranghetti, phD (2019) \email{luigi@@ranghetti.info}
-#' @author Lorenzo Busetto, PhD (2019) \email{lbusett@@gmail.com}
+#' @author Lorenzo Busetto, PhD (2019)
path_check <- function(path, mustbe_empty = FALSE, mustbe_writable = TRUE) {
if (all(length(path)>0, path[1]!="")) {
diff --git a/R/print_message.R b/R/print_message.R
index 1397407f..41cae86c 100644
--- a/R/print_message.R
+++ b/R/print_message.R
@@ -39,9 +39,8 @@
#' @author Luigi Ranghetti, phD (2020) \email{luigi@@ranghetti.info}
#' @references L. Ranghetti, M. Boschetti, F. Nutini, L. Busetto (2020).
#' "sen2r": An R toolbox for automatically downloading and preprocessing
-#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473. DOI:
-#' \href{https://doi.org/10.1016/j.cageo.2020.104473}{10.1016/j.cageo.2020.104473},
-#' URL: \url{http://sen2r.ranghetti.info/}.
+#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473.
+#' \doi{10.1016/j.cageo.2020.104473}, URL: \url{http://sen2r.ranghetti.info/}.
#' @note License: GPL 3.0
print_message <- function(
diff --git a/R/projpar.R b/R/projpar.R
index 9e59e1f2..191ae2a7 100644
--- a/R/projpar.R
+++ b/R/projpar.R
@@ -17,9 +17,8 @@
#' @author Luigi Ranghetti, phD (2020) \email{luigi@@ranghetti.info}
#' @references L. Ranghetti, M. Boschetti, F. Nutini, L. Busetto (2020).
#' "sen2r": An R toolbox for automatically downloading and preprocessing
-#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473. DOI:
-#' \href{https://doi.org/10.1016/j.cageo.2020.104473}{10.1016/j.cageo.2020.104473},
-#' URL: \url{http://sen2r.ranghetti.info/}.
+#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473.
+#' \doi{10.1016/j.cageo.2020.104473}, URL: \url{http://sen2r.ranghetti.info/}.
#' @note License: GPL 3.0
#' @export
#' @importFrom sf st_as_text st_crs
diff --git a/R/raster_metadata.R b/R/raster_metadata.R
index 1065c198..22267834 100644
--- a/R/raster_metadata.R
+++ b/R/raster_metadata.R
@@ -11,9 +11,8 @@
#' @author Luigi Ranghetti, phD (2019) \email{luigi@@ranghetti.info}
#' @references L. Ranghetti, M. Boschetti, F. Nutini, L. Busetto (2020).
#' "sen2r": An R toolbox for automatically downloading and preprocessing
-#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473. DOI:
-#' \href{https://doi.org/10.1016/j.cageo.2020.104473}{10.1016/j.cageo.2020.104473},
-#' URL: \url{http://sen2r.ranghetti.info/}.
+#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473.
+#' \doi{10.1016/j.cageo.2020.104473}, URL: \url{http://sen2r.ranghetti.info/}.
#' @note License: GPL 3.0
#' @export
#' @import data.table
diff --git a/R/s2_calcindices.R b/R/s2_calcindices.R
index 80383c61..e97f6951 100644
--- a/R/s2_calcindices.R
+++ b/R/s2_calcindices.R
@@ -90,9 +90,8 @@
#' @author Luigi Ranghetti, phD (2020) \email{luigi@@ranghetti.info}
#' @references L. Ranghetti, M. Boschetti, F. Nutini, L. Busetto (2020).
#' "sen2r": An R toolbox for automatically downloading and preprocessing
-#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473. DOI:
-#' \href{https://doi.org/10.1016/j.cageo.2020.104473}{10.1016/j.cageo.2020.104473},
-#' URL: \url{http://sen2r.ranghetti.info/}.
+#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473.
+#' \doi{10.1016/j.cageo.2020.104473}, URL: \url{http://sen2r.ranghetti.info/}.
#' @note License: GPL 3.0
#' @examples
#' # Define file names
@@ -112,8 +111,9 @@
#'
#' # Show output
#' oldpar <- par(mfrow = c(1,2), mar = rep(0,4))
-#' image(stars::read_stars(ex_in), rgb = 4:2, maxColorValue = 3500)
-#' par(mar = rep(2/3,4)); image(stars::read_stars(ex_out))
+#' image(stars::read_stars(ex_in), rgb = 4:2, maxColorValue = 3500, useRaster = TRUE)
+#' par(mar = rep(2/3,4))
+#' image(stars::read_stars(ex_out), useRaster = TRUE)
#' par(oldpar)
s2_calcindices <- function(
diff --git a/R/s2_dop.R b/R/s2_dop.R
index 752cca65..18c5a66d 100644
--- a/R/s2_dop.R
+++ b/R/s2_dop.R
@@ -29,9 +29,8 @@
#' @author Luigi Ranghetti, phD (2019) \email{luigi@@ranghetti.info}
#' @references L. Ranghetti, M. Boschetti, F. Nutini, L. Busetto (2020).
#' "sen2r": An R toolbox for automatically downloading and preprocessing
-#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473. DOI:
-#' \href{https://doi.org/10.1016/j.cageo.2020.104473}{10.1016/j.cageo.2020.104473},
-#' URL: \url{http://sen2r.ranghetti.info/}.
+#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473.
+#' \doi{10.1016/j.cageo.2020.104473}, URL: \url{http://sen2r.ranghetti.info/}.
#' @note License: GPL 3.0
#' @import data.table
#' @importFrom jsonlite fromJSON
diff --git a/R/s2_download.R b/R/s2_download.R
index 76213893..4cb7a2f2 100644
--- a/R/s2_download.R
+++ b/R/s2_download.R
@@ -28,12 +28,11 @@
#' (being downloaded or already existing).
#'
#' @author Luigi Ranghetti, phD (2020) \email{luigi@@ranghetti.info}
-#' @author Lorenzo Busetto, phD (2019) \email{lbusett@@gmail.com}
+#' @author Lorenzo Busetto, phD (2019)
#' @references L. Ranghetti, M. Boschetti, F. Nutini, L. Busetto (2020).
#' "sen2r": An R toolbox for automatically downloading and preprocessing
-#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473. DOI:
-#' \href{https://doi.org/10.1016/j.cageo.2020.104473}{10.1016/j.cageo.2020.104473},
-#' URL: \url{http://sen2r.ranghetti.info/}.
+#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473.
+#' \doi{10.1016/j.cageo.2020.104473}, URL: \url{http://sen2r.ranghetti.info/}.
#' @note License: GPL 3.0
#' @importFrom httr RETRY authenticate progress write_disk
#' @importFrom foreach foreach "%do%"
@@ -280,15 +279,15 @@ s2_download <- function(
# )]
# safe_existing <- list.files(dirname(zip_path), safe_regex, full.names = TRUE)
# safe_existing <- safe_existing[safe_isvalid(safe_existing)]
-
- # if footprint exists, check if existing SAFEs are actually equivalent
- if (!is.null(s2_meta$footprint)) {
- safe_existing_footprint <- safe_getMetadata(safe_existing, "footprint")
- safe_existing_centroid <- st_centroid(st_transform(st_as_sfc(safe_existing_footprint, crs = 4326), 3857))
- safe_centroid <- st_centroid(st_transform(st_as_sfc(s2_meta[i,footprint], crs = 4326), 3857))
- centroid_distance <- st_distance(safe_existing_centroid, safe_centroid)[1,1]
- # TODO
- }
+ #
+ # # if footprint exists, check if existing SAFEs are actually equivalent
+ # if (!is.null(s2_meta$footprint)) {
+ # safe_existing_footprint <- safe_getMetadata(safe_existing, "footprint")
+ # safe_existing_centroid <- st_centroid(st_transform(st_as_sfc(safe_existing_footprint, crs = 4326), 3857))
+ # safe_centroid <- st_centroid(st_transform(st_as_sfc(s2_meta[i,footprint], crs = 4326), 3857))
+ # centroid_distance <- st_distance(safe_existing_centroid, safe_centroid)[1,1]
+ # # TODO
+ # }
if (any(overwrite == TRUE, !dir.exists(safe_path))) {
diff --git a/R/s2_gui.R b/R/s2_gui.R
index de641581..da5cc72d 100644
--- a/R/s2_gui.R
+++ b/R/s2_gui.R
@@ -9,9 +9,8 @@
#' @author Luigi Ranghetti, phD (2019) \email{luigi@@ranghetti.info}
#' @references L. Ranghetti, M. Boschetti, F. Nutini, L. Busetto (2020).
#' "sen2r": An R toolbox for automatically downloading and preprocessing
-#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473. DOI:
-#' \href{https://doi.org/10.1016/j.cageo.2020.104473}{10.1016/j.cageo.2020.104473},
-#' URL: \url{http://sen2r.ranghetti.info/}.
+#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473.
+#' \doi{10.1016/j.cageo.2020.104473}, URL: \url{http://sen2r.ranghetti.info/}.
#' @note License: GPL 3.0
#' @importFrom jsonlite fromJSON toJSON
#' @import data.table
@@ -3112,7 +3111,7 @@ s2_gui <- function(param_list = NULL,
title = "Method to obtain level-2A corrected images",
p(HTML(
"Note: this selector is active only if",
- "Sen2Cor was installed and configured;",
"to do it, run check_sen2r_deps()
."
)),
diff --git a/R/s2_list.R b/R/s2_list.R
index d57502b7..4623b50f 100644
--- a/R/s2_list.R
+++ b/R/s2_list.R
@@ -49,15 +49,14 @@
#' `availability != "ignore"`, values are TRUE / FALSE for
#' products available for download / stored in the Long Term Archive;
#' otherwise, values are set to NA.
-#' @author Lorenzo Busetto, phD (2019) \email{lbusett@@gmail.com} - Inspired by
+#' @author Lorenzo Busetto, phD (2019) - Inspired by
#' function `getSentinel_query` of package
#' [`getSpatialData`](https://github.com/16EAGLE/getSpatialData) by J. Schwalb-Willmann
#' @author Luigi Ranghetti, phD (2019) \email{luigi@@ranghetti.info}
#' @references L. Ranghetti, M. Boschetti, F. Nutini, L. Busetto (2020).
#' "sen2r": An R toolbox for automatically downloading and preprocessing
-#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473. DOI:
-#' \href{https://doi.org/10.1016/j.cageo.2020.104473}{10.1016/j.cageo.2020.104473},
-#' URL: \url{http://sen2r.ranghetti.info/}.
+#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473.
+#' \doi{10.1016/j.cageo.2020.104473}, URL: \url{http://sen2r.ranghetti.info/}.
#' @note License: GPL 3.0
#' @import data.table
#' @importFrom methods is
@@ -161,7 +160,7 @@ s2_list <- function(spatial_extent = NULL,
# to avoid NOTE on check
. <- online <- id_tile <- id_orbit <-
- sensing_datetime <- ingestion_datetime <- NULL
+ sensing_datetime <- ingestion_datetime <- centroid <- footprint <- NULL
# convert input NA arguments in NULL
for (a in c("spatial_extent","tile","orbit","time_interval","apihub")) {
diff --git a/R/s2_mask.R b/R/s2_mask.R
index 1720ba23..c22718cf 100644
--- a/R/s2_mask.R
+++ b/R/s2_mask.R
@@ -122,9 +122,8 @@
#' @author Luigi Ranghetti, phD (2019) \email{luigi@@ranghetti.info}
#' @references L. Ranghetti, M. Boschetti, F. Nutini, L. Busetto (2020).
#' "sen2r": An R toolbox for automatically downloading and preprocessing
-#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473. DOI:
-#' \href{https://doi.org/10.1016/j.cageo.2020.104473}{10.1016/j.cageo.2020.104473},
-#' URL: \url{http://sen2r.ranghetti.info/}.
+#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473.
+#' \doi{10.1016/j.cageo.2020.104473}, URL: \url{http://sen2r.ranghetti.info/}.
#' @note License: GPL 3.0
#' @examples
#' \donttest{
@@ -149,9 +148,12 @@
#'
#' # Show output
#' oldpar <- par(mfrow = c(1,3))
-#' par(mar = rep(0,4)); image(stars::read_stars(ex_in), rgb = 1:3)
-#' par(mar = rep(2/3,4)); image(stars::read_stars(ex_mask))
-#' par(mar = rep(0,4)); image(stars::read_stars(ex_out), rgb = 1:3)
+#' par(mar = rep(0,4))
+#' image(stars::read_stars(ex_in), rgb = 1:3, useRaster = TRUE)
+#' par(mar = rep(2/3,4))
+#' image(stars::read_stars(ex_mask), useRaster = TRUE)
+#' par(mar = rep(0,4))
+#' image(stars::read_stars(ex_out), rgb = 1:3, useRaster = TRUE)
#' par(oldpar)
#' }
diff --git a/R/s2_merge.R b/R/s2_merge.R
index dc99936b..bfd87efd 100644
--- a/R/s2_merge.R
+++ b/R/s2_merge.R
@@ -62,9 +62,8 @@
#' @author Luigi Ranghetti, phD (2019) \email{luigi@@ranghetti.info}
#' @references L. Ranghetti, M. Boschetti, F. Nutini, L. Busetto (2020).
#' "sen2r": An R toolbox for automatically downloading and preprocessing
-#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473. DOI:
-#' \href{https://doi.org/10.1016/j.cageo.2020.104473}{10.1016/j.cageo.2020.104473},
-#' URL: \url{http://sen2r.ranghetti.info/}.
+#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473.
+#' \doi{10.1016/j.cageo.2020.104473}, URL: \url{http://sen2r.ranghetti.info/}.
#' @note License: GPL 3.0
diff --git a/R/s2_order.R b/R/s2_order.R
index 8f154dca..26dc8dd3 100644
--- a/R/s2_order.R
+++ b/R/s2_order.R
@@ -38,12 +38,11 @@
#' and not ordered) was saved (if `export_prodlist = TRUE`).
#'
#' @author Luigi Ranghetti, phD (2019) \email{luigi@@ranghetti.info}
-#' @author Lorenzo Busetto, phD (2020) \email{lbusett@@gmail.com}
+#' @author Lorenzo Busetto, phD (2020)
#' @references L. Ranghetti, M. Boschetti, F. Nutini, L. Busetto (2020).
#' "sen2r": An R toolbox for automatically downloading and preprocessing
-#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473. DOI:
-#' \href{https://doi.org/10.1016/j.cageo.2020.104473}{10.1016/j.cageo.2020.104473},
-#' URL: \url{http://sen2r.ranghetti.info/}.
+#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473.
+#' \doi{10.1016/j.cageo.2020.104473}, URL: \url{http://sen2r.ranghetti.info/}.
#' @note License: GPL 3.0
#' @importFrom httr RETRY authenticate
#' @importFrom foreach foreach "%do%"
diff --git a/R/s2_rgb.R b/R/s2_rgb.R
index 36ef4062..6f181fb7 100644
--- a/R/s2_rgb.R
+++ b/R/s2_rgb.R
@@ -65,9 +65,8 @@
#' @author Luigi Ranghetti, phD (2019) \email{luigi@@ranghetti.info}
#' @references L. Ranghetti, M. Boschetti, F. Nutini, L. Busetto (2020).
#' "sen2r": An R toolbox for automatically downloading and preprocessing
-#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473. DOI:
-#' \href{https://doi.org/10.1016/j.cageo.2020.104473}{10.1016/j.cageo.2020.104473},
-#' URL: \url{http://sen2r.ranghetti.info/}.
+#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473.
+#' \doi{10.1016/j.cageo.2020.104473}, URL: \url{http://sen2r.ranghetti.info/}.
#' @note License: GPL 3.0
#' @import data.table
#' @importFrom foreach foreach "%do%" "%dopar%"
@@ -95,9 +94,9 @@
#'
#' # Show output
#' oldpar <- par(mfrow = c(1,3), mar = rep(0,4))
-#' image(stars::read_stars(ex_in), rgb = 4:2, maxColorValue = 3500)
-#' image(stars::read_stars(ex_out[1]), rgb = 1:3)
-#' image(stars::read_stars(ex_out[2]), rgb = 1:3)
+#' image(stars::read_stars(ex_in), rgb = 4:2, maxColorValue = 3500, useRaster = TRUE)
+#' image(stars::read_stars(ex_out[1]), rgb = 1:3, useRaster = TRUE)
+#' image(stars::read_stars(ex_out[2]), rgb = 1:3, useRaster = TRUE)
#' par(oldpar)
#' }
diff --git a/R/s2_thumbnails.R b/R/s2_thumbnails.R
index adc5923f..5f4b8c90 100644
--- a/R/s2_thumbnails.R
+++ b/R/s2_thumbnails.R
@@ -42,9 +42,8 @@
#' @author Luigi Ranghetti, phD (2019) \email{luigi@@ranghetti.info}
#' @references L. Ranghetti, M. Boschetti, F. Nutini, L. Busetto (2020).
#' "sen2r": An R toolbox for automatically downloading and preprocessing
-#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473. DOI:
-#' \href{https://doi.org/10.1016/j.cageo.2020.104473}{10.1016/j.cageo.2020.104473},
-#' URL: \url{http://sen2r.ranghetti.info/}.
+#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473.
+#' \doi{10.1016/j.cageo.2020.104473}, URL: \url{http://sen2r.ranghetti.info/}.
#' @note License: GPL 3.0
#' @importFrom raster raster
#' @importFrom jsonlite fromJSON
@@ -287,9 +286,8 @@ stack2rgb <- function(in_rast,
#' @author Luigi Ranghetti, phD (2019) \email{luigi@@ranghetti.info}
#' @references L. Ranghetti, M. Boschetti, F. Nutini, L. Busetto (2020).
#' "sen2r": An R toolbox for automatically downloading and preprocessing
-#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473. DOI:
-#' \href{https://doi.org/10.1016/j.cageo.2020.104473}{10.1016/j.cageo.2020.104473},
-#' URL: \url{http://sen2r.ranghetti.info/}.
+#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473.
+#' \doi{10.1016/j.cageo.2020.104473}, URL: \url{http://sen2r.ranghetti.info/}.
#' @note License: GPL 3.0
#' @importFrom raster raster
#' @importFrom jsonlite fromJSON
@@ -462,9 +460,8 @@ raster2rgb <- function(in_rast,
#' @author Luigi Ranghetti, phD (2019) \email{luigi@@ranghetti.info}
#' @references L. Ranghetti, M. Boschetti, F. Nutini, L. Busetto (2020).
#' "sen2r": An R toolbox for automatically downloading and preprocessing
-#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473. DOI:
-#' \href{https://doi.org/10.1016/j.cageo.2020.104473}{10.1016/j.cageo.2020.104473},
-#' URL: \url{http://sen2r.ranghetti.info/}.
+#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473.
+#' \doi{10.1016/j.cageo.2020.104473}, URL: \url{http://sen2r.ranghetti.info/}.
#' @note License: GPL 3.0
#' @import data.table
#' @importFrom jsonlite fromJSON
diff --git a/R/s2_tiles.R b/R/s2_tiles.R
index 57ce3329..88b50367 100644
--- a/R/s2_tiles.R
+++ b/R/s2_tiles.R
@@ -10,9 +10,8 @@
#' @author Luigi Ranghetti, phD (2019) \email{luigi@@ranghetti.info}
#' @references L. Ranghetti, M. Boschetti, F. Nutini, L. Busetto (2020).
#' "sen2r": An R toolbox for automatically downloading and preprocessing
-#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473. DOI:
-#' \href{https://doi.org/10.1016/j.cageo.2020.104473}{10.1016/j.cageo.2020.104473},
-#' URL: \url{http://sen2r.ranghetti.info/}.
+#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473.
+#' \doi{10.1016/j.cageo.2020.104473}, URL: \url{http://sen2r.ranghetti.info/}.
#' @note License: GPL 3.0
#' @examples
#' # Retrieve all the tiles
diff --git a/R/s2_translate.R b/R/s2_translate.R
index 898d3303..86c6c559 100644
--- a/R/s2_translate.R
+++ b/R/s2_translate.R
@@ -56,9 +56,8 @@
#' @author Luigi Ranghetti, phD (2019) \email{luigi@@ranghetti.info}
#' @references L. Ranghetti, M. Boschetti, F. Nutini, L. Busetto (2020).
#' "sen2r": An R toolbox for automatically downloading and preprocessing
-#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473. DOI:
-#' \href{https://doi.org/10.1016/j.cageo.2020.104473}{10.1016/j.cageo.2020.104473},
-#' URL: \url{http://sen2r.ranghetti.info/}.
+#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473.
+#' \doi{10.1016/j.cageo.2020.104473}, URL: \url{http://sen2r.ranghetti.info/}.
#' @note License: GPL 3.0
#' @importFrom jsonlite fromJSON
#' @export
diff --git a/R/safe_getMetadata.R b/R/safe_getMetadata.R
index e2eb7674..65df3e21 100644
--- a/R/safe_getMetadata.R
+++ b/R/safe_getMetadata.R
@@ -86,9 +86,8 @@
#' @author Luigi Ranghetti, phD (2019) \email{luigi@@ranghetti.info}
#' @references L. Ranghetti, M. Boschetti, F. Nutini, L. Busetto (2020).
#' "sen2r": An R toolbox for automatically downloading and preprocessing
-#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473. DOI:
-#' \href{https://doi.org/10.1016/j.cageo.2020.104473}{10.1016/j.cageo.2020.104473},
-#' URL: \url{http://sen2r.ranghetti.info/}.
+#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473.
+#' \doi{10.1016/j.cageo.2020.104473}, URL: \url{http://sen2r.ranghetti.info/}.
#' @note License: GPL 3.0
#' @export
#' @import data.table
diff --git a/R/safe_is_online.R b/R/safe_is_online.R
index d3f9811a..17237080 100644
--- a/R/safe_is_online.R
+++ b/R/safe_is_online.R
@@ -16,12 +16,11 @@
#' available for download, FALSE if it is not or NA in case of errors with
#' the SAFE url.
#' @author Luigi Ranghetti, phD (2019) \email{luigi@@ranghetti.info}
-#' @author Lorenzo Busetto, phD (2020) \email{lbusett@@gmail.com}
+#' @author Lorenzo Busetto, phD (2020)
#' @references L. Ranghetti, M. Boschetti, F. Nutini, L. Busetto (2020).
#' "sen2r": An R toolbox for automatically downloading and preprocessing
-#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473. DOI:
-#' \href{https://doi.org/10.1016/j.cageo.2020.104473}{10.1016/j.cageo.2020.104473},
-#' URL: \url{http://sen2r.ranghetti.info/}.
+#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473.
+#' \doi{10.1016/j.cageo.2020.104473}, URL: \url{http://sen2r.ranghetti.info/}.
#' @note License: GPL 3.0
#' @importFrom httr RETRY authenticate content
#' @importFrom jsonlite fromJSON
diff --git a/R/safe_shortname.R b/R/safe_shortname.R
index cb998b07..4f7b9859 100644
--- a/R/safe_shortname.R
+++ b/R/safe_shortname.R
@@ -62,9 +62,8 @@
#' @author Luigi Ranghetti, phD (2019) \email{luigi@@ranghetti.info}
#' @references L. Ranghetti, M. Boschetti, F. Nutini, L. Busetto (2020).
#' "sen2r": An R toolbox for automatically downloading and preprocessing
-#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473. DOI:
-#' \href{https://doi.org/10.1016/j.cageo.2020.104473}{10.1016/j.cageo.2020.104473},
-#' URL: \url{http://sen2r.ranghetti.info/}.
+#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473.
+#' \doi{10.1016/j.cageo.2020.104473}, URL: \url{http://sen2r.ranghetti.info/}.
#' @note License: GPL 3.0
#' @export
diff --git a/R/safelist-class.R b/R/safelist-class.R
index a1a05e45..80cc6896 100644
--- a/R/safelist-class.R
+++ b/R/safelist-class.R
@@ -23,9 +23,8 @@
#' @author Luigi Ranghetti, phD (2019) \email{luigi@@ranghetti.info}
#' @references L. Ranghetti, M. Boschetti, F. Nutini, L. Busetto (2020).
#' "sen2r": An R toolbox for automatically downloading and preprocessing
-#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473. DOI:
-#' \href{https://doi.org/10.1016/j.cageo.2020.104473}{10.1016/j.cageo.2020.104473},
-#' URL: \url{http://sen2r.ranghetti.info/}.
+#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473.
+#' \doi{10.1016/j.cageo.2020.104473}, URL: \url{http://sen2r.ranghetti.info/}.
#' @note License: GPL 3.0
#' @examples
#' \donttest{
diff --git a/R/scihub_login.R b/R/scihub_login.R
index 65b852f7..c94624bc 100644
--- a/R/scihub_login.R
+++ b/R/scihub_login.R
@@ -19,9 +19,8 @@
#' @author Luigi Ranghetti, phD (2019) \email{luigi@@ranghetti.info}
#' @references L. Ranghetti, M. Boschetti, F. Nutini, L. Busetto (2020).
#' "sen2r": An R toolbox for automatically downloading and preprocessing
-#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473. DOI:
-#' \href{https://doi.org/10.1016/j.cageo.2020.104473}{10.1016/j.cageo.2020.104473},
-#' URL: \url{http://sen2r.ranghetti.info/}.
+#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473.
+#' \doi{10.1016/j.cageo.2020.104473}, URL: \url{http://sen2r.ranghetti.info/}.
#' @note License: GPL 3.0
#'
#' @examples
@@ -66,7 +65,7 @@ read_scihub_login <- function(apihub_path=NA) {
#' @return `check_scihub_login` returns TRUE if credentials are valid,
#' FALSE elsewhere.
#' @importFrom httr RETRY authenticate handle
-#' @author Lorenzo Busetto, phD (2019) \email{lbusett@@gmail.com}
+#' @author Lorenzo Busetto, phD (2019)
#' @rdname scihub_login
#' @export
diff --git a/R/sen2cor.R b/R/sen2cor.R
index ca014be5..dd09364e 100644
--- a/R/sen2cor.R
+++ b/R/sen2cor.R
@@ -1,7 +1,7 @@
#' @title Correct L1C products using Sen2Cor
#' @description The function uses Sen2Cor to manually correct L1C products.
#' Standalone version of
-#' [sen2cor](http://step.esa.int/main/third-party-plugins-2/sen2cor/)
+#' [sen2cor](http://step.esa.int/main/snap-supported-plugins/sen2cor/)
#' (version 2.8.0 or 2.5.5) is used.
#' @param l1c_prodlist List of L1C product names to be corrected. They can be both
#' product names with full/relative path or only names of SAFE products (in this case, also
@@ -38,8 +38,8 @@
#' to maintain the value specified in the XML file).
#'
#' For details about the GIPP parameters, refer to the Sen2Cor documentation
-#' (v. [2.5.5](http://step.esa.int/main/third-party-plugins-2/sen2cor/sen2cor_v2-5-5/)
-#' or [2.8.0](http://step.esa.int/main/third-party-plugins-2/sen2cor/sen2cor_v2-8/):
+#' (v. [2.5.5](http://step.esa.int/main/snap-supported-plugins/sen2cor/sen2cor_v2-5-5/)
+#' or [2.8.0](http://step.esa.int/main/snap-supported-plugins/sen2cor/sen2cor_v2-8/):
#' see the "Schemas of the GIPP file" at the end of each page).
#' _Note_: this argument takes effect only in the current execution of
#' `sen2cor()` function.
@@ -102,9 +102,8 @@
#' @author Luigi Ranghetti, phD (2019) \email{luigi@@ranghetti.info}
#' @references L. Ranghetti, M. Boschetti, F. Nutini, L. Busetto (2020).
#' "sen2r": An R toolbox for automatically downloading and preprocessing
-#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473. DOI:
-#' \href{https://doi.org/10.1016/j.cageo.2020.104473}{10.1016/j.cageo.2020.104473},
-#' URL: \url{http://sen2r.ranghetti.info/}.
+#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473.
+#' \doi{10.1016/j.cageo.2020.104473}, URL: \url{http://sen2r.ranghetti.info/}.
#' @note License: GPL 3.0
#' @importFrom jsonlite fromJSON
#' @importFrom doParallel registerDoParallel
diff --git a/R/sen2r.R b/R/sen2r.R
index 56d5d074..94ee250b 100644
--- a/R/sen2r.R
+++ b/R/sen2r.R
@@ -327,12 +327,11 @@
#' @importFrom stats na.omit setNames
#' @export
#' @author Luigi Ranghetti, phD (2020) \email{luigi@@ranghetti.info}
-#' @author Lorenzo Busetto, phD (2020) \email{lbusett@@gmail.com}
+#' @author Lorenzo Busetto, phD (2020)
#' @references L. Ranghetti, M. Boschetti, F. Nutini, L. Busetto (2020).
#' "sen2r": An R toolbox for automatically downloading and preprocessing
-#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473. DOI:
-#' \href{https://doi.org/10.1016/j.cageo.2020.104473}{10.1016/j.cageo.2020.104473},
-#' URL: \url{http://sen2r.ranghetti.info/}.
+#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473.
+#' \doi{10.1016/j.cageo.2020.104473}, URL: \url{http://sen2r.ranghetti.info/}.
#' @note License: GPL 3.0
#' @examples
#' \donttest{
@@ -390,28 +389,28 @@
#' gsub("jpg$", "png", thumb_4[grep("SCL", thumb_4)])
#'
#' oldpar <- par(mfrow = c(1,2), mar = rep(0,4))
-#' image(stars::read_stars(thumb_3[grep("BOA", thumb_3)]), rgb = 1:3)
-#' image(stars::read_stars(thumb_3[grep("SCL", thumb_3)]), rgb = 1:3)
+#' image(stars::read_stars(thumb_3[grep("BOA", thumb_3)]), rgb = 1:3, useRaster = TRUE)
+#' image(stars::read_stars(thumb_3[grep("SCL", thumb_3)]), rgb = 1:3, useRaster = TRUE)
#'
#' par(mfrow = c(1,2), mar = rep(0,4))
-#' image(stars::read_stars(thumb_3[grep("MSAVI2", thumb_3)]), rgb = 1:3)
-#' image(stars::read_stars(thumb_3[grep("NDVI", thumb_3)]), rgb = 1:3)
+#' image(stars::read_stars(thumb_3[grep("MSAVI2", thumb_3)]), rgb = 1:3, useRaster = TRUE)
+#' image(stars::read_stars(thumb_3[grep("NDVI", thumb_3)]), rgb = 1:3, useRaster = TRUE)
#'
#' par(mfrow = c(1,2), mar = rep(0,4))
-#' image(stars::read_stars(thumb_3[grep("RGB432B", thumb_3)]), rgb = 1:3)
-#' image(stars::read_stars(thumb_3[grep("RGB843B", thumb_3)]), rgb = 1:3)
+#' image(stars::read_stars(thumb_3[grep("RGB432B", thumb_3)]), rgb = 1:3, useRaster = TRUE)
+#' image(stars::read_stars(thumb_3[grep("RGB843B", thumb_3)]), rgb = 1:3, useRaster = TRUE)
#'
#' par(mfrow = c(1,2), mar = rep(0,4))
-#' image(stars::read_stars(thumb_4[grep("BOA", thumb_4)]), rgb = 1:3)
-#' image(stars::read_stars(thumb_4[grep("SCL", thumb_4)]), rgb = 1:3)
+#' image(stars::read_stars(thumb_4[grep("BOA", thumb_4)]), rgb = 1:3, useRaster = TRUE)
+#' image(stars::read_stars(thumb_4[grep("SCL", thumb_4)]), rgb = 1:3, useRaster = TRUE)
#'
#' par(mfrow = c(1,2), mar = rep(0,4))
-#' image(stars::read_stars(thumb_4[grep("MSAVI2", thumb_4)]), rgb = 1:3)
-#' image(stars::read_stars(thumb_4[grep("NDVI", thumb_4)]), rgb = 1:3)
+#' image(stars::read_stars(thumb_4[grep("MSAVI2", thumb_4)]), rgb = 1:3, useRaster = TRUE)
+#' image(stars::read_stars(thumb_4[grep("NDVI", thumb_4)]), rgb = 1:3, useRaster = TRUE)
#'
#' par(mfrow = c(1,2), mar = rep(0,4))
-#' image(stars::read_stars(thumb_4[grep("RGB432B", thumb_4)]), rgb = 1:3)
-#' image(stars::read_stars(thumb_4[grep("RGB843B", thumb_4)]), rgb = 1:3)
+#' image(stars::read_stars(thumb_4[grep("RGB432B", thumb_4)]), rgb = 1:3, useRaster = TRUE)
+#' image(stars::read_stars(thumb_4[grep("RGB843B", thumb_4)]), rgb = 1:3, useRaster = TRUE)
#'
#' par(oldpar)
#' }
@@ -667,7 +666,9 @@ sen2r <- function(param_list = NULL,
# to avoid NOTE on check
. <- sensing_datetime <- creation_datetime <- mission <- level <- id_orbit <-
id_tile <- name <- id_baseline <- prod_type <- name <- sel_group_A <-
- i_group_A <- sel_apihub_path <- i_group_B <- sensing_date <- lta <- NULL
+ i_group_A <- sel_apihub_path <- i_group_B <- sensing_date <- lta <-
+ centroid_x <- centroid_y <- res_type <-path <- footprint <- sel_out <-
+ NULL
### Preliminary settings ###
@@ -1559,6 +1560,21 @@ sen2r <- function(param_list = NULL,
return(sen2r_output)
}
+ ## determine the output grid (this will be used later)
+ exi_meta <- cbind(
+ sen2r_getElements(unlist(s2names$exi[c("indices","rgb","masked","warped_nomsk","warped")])),
+ data.frame(path=unlist(s2names$exi[c("indices","rgb","masked","warped_nomsk","warped")]))
+ # raster_metadata(unlist(s2names$exi[c("indices","rgb","masked","warped_nomsk","warped")]))
+ )
+ # res_type: "res20" if the minimum native resolution is 20m, "res10" if it is 10m
+ exi_meta[,res_type:=ifelse(prod_type %in% c("SCL","CLD","SNW"), "res20", "res10")]
+ reference_exi_paths <- if (nrow(exi_meta)>0) {
+ exi_meta[!duplicated(res_type),list(res_type,path)]
+ } else {
+ data.table(res_type = character(0), path = character(0))
+ }
+
+
### SAFE processing: download and atmospheric correction ###
## Generate the list of required SAFE
@@ -2425,7 +2441,17 @@ sen2r <- function(param_list = NULL,
sel_s2names$req$warped[[sel_prod]],
warped_tomsk_reqout[[sel_prod]],
of = out_format["warped"],
- ref = if (!is.na(pm$reference_path)) {pm$reference_path} else {NULL},
+ ref = if (!is.na(pm$reference_path)) {
+ pm$reference_path
+ } else {
+ reference_exi_paths[
+ res_type == ifelse(
+ sel_prod %in% c("SCL","CLD","SNW"),
+ "res20", "res10"
+ ),
+ path
+ ]
+ },
mask = s2_mask_extent,
tr = if (!anyNA(pm$res)) {pm$res} else {NULL},
t_srs = if (!is.na(pm$proj)){pm$proj} else {NULL},
@@ -2464,7 +2490,17 @@ sen2r <- function(param_list = NULL,
sel_s2names$req$warped_nomsk[[sel_prod]],
warped_nomsk_reqout[[sel_prod]],
of = out_format["warped_nomsk"], # use physical files to speed up next steps
- ref = if (!is.na(pm$reference_path)) {pm$reference_path} else {NULL},
+ ref = if (!is.na(pm$reference_path)) {
+ pm$reference_path
+ } else {
+ reference_exi_paths[
+ res_type == ifelse(
+ sel_prod %in% c("SCL","CLD","SNW"),
+ "res20", "res10"
+ ),
+ path
+ ]
+ },
mask = s2_mask_extent,
tr = if (!anyNA(pm$res)) {pm$res} else {NULL},
t_srs = if (!is.na(pm$proj)) {pm$proj} else {NULL},
diff --git a/R/sen2r_getElements.R b/R/sen2r_getElements.R
index cf992a6e..7a8da78b 100644
--- a/R/sen2r_getElements.R
+++ b/R/sen2r_getElements.R
@@ -13,9 +13,8 @@
#' @author Luigi Ranghetti, phD (2019) \email{luigi@@ranghetti.info}
#' @references L. Ranghetti, M. Boschetti, F. Nutini, L. Busetto (2020).
#' "sen2r": An R toolbox for automatically downloading and preprocessing
-#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473. DOI:
-#' \href{https://doi.org/10.1016/j.cageo.2020.104473}{10.1016/j.cageo.2020.104473},
-#' URL: \url{http://sen2r.ranghetti.info/}.
+#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473.
+#' \doi{10.1016/j.cageo.2020.104473}, URL: \url{http://sen2r.ranghetti.info/}.
#' @note License: GPL 3.0
#' @export
#' @import data.table
diff --git a/R/sen2r_process_report.R b/R/sen2r_process_report.R
index 66435eb6..4bff2ddd 100644
--- a/R/sen2r_process_report.R
+++ b/R/sen2r_process_report.R
@@ -39,12 +39,11 @@
#' - `n_corrected`: number of images atmospherically corrected using sen2cor;
#' - `completed`: logical, indicating if processing can be considered
#' "complete" (it is set to TRUE in case `n_notonline_dates = 0`).
-#' @author Lorenzo Busetto, phD (2020) \email{lbusett@@gmail.com}
+#' @author Lorenzo Busetto, phD (2020)
#' @references L. Ranghetti, M. Boschetti, F. Nutini, L. Busetto (2020).
#' "sen2r": An R toolbox for automatically downloading and preprocessing
-#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473. DOI:
-#' \href{https://doi.org/10.1016/j.cageo.2020.104473}{10.1016/j.cageo.2020.104473},
-#' URL: \url{http://sen2r.ranghetti.info/}.
+#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473.
+#' \doi{10.1016/j.cageo.2020.104473}, URL: \url{http://sen2r.ranghetti.info/}.
#' @note License: GPL 3.0
diff --git a/R/smooth_mask.R b/R/smooth_mask.R
index d49ba750..05e0f4fd 100644
--- a/R/smooth_mask.R
+++ b/R/smooth_mask.R
@@ -24,9 +24,8 @@
#' @author Luigi Ranghetti, phD (2019) \email{luigi@@ranghetti.info}
#' @references L. Ranghetti, M. Boschetti, F. Nutini, L. Busetto (2020).
#' "sen2r": An R toolbox for automatically downloading and preprocessing
-#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473. DOI:
-#' \href{https://doi.org/10.1016/j.cageo.2020.104473}{10.1016/j.cageo.2020.104473},
-#' URL: \url{http://sen2r.ranghetti.info/}.
+#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473.
+#' \doi{10.1016/j.cageo.2020.104473}, URL: \url{http://sen2r.ranghetti.info/}.
#' @note License: GPL 3.0
smooth_mask <- function(
diff --git a/R/st_as_text_2.R b/R/st_as_text_2.R
index b172a621..66781e0b 100644
--- a/R/st_as_text_2.R
+++ b/R/st_as_text_2.R
@@ -18,22 +18,22 @@
#' sen2r:::st_as_text_2(sf::st_crs(32632))
st_as_text_2 <- function(x, pretty = FALSE) {
- if (
- package_version(sf_extSoftVersion()["proj.4"]) >= 6 &&
- requireNamespace("rgdal", quietly = TRUE) &&
- packageVersion("rgdal") >= 1.5
- ) {
- x_crs <- st_crs(x)
- x_proj <- if (is.na(x_crs$epsg)) {
- x_crs$proj4string
- } else {
- paste0("EPSG:",x_crs$epsg)
- }
- srid_multiline <- if (pretty == TRUE) {"YES"} else {"NO"}
- eval(parse(
- text = "rgdal::showSRID(x_proj, format = 'WKT2', multiline = srid_multiline)"
- ))
- } else {
+ # if (
+ # package_version(sf_extSoftVersion()["proj.4"]) >= 6 &&
+ # requireNamespace("rgdal", quietly = TRUE) &&
+ # packageVersion("rgdal") >= 1.5
+ # ) {
+ # x_crs <- st_crs(x)
+ # x_proj <- if (is.na(x_crs$epsg)) {
+ # x_crs$proj4string
+ # } else {
+ # paste0("EPSG:",x_crs$epsg)
+ # }
+ # srid_multiline <- if (pretty == TRUE) {"YES"} else {"NO"}
+ # eval(parse(
+ # text = "rgdal::showSRID(x_proj, format = 'WKT2', multiline = srid_multiline)"
+ # ))
+ # } else {
st_as_text(x, pretty = pretty)
- }
+ # }
}
diff --git a/R/st_crs2.R b/R/st_crs2.R
index 06f755b9..762370d8 100644
--- a/R/st_crs2.R
+++ b/R/st_crs2.R
@@ -29,9 +29,8 @@
#' @author Luigi Ranghetti, phD (2019) \email{luigi@@ranghetti.info}
#' @references L. Ranghetti, M. Boschetti, F. Nutini, L. Busetto (2020).
#' "sen2r": An R toolbox for automatically downloading and preprocessing
-#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473. DOI:
-#' \href{https://doi.org/10.1016/j.cageo.2020.104473}{10.1016/j.cageo.2020.104473},
-#' URL: \url{http://sen2r.ranghetti.info/}.
+#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473.
+#' \doi{10.1016/j.cageo.2020.104473}, URL: \url{http://sen2r.ranghetti.info/}.
#' @note License: GPL 3.0
#' @examples
#' ## CRS from EPSG
diff --git a/R/str_pad2.R b/R/str_pad2.R
index 638c7b03..f0d0071c 100644
--- a/R/str_pad2.R
+++ b/R/str_pad2.R
@@ -12,9 +12,8 @@
#' @author Luigi Ranghetti, phD (2019) \email{luigi@@ranghetti.info}
#' @references L. Ranghetti, M. Boschetti, F. Nutini, L. Busetto (2020).
#' "sen2r": An R toolbox for automatically downloading and preprocessing
-#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473. DOI:
-#' \href{https://doi.org/10.1016/j.cageo.2020.104473}{10.1016/j.cageo.2020.104473},
-#' URL: \url{http://sen2r.ranghetti.info/}.
+#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473.
+#' \doi{10.1016/j.cageo.2020.104473}, URL: \url{http://sen2r.ranghetti.info/}.
#' @note License: GPL 3.0
#' @export
#' @examples
diff --git a/R/tiles_intersects.R b/R/tiles_intersects.R
index 1a9817f0..c4f745b7 100644
--- a/R/tiles_intersects.R
+++ b/R/tiles_intersects.R
@@ -21,9 +21,8 @@
#' @author Luigi Ranghetti, phD (2019) \email{luigi@@ranghetti.info}
#' @references L. Ranghetti, M. Boschetti, F. Nutini, L. Busetto (2020).
#' "sen2r": An R toolbox for automatically downloading and preprocessing
-#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473. DOI:
-#' \href{https://doi.org/10.1016/j.cageo.2020.104473}{10.1016/j.cageo.2020.104473},
-#' URL: \url{http://sen2r.ranghetti.info/}.
+#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473.
+#' \doi{10.1016/j.cageo.2020.104473}, URL: \url{http://sen2r.ranghetti.info/}.
#' @note License: GPL 3.0
#' @examples
#' ex_extent <- sf::st_read(
diff --git a/R/trace_functions.R b/R/trace_functions.R
index 0a4ea7d1..26313ab7 100644
--- a/R/trace_functions.R
+++ b/R/trace_functions.R
@@ -36,9 +36,8 @@
#' @author Luigi Ranghetti, phD (2019) \email{luigi@@ranghetti.info}
#' @references L. Ranghetti, M. Boschetti, F. Nutini, L. Busetto (2020).
#' "sen2r": An R toolbox for automatically downloading and preprocessing
-#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473. DOI:
-#' \href{https://doi.org/10.1016/j.cageo.2020.104473}{10.1016/j.cageo.2020.104473},
-#' URL: \url{http://sen2r.ranghetti.info/}.
+#' Sentinel-2 satellite data. _Computers & Geosciences_, 139, 104473.
+#' \doi{10.1016/j.cageo.2020.104473}, URL: \url{http://sen2r.ranghetti.info/}.
#' @note License: GPL 3.0
#' @importFrom methods is
diff --git a/README.Rmd b/README.Rmd
index 3555b105..9e836c26 100644
--- a/README.Rmd
+++ b/README.Rmd
@@ -74,7 +74,7 @@ was published on the ISI journal *Computers \& Geosciences*; the manuscript is a
L.\ Ranghetti, M.\ Boschetti, F.\ Nutini, L.\ Busetto (2020).
"sen2r: An R toolbox for automatically downloading and preprocessing Sentinel-2 satellite data".
Computers \& Geosciences, 139, 104473.
-DOI: 10.1016/j.cageo.2020.104473,
+doi: 10.1016/j.cageo.2020.104473,
URL: http://sen2r.ranghetti.info
.
@@ -142,8 +142,8 @@ This is a list of the principal processing functions
to download Sentinel-2 products;
* [`s2_order()`](http://sen2r.ranghetti.info/reference/s2_order.html)
to order products from the Long Term Archive;
-* [`sen2cor()`](reference/sen2cor.html)
- to correct level-1C products using [Sen2Cor](http://step.esa.int/main/third-party-plugins-2/sen2cor/);
+* [`sen2cor()`](http://sen2r.ranghetti.info/reference/sen2cor.html)
+ to correct level-1C products using [Sen2Cor](http://step.esa.int/main/snap-supported-plugins/sen2cor/);
* [`s2_mask()`](http://sen2r.ranghetti.info/reference/s2_mask.html)
to apply a cloud mask to Sentinel-2 products;
* [`s2_rgb()`](http://sen2r.ranghetti.info/reference/s2_rgb.html)
@@ -170,7 +170,7 @@ To cite this library, please use the following entry:
L.\ Ranghetti, M.\ Boschetti, F.\ Nutini, L.\ Busetto (2020).
**"sen2r: An R toolbox for automatically downloading and preprocessing Sentinel-2 satellite data"**.
*Computers \& Geosciences*, 139, 104473.
-DOI: 10.1016/j.cageo.2020.104473,
+doi: 10.1016/j.cageo.2020.104473,
URL: http://sen2r.ranghetti.info.
```bibtex
diff --git a/README.md b/README.md
index d9c9a3f8..71762f13 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,12 @@
-
+- [sen2r: Find, Download and Process Sentinel-2
+ Data](#sen2r-find-download-and-process-sentinel-2-data)
+ - [Installation](#installation)
+ - [Usage](#usage)
+ - [Credits](#credits)
+ - [Contributing](#contributing)
+
[ 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,
-sen2r
+In particular, sen2r
allows to:
- - retrieve the list of available products on a selected area (which
+- 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
+- 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
+- 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
+- mask cloudy pixels (using the Surface Classification Map as masking
layer);
- - computing spectral indices and RGB images.
+- computing spectral indices and RGB images.
Setting the execution of this processing chain is particularly easy
-using the
-sen2r
+using the sen2r
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.
@@ -63,21 +76,22 @@ 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)).
+(see [usage](#usage)).
-sen2r
+sen2r
was published on the ISI journal *Computers & Geosciences*; the
-manuscript is available
-here:
+manuscript is available here:
L. Ranghetti, M. Boschetti, F. Nutini, L. Busetto (2020).
“sen2r: An R toolbox for automatically downloading and
preprocessing Sentinel-2 satellite data”. Computers &
-Geosciences, 139, 104473. DOI: 10.1016/j.cageo.2020.104473, URL:
+Geosciences, 139, 104473. doi: 10.1016/j.cageo.2020.104473, URL:
http://sen2r.ranghetti.info .
Users which processed Sentinel-2 data and used them for a scientific
@@ -97,16 +111,20 @@ dependencies), see the
[Installation](http://sen2r.ranghetti.info/articles/installation.html)
page.
-A dockerised version of
-sen2r
+A dockerised version of sen2r
is available [here](https://hub.docker.com/r/ranghetti/sen2r). For
detailed instructions about using it, see the page [“Run in a Docker
container”](http://sen2r.ranghetti.info/articles/docker.html).
## Usage
-The simplest way to use
-sen2r
+The simplest way to use sen2r
is to execute it in interactive mode (see [this
vignette](http://sen2r.ranghetti.info/articles/sen2r_gui.html)):
@@ -116,7 +134,6 @@ sen2r()
```
-
@@ -127,7 +144,6 @@ sen2r()
-
If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the “copyright” line and a pointer to where the full notice is found.
-<one line to give the program's name and a brief idea of what it does.>
-Copyright (C) 2019 Luigi Ranghetti, Lorenzo Busetto
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see <http://www.gnu.org/licenses/>.
<one line to give the program's name and a brief idea of what it does.>
+Copyright (C) 2019 Luigi Ranghetti, Lorenzo Busetto
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode:
-Copyright (C) 2019 Luigi Ranghetti, Lorenzo Busetto
- sen2r for details type 'show w'.
- This program comes with ABSOLUTELY NO WARRANTY;
- This is free software, and you are welcome to redistribute it'show c' for details. under certain conditions; type
Copyright (C) 2019 Luigi Ranghetti, Lorenzo Busetto
+ sen2r for details type 'show w'.
+ This program comes with ABSOLUTELY NO WARRANTY;
+ This is free software, and you are welcome to redistribute it'show c' for details. under certain conditions; type
The hypothetical commands show w
and show c
should show the appropriate parts of the General Public License. Of course, your program’s commands might be different; for a GUI interface, you would use an “about box”.
You should also get your employer (if you work as a programmer) or school, if any, to sign a “copyright disclaimer” for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see <http://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read <http://www.gnu.org/philosophy/why-not-lgpl.html>.
diff --git a/docs/articles/docker.html b/docs/articles/docker.html index fb5b2058..decc9103 100644 --- a/docs/articles/docker.html +++ b/docs/articles/docker.html @@ -31,7 +31,7 @@ @@ -106,7 +106,8 @@ -read the docker documentation in Part 1;
obtain the image of sen2r:
-docker pull ranghetti/sen2r:latest
docker pull ranghetti/sen2r:latest
where latest
corresponds to the software version in branch master (see here all the available docker tags);
run the docker:
-docker run --rm -e PASSWORD=sen2r -e USERID=$(id -u) -v $(pwd):/home/rstudio/host -p 8777:8787 ranghetti/sen2r
docker run --rm -e PASSWORD=sen2r -e USERID=$(id -u) -v $(pwd):/home/rstudio/host -p 8777:8787 ranghetti/sen2r
where:
access to the RStudio environment from http://localhost:8777
, logging in with user rstudio
and the password set as above;
for online use, add the user’s SciHub credentials using the GUI or with the function:
--library(sen2r) -write_scihub_login("<scihub_username>", "<scihub_password>")
+library(sen2r)
+write_scihub_login("<scihub_username>", "<scihub_password>")
Some external dependencies are required to run specific sen2r features:
Ubuntu 20.04 LTS Focal and newer:
-sudo apt install -y r-base gdal-bin aria2 libpython2-dev libudunits2-dev libgdal-dev libjq-dev libprotobuf-dev protobuf-compiler libv8-dev libssl-dev libcairo2-dev
sudo apt install -y r-base gdal-bin aria2 libpython2-dev libudunits2-dev libgdal-dev libjq-dev libprotobuf-dev protobuf-compiler libv8-dev libssl-dev libcairo2-dev
Older distros:
-sudo apt-get install -y r-base gdal-bin python-gdal aria2 libpython-dev libudunits2-dev libgdal-dev libjq-dev libprotobuf-dev protobuf-compiler libv8-dev libssl-dev libcairo2-dev
sudo apt-get install -y r-base gdal-bin python-gdal aria2 libpython-dev libudunits2-dev libgdal-dev libjq-dev libprotobuf-dev protobuf-compiler libv8-dev libssl-dev libcairo2-dev
On Ubuntu 16.04 LTS Xenial, the repositories ubuntugis and opencpu must be added before installing the packages:
-sudo add-apt-repository -y ppa:opencpu/jq
-sudo add-apt-repository -y ppa:ubuntugis/ubuntugis-unstable
-sudo apt-get update -q
sudo add-apt-repository -y ppa:opencpu/jq
+sudo add-apt-repository -y ppa:ubuntugis/ubuntugis-unstable
+sudo apt-get update -q
Installation was tested over Ubuntu 20.04 LTS focal and 18.04 LTS Bionic; non-LTS versions > 18.04 and Ubuntu 16.04 LTS Xenial should work. Other releases (Ubuntu non-LTS < 18.04; Ubuntu LTS ≤ 14.04) are not supported.
On Debian:
-sudo apt-get install -y r-base gdal-bin python-gdal aria2 libpython-dev libudunits2-dev libgdal-dev libjq-dev libprotobuf-dev protobuf-compiler libnode-dev libssl-dev libcairo2-dev proj-epsg
sudo apt-get install -y r-base gdal-bin python-gdal aria2 libpython-dev libudunits2-dev libgdal-dev libjq-dev libprotobuf-dev protobuf-compiler libnode-dev libssl-dev libcairo2-dev proj-epsg
Installation was tested over Debian 9 Stretch; older releases are not supported.
On Fedora:
-sudo yum install R gdal gdal-python aria2 python-devels gdal-devel proj-devel geos-devel udunits2-devel jq-devel protobuf-devel v8-devel openssl-devel cairo-devel libcurl-devel netcdf-devel libxml2-devel
sudo yum install R gdal gdal-python aria2 python-devels gdal-devel proj-devel geos-devel udunits2-devel jq-devel protobuf-devel v8-devel openssl-devel cairo-devel libcurl-devel netcdf-devel libxml2-devel
Installation was tested over Fedora 29.
On ArchLinux:
-sudo pacman -S --noconfirm r base-devel gcc-fortran python-gdal wget aria2 jq protobuf git
-cd /tmp; git clone https://aur.archlinux.org/gyp-git.git
-cd gyp-git; makepkg -si --noconfirm
-cd /tmp; git clone https://aur.archlinux.org/v8-3.14.git
-cd v8-3.14; makepkg -si --noconfirm
-cd /tmp; git clone https://aur.archlinux.org/udunits.git
-cd udunits; makepkg -si --noconfirm
sudo pacman -S --noconfirm r base-devel gcc-fortran python-gdal wget aria2 jq protobuf git
+cd /tmp; git clone https://aur.archlinux.org/gyp-git.git
+cd gyp-git; makepkg -si --noconfirm
+cd /tmp; git clone https://aur.archlinux.org/v8-3.14.git
+cd v8-3.14; makepkg -si --noconfirm
+cd /tmp; git clone https://aur.archlinux.org/udunits.git
+cd udunits; makepkg -si --noconfirm
Installation was tested on date 2018-11-21.
Before proceeding, it is suggested to update the existing R packages:
--update.packages(ask = FALSE)
+update.packages(ask = FALSE)
Doing that, the following warning could appear:
Warning in install.packages(update[instlib == l, "Package"], l, contriburl = contriburl, :
'lib = "/usr/lib/R/library"' is not writable
Would you like to use a personal library instead? (y/n)
If so, press y
and continue. Moreover, if no personal libraries already exist, it is asked to create a new one: ask y
and continue.
After that, the package can be installed from CRAN:
--install.packages("sen2r")
+install.packages("sen2r")
Alternatively, the development version can be installed from GitHub with the R package remotes. To do it:
install the package remotes, if missing:
--install.packages("remotes")
+install.packages("remotes")
load it and install sen2r:
--library(remotes) -install_github("ranghetti/sen2r")
+library(remotes)
+install_github("ranghetti/sen2r")
This will install the R package along with its package dependencies, containing all the functions necessary to preprocess data.
Finally, Sen2Cor can be installed from R:
--library(sen2r) -install_sen2cor()
+library(sen2r)
+install_sen2cor()
R must be installed before proceeding.
In the case it was already installed, it is suggested to update the existing R packages:
--update.packages(ask = FALSE)
+update.packages(ask = FALSE)
sen2r can be installed from CRAN:
--install.packages("sen2r")
+install.packages("sen2r")
Alternatively, the development version can be installed from GitHub with the R package remotes. To do it:
install the package remotes, if missing:
--install.packages("remotes")
+install.packages("remotes")
load it and install sen2r:
--library(remotes) -install_github("ranghetti/sen2r")
+library(remotes)
+install_github("ranghetti/sen2r")
This will install the R package along with its package dependencies, containing all the functions necessary to preprocess data.
@@ -276,27 +277,27 @@R must be installed before proceeding.
In the case it was already installed, it is suggested to update the existing R packages:
--update.packages(ask = FALSE)
+update.packages(ask = FALSE)
Packages can be installed using the compiled binaries, except from sp, sf, rgdal and rgeos, which are recommended to be compiled. To do it, use the command
--install.packages(c("sp", "sf", "rgdal", "rgeos"), type = "source")
+install.packages(c("sp", "sf", "rgdal", "rgeos"), type = "source")
after having installed GDAL as described above.
sen2r can be installed from CRAN:
--install.packages("sen2r")
+install.packages("sen2r")
Alternatively, the development version can be installed from GitHub with the R package remotes. To do it:
install the package remotes, if missing:
--install.packages("remotes")
+install.packages("remotes")
load it and install sen2r:
--library(remotes) -install_github("ranghetti/sen2r")
+library(remotes)
+install_github("ranghetti/sen2r")
This will install the R package along with its package dependencies, containing all the functions necessary to preprocess data.
@@ -304,15 +305,15 @@Sen2Cor is used to perform atmospheric correction of Sentinel-2 Level-1C products, so its installation can be skipped in case this function is not required by the user (using only Level-1C – TOA products or downloading directly Level-2A products).
+Sen2Cor is used to perform atmospheric correction of Sentinel-2 Level-1C products, so its installation can be skipped in case this function is not required by the user (using only Level-1C – TOA products or downloading directly Level-2A products).
It can be graphically checked / installed launching the function
--library(sen2r) -check_sen2r_deps()
+library(sen2r)
+check_sen2r_deps()
This function opens a GUI which help to check if this and other dependencies are satisfied; from this GUI a new Sen2Cor installation can be performed, or an existing environment can be linked to Sen2Cor.
Alternatively, it can be installed from the command line with the following function:
- +These dependences can be graphically checked launching the function
--library(sen2r) -check_sen2r_deps()
+library(sen2r)
+check_sen2r_deps()
Alternatively, they can be installed individually from the command line with the following functions (see their respective references for further details):
--check_gdal() -install_aria2()
+check_gdal()
+install_aria2()
if Homebrew is missing on your system, install it opening a terminal and typing:
-/usr/bin/ruby -e "$(curl -fsSL https://github.com/Homebrew/install/raw/master/install)"
/usr/bin/ruby -e "$(curl -fsSL https://github.com/Homebrew/install/raw/master/install)"
(see the Homebrew webpage for details);
install GDAL by typing:
-brew tap osgeo/osgeo4mac
-brew install osgeo-gdal-python
brew tap osgeo/osgeo4mac
+brew install osgeo-gdal-python
(see the OSGeo Homebrew webpage for details). At this step, an error could be returned in case another GDAL installation was already present; in this case, follow the instruction returned in the terminal to solve it (probably some packages must be unlinked with the instructions brew unlink <package>
).
Spectral indices are single band rasters computed from BOA (by default) or TOA images using function s2_calcindices()
(or the main function sen2r()
).
The list of the indices which can be computed can be seen in the GUI (fourth sheet). In the GUI, the index formula is usually graphically provided. In order to check the formula which is used for index computation, the function `list_indices()’ can be used. For example, the following command will return the formula of index NDVI:
--list_indices("s2_formula", "^NDVI$")
+list_indices("s2_formula", "^NDVI$")
## [1] "(band_8-band_4)/(band_8+band_4)"
See the function documentation for other examples.
The output type can be both floating (in this case, the actual index value is provided) or integer (default; in this case, values are multiplicated by a scaling factor, 10000 by default). So, if the user did not change the arguments outType
and scaleFactor
of function s2_calcindices()
, or index_datatype
of function sen2r()
, raster values will be multiplicated by 10000 respect to the “expected” index values.
Processing functions allows setting an output directory using the arguments path_out
, path_rgb
and path_indices
(sen2r()
) or outdir
(s2_translate()
, s2_merge()
, s2_mask()
, s2_rgb()
and s2_calcindices()
). These folders are automatically created if their parent directories exist.
By default, functions create a subfolder for each product / index / RGB type, in which files are stored. Each product subfolder includes a sub-subfolder named thumbnails
, which contains small JPEG or PNG images which can be used to rapidly monitor what was done (see s2_thumbnails()
for further details).
For example, the following command would produce the outputs listed below.
--json_path <- build_example_param_file() ++)+json_path <- build_example_param_file() out_dir_1 <- tempfile(pattern = "sen2r_out_1_") library(sen2r) @@ -301,7 +302,7 @@
json_path, timewindow = c("2019-07-13","2019-07-23"), path_out = out_dir_1 -)
[2020-02-06 09:42:40] #### Starting sen2r execution. ####
[2020-02-06 09:42:40] Searching for available SAFE products on SciHub...
[2020-02-06 09:42:46] Computing output names...
@@ -316,8 +317,8 @@
[2020-02-06 09:44:45] #### sen2r session terminated. ####
The processing chain can be re-launched with the command:
sen2r("/home/lranghetti/.sen2r/proc_par/s2proc_20200206_094240.json")
-
+
/tmp/RtmpUlAdHw/sen2r_out_1_a55119f4ed09
├── BOA
│ ├── S2A2A_20190713_022_sen2r_BOA_10.tif
@@ -426,8 +427,8 @@
In each of the 6 subfolders BOA
, MSAVI2
, NDVI
, RGB432B
, RGB843B
and SCL
5 products (one for each date) were created. Sub-subfolders thumbnails
contains thumbnail images.
Users can skip the creation of products’ subfolders setting the argument sen2r(..., path_subdirs = FALSE)
(default: TRUE
), or doing the same with the argument subdir
of other processing functions. The creation of thumbnails can be skipped using sen2r(..., thumbnails = FALSE)
(default: TRUE
). Both the options can be also set using the sen2r()
GUI.
For example, the following command would produce the outputs listed below.
-
-out_dir_2 <- tempfile(pattern = "sen2r_out_2_")
+
+out_dir_2 <- tempfile(pattern = "sen2r_out_2_")
sen2r(
json_path,
@@ -435,7 +436,7 @@
path_out = out_dir_2,
path_subdirs = FALSE,
thumbnails = FALSE
-)
+)
[2020-02-06 09:52:30] #### Starting sen2r execution. ####
[2020-02-06 09:52:30] Searching for available SAFE products on SciHub...
[2020-02-06 09:52:35] Computing output names...
@@ -452,8 +453,8 @@
[2020-02-06 09:54:16] #### sen2r session terminated. ####
The processing chain can be re-launched with the command:
sen2r("/home/lranghetti/.sen2r/proc_par/s2proc_20200206_095230.json")
-
+
/tmp/RtmpUlAdHw/sen2r_out_2_a5513ad348b0
├── S2A2A_20190713_022_sen2r_BOA_10.tif
├── S2A2A_20190713_022_sen2r_MSAVI2_10.tif
diff --git a/docs/articles/outstructure_files/anchor-sections-1.0/anchor-sections.css b/docs/articles/outstructure_files/anchor-sections-1.0/anchor-sections.css
new file mode 100644
index 00000000..07aee5fc
--- /dev/null
+++ b/docs/articles/outstructure_files/anchor-sections-1.0/anchor-sections.css
@@ -0,0 +1,4 @@
+/* Styles for section anchors */
+a.anchor-section {margin-left: 10px; visibility: hidden; color: inherit;}
+a.anchor-section::before {content: '#';}
+.hasAnchor:hover a.anchor-section {visibility: visible;}
diff --git a/docs/articles/outstructure_files/anchor-sections-1.0/anchor-sections.js b/docs/articles/outstructure_files/anchor-sections-1.0/anchor-sections.js
new file mode 100644
index 00000000..570f99a0
--- /dev/null
+++ b/docs/articles/outstructure_files/anchor-sections-1.0/anchor-sections.js
@@ -0,0 +1,33 @@
+// Anchor sections v1.0 written by Atsushi Yasumoto on Oct 3rd, 2020.
+document.addEventListener('DOMContentLoaded', function() {
+ // Do nothing if AnchorJS is used
+ if (typeof window.anchors === 'object' && anchors.hasOwnProperty('hasAnchorJSLink')) {
+ return;
+ }
+
+ const h = document.querySelectorAll('h1, h2, h3, h4, h5, h6');
+
+ // Do nothing if sections are already anchored
+ if (Array.from(h).some(x => x.classList.contains('hasAnchor'))) {
+ return null;
+ }
+
+ // Use section id when pandoc runs with --section-divs
+ const section_id = function(x) {
+ return ((x.classList.contains('section') || (x.tagName === 'SECTION'))
+ ? x.id : '');
+ };
+
+ // Add anchors
+ h.forEach(function(x) {
+ const id = x.id || section_id(x.parentElement);
+ if (id === '') {
+ return null;
+ }
+ let anchor = document.createElement('a');
+ anchor.href = '#' + id;
+ anchor.classList = ['anchor-section'];
+ x.classList.add('hasAnchor');
+ x.appendChild(anchor);
+ });
+});
diff --git a/docs/articles/outstructure_files/header-attrs-2.5/header-attrs.js b/docs/articles/outstructure_files/header-attrs-2.5/header-attrs.js
new file mode 100644
index 00000000..dd57d92e
--- /dev/null
+++ b/docs/articles/outstructure_files/header-attrs-2.5/header-attrs.js
@@ -0,0 +1,12 @@
+// Pandoc 2.9 adds attributes on both header and div. We remove the former (to
+// be compatible with the behavior of Pandoc < 2.8).
+document.addEventListener('DOMContentLoaded', function(e) {
+ var hs = document.querySelectorAll("div.section[class*='level'] > :first-child");
+ var i, h, a;
+ for (i = 0; i < hs.length; i++) {
+ h = hs[i];
+ if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6
+ a = h.attributes;
+ while (a.length > 0) h.removeAttribute(a[0].name);
+ }
+});
diff --git a/docs/articles/sen2r_cmd.html b/docs/articles/sen2r_cmd.html
index 30c3a446..669b396e 100644
--- a/docs/articles/sen2r_cmd.html
+++ b/docs/articles/sen2r_cmd.html
@@ -31,7 +31,7 @@
-# Set paths +-+# Set paths out_dir_1 <- tempfile(pattern = "sen2r_out_1_") # output folder -safe_dir_1 <- tempfile(pattern = "sen2r_safe_") # folder to store downloaded SAFE +safe_dir <- tempfile(pattern = "sen2r_safe_") # folder to store downloaded SAFE myextent_1 <- system.file("extdata/vector/barbellino.geojson", package = "sen2r") @@ -161,7 +162,7 @@
step_atmcorr = "l2a", extent = myextent_1, extent_name = "Barbellino", - timewindow = c(as.Date("2019-07-13"), as.Date("2019-07-25")), + timewindow = c(as.Date("2020-11-13"), as.Date("2020-11-25")), list_prods = c("BOA","SCL"), list_indices = c("NDVI","MSAVI2"), list_rgb = c("RGB432B"), @@ -169,17 +170,17 @@
max_mask = 10, path_l2a = safe_dir, path_out = out_dir_1 -)
[2020-02-05 10:53:53] #### Starting sen2r execution. #### -[2020-02-05 10:53:57] Searching for available SAFE products on SciHub... -[2020-02-05 10:54:02] Computing output names... -[2020-02-05 10:54:03] Processing group 1 of 5... -[2020-02-05 10:54:03] Starting to download the required level-2A SAFE products. -[2020-02-05 10:54:03] Check if products are available for download... -[2020-02-05 10:54:03] 1 Sentinel-2 images are already online. -[2020-02-05 10:54:03] Downloading Sentinel-2 image 1 of 1 - (S2A_MSIL2A_20190703T101031_N0212_R022_T32TNS_20190703T134349.SAFE)... -[2020-02-05 10:54:41] Download of level-2A SAFE products terminated. +)
[2020-11-27 16:59:58] #### Starting sen2r execution. ####
+[2020-11-27 16:59:59] Searching for available SAFE products on SciHub...
+[2020-11-27 17:00:10] Computing output names...
+Linking to GEOS 3.7.1, GDAL 2.2.3, PROJ 4.9.3
+[2020-11-27 17:00:11] Processing group 1 of 5...
+[2020-11-27 17:00:11] Starting to download the required level-2A SAFE products.
+[2020-11-27 17:00:11] Check if products are available for download...
+[2020-11-27 17:00:11] Downloading Sentinel-2 image 1 of 1
+ (S2A_MSIL2A_20201114T101301_N0214_R022_T32TNS_20201114T120346.SAFE)...
+[2020-11-27 17:00:59] Download of level-2A SAFE products terminated.
# (skipping most processing messages here)
After subsequent messages describing the processing operations which are being done, a report summarising the conducted processing is issued at the end:
@@ -188,65 +189,65 @@In this case, it shows that all the 5 S2 images satisfying the spatial-temporal query were downloaded and properly processed. However, outputs for two of those dates were not created because cloudiness over the spatial extent was above the specified threshold.
+In this case, it shows that all the 5 S2 images satisfying the spatial-temporal query were downloaded and properly processed.
S2 original SAFE images are stored in the folder specified by safe_dir
, and are not deleted after processing (unless the user sets also the argument rm_safe
to TRUE
).
-list.files(safe_dir)
[1] "S2A_MSIL2A_20190703T101031_N0212_R022_T32TNS_20190703T134349.SAFE"
-[2] "S2A_MSIL2A_20190706T102031_N0212_R065_T32TNS_20190706T134618.SAFE"
-[3] "S2A_MSIL2A_20190713T101031_N0213_R022_T32TNS_20190713T135651.SAFE"
-[4] "S2B_MSIL2A_20190708T101039_N0213_R022_T32TNS_20190708T133715.SAFE"
-[5] "S2B_MSIL2A_20190711T102029_N0213_R065_T32TNS_20190711T135545.SAFE"
+
+list.files(safe_dir)
[1] "S2A_MSIL2A_20201114T101301_N0214_R022_T32TNS_20201114T120346.SAFE"
+[2] "S2A_MSIL2A_20201117T102321_N0214_R065_T32TNS_20201117T130408.SAFE"
+[3] "S2A_MSIL2A_20201124T101341_N0214_R022_T32TNS_20201124T115339.SAFE"
+[4] "S2B_MSIL2A_20201119T101319_N0214_R022_T32TNS_20201119T120649.SAFE"
+[5] "S2B_MSIL2A_20201122T102339_N0214_R065_T32TNS_20201122T122607.SAFE"
Outputs are automatically subsetted and masked over the study area, and stored in appropriate subfolders of out_dir
.
-list.files(out_dir_1)
+list.files(out_dir_1)
[1] "BOA" "MSAVI2" "NDVI" "RGB432B" "SCL"
--list.files(file.path(out_dir_1, "NDVI"))
[1] "S2A2A_20190703_022_Barbellino_NDVI_10.tif"
-[2] "S2A2A_20190706_065_Barbellino_NDVI_10.tif"
-[3] "S2B2A_20190708_022_Barbellino_NDVI_10.tif" "thumbnails"
+
+list.files(file.path(out_dir_1, "NDVI"))
[1] "S2A2A_20201114_022_Barbellino_NDVI_10.tif"
+[2] "S2A2A_20201117_065_Barbellino_NDVI_10.tif"
+[3] "S2A2A_20201124_022_Barbellino_NDVI_10.tif"
+[4] "S2B2A_20201119_022_Barbellino_NDVI_10.tif"
+[5] "S2B2A_20201122_065_Barbellino_NDVI_10.tif"
+[6] "thumbnails"
See this vignette for more info about folder structure and naming conventions of sen2r()
outputs.
Users can set the desired parameters with the GUI, export them to a JSON file and run the command sen2r()
specifying the JSON path in the argument param_list
to specify processing options. For example, the command would launch sen2r()
using settings specified in file "myparams.json"
(or "file30ac6089ea3_sen2r_params.json"
in the reproducible case):
-# set the path to an existing JSON file +-+# set the path to an existing JSON file # (commented here, and substituted with an instruction that creates # a test JSON file) # json_path <- "/path/to/myparams.json" json_path_2 <- build_example_param_file() -json_path_2
-[1] "/tmp/RtmpDLx7qh/file30ac6089ea3_sen2r_params.json"
--out_paths_2 <- sen2r(param_list = json_path_2)[2020-02-05 11:58:09] #### Starting sen2r execution. #### -[2020-02-05 11:58:09] Searching for available SAFE products on SciHub... -[2020-02-05 11:58:12] Computing output names... -[2020-02-05 11:58:13] Starting to download the required level-2A SAFE products. -Images S2A_MSIL2A_20170703T101021_N0205_R022_T32TNS_20170703T101041.SAFE are -already on your system and will be skipped. Set "overwrite_safe" to TRUE to -re-download them. +json_path_2
[1] "/tmp/RtmpHUtF1k/file9a625065871c_sen2r_params.json"
+
+out_paths_2 <- sen2r(param_list = json_path_2)
[2020-11-27 17:25:23] #### Starting sen2r execution. ####
+[2020-11-27 17:25:23] Searching for available SAFE products on SciHub...
+[2020-11-27 17:25:26] Computing output names...
+[2020-11-27 17:25:28] Starting to download the required level-2A SAFE products.
# (skipping most processing messages here)
+
╔══════════════════════════════════════════════════════════════════════════════
║ sen2r Processing Report
╟──────────────────────────────────────────────────────────────────────────────
║ Dates to be processed based on processing parameters: 1
║ Processing completed for: all expected dates.
╚══════════════════════════════════════════════════════════════════════════════
-[2020-02-05 11:58:20] #### Execution of sen2r session terminated. ####
+[2020-11-27 17:26:43] #### sen2r session terminated. ####
The processing chain can be re-launched with the command:
- sen2r("/home/lb/.sen2r/proc_par/s2proc_20200205_115809.json")
+ sen2r("/home/lranghetti/.sen2r/proc_par/s2proc_20201127_172523.json")
This is for example particularly useful if a sen2r()
processing requires ordering images from the LTA archive (see https://scihub.copernicus.eu/userguide/LongTermArchive).
The user can in fact, in that case:
This allows users to use a previously saved JSON file as a “template” for a processing, but changing “manually” any desired parameter.
For example, the following instructions would execute the same processing as in the previous example, but changing both the extent and time window of the analysis.
--# use the previously saved JSON path -json_path_2
+# use the previously saved JSON path
+json_path_2
[1] "/tmp/RtmpDLx7qh/file30ac6089ea3_sen2r_params.json"
--out_dir_3 <- tempfile(pattern = "sen2r_out_3_") # new output folder ++)+out_dir_3 <- tempfile(pattern = "sen2r_out_3_") # new output folder myextent_3 <- system.file("extdata/vector/scalve.kml", package = "sen2r") @@ -276,9 +277,9 @@
param_list = json_path_2, extent = myextent_3, extent_name = "newxtent", - timewindow = c(as.Date("2019-01-01"), as.Date("2019-01-30")), + timewindow = c(as.Date("2020-10-01"), as.Date("2020-10-30")), path_out = out_dir_3 -)
This allows for example to easily run the same processing over different spatial/temporal extents.
The simplest way to use sen2r is to execute it in interactive mode. These commands will open the GUI provided with by function sen2r()
:
Note that the following error message could be returned:
Some missing packages are needed to run the GUI; please install them with the command
> install.packages(c("leaflet", "leafpm", "mapedit", "shiny", "shinyFiles", "shinydashboard", "shinyjs", "shinyWidgets"))
diff --git a/docs/articles/sen2r_gui_files/anchor-sections-1.0/anchor-sections.css b/docs/articles/sen2r_gui_files/anchor-sections-1.0/anchor-sections.css
new file mode 100644
index 00000000..07aee5fc
--- /dev/null
+++ b/docs/articles/sen2r_gui_files/anchor-sections-1.0/anchor-sections.css
@@ -0,0 +1,4 @@
+/* Styles for section anchors */
+a.anchor-section {margin-left: 10px; visibility: hidden; color: inherit;}
+a.anchor-section::before {content: '#';}
+.hasAnchor:hover a.anchor-section {visibility: visible;}
diff --git a/docs/articles/sen2r_gui_files/anchor-sections-1.0/anchor-sections.js b/docs/articles/sen2r_gui_files/anchor-sections-1.0/anchor-sections.js
new file mode 100644
index 00000000..570f99a0
--- /dev/null
+++ b/docs/articles/sen2r_gui_files/anchor-sections-1.0/anchor-sections.js
@@ -0,0 +1,33 @@
+// Anchor sections v1.0 written by Atsushi Yasumoto on Oct 3rd, 2020.
+document.addEventListener('DOMContentLoaded', function() {
+ // Do nothing if AnchorJS is used
+ if (typeof window.anchors === 'object' && anchors.hasOwnProperty('hasAnchorJSLink')) {
+ return;
+ }
+
+ const h = document.querySelectorAll('h1, h2, h3, h4, h5, h6');
+
+ // Do nothing if sections are already anchored
+ if (Array.from(h).some(x => x.classList.contains('hasAnchor'))) {
+ return null;
+ }
+
+ // Use section id when pandoc runs with --section-divs
+ const section_id = function(x) {
+ return ((x.classList.contains('section') || (x.tagName === 'SECTION'))
+ ? x.id : '');
+ };
+
+ // Add anchors
+ h.forEach(function(x) {
+ const id = x.id || section_id(x.parentElement);
+ if (id === '') {
+ return null;
+ }
+ let anchor = document.createElement('a');
+ anchor.href = '#' + id;
+ anchor.classList = ['anchor-section'];
+ x.classList.add('hasAnchor');
+ x.appendChild(anchor);
+ });
+});
diff --git a/docs/articles/sen2r_gui_files/header-attrs-2.5/header-attrs.js b/docs/articles/sen2r_gui_files/header-attrs-2.5/header-attrs.js
new file mode 100644
index 00000000..dd57d92e
--- /dev/null
+++ b/docs/articles/sen2r_gui_files/header-attrs-2.5/header-attrs.js
@@ -0,0 +1,12 @@
+// Pandoc 2.9 adds attributes on both header and div. We remove the former (to
+// be compatible with the behavior of Pandoc < 2.8).
+document.addEventListener('DOMContentLoaded', function(e) {
+ var hs = document.querySelectorAll("div.section[class*='level'] > :first-child");
+ var i, h, a;
+ for (i = 0; i < hs.length; i++) {
+ h = hs[i];
+ if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6
+ a = h.attributes;
+ while (a.length > 0) h.removeAttribute(a[0].name);
+ }
+});
diff --git a/docs/authors.html b/docs/authors.html
index f5ad3883..abfd3fc0 100644
--- a/docs/authors.html
+++ b/docs/authors.html
@@ -71,7 +71,7 @@
inst/CITATION
L. Ranghetti, M. Boschetti, F. Nutini, L. Busetto (2020). sen2r: An R toolbox for automatically downloading and preprocessing Sentinel-2 satellite data. Computers & Geosciences, 139, 104473. DOI: 10.1016/j.cageo.2020.104473, URL: http://sen2r.ranghetti.info/.
+L. Ranghetti, M. Boschetti, F. Nutini, L. Busetto (2020). sen2r: An R toolbox for automatically downloading and preprocessing Sentinel-2 satellite data. Computers & Geosciences, 139, 104473. doi: 10.1016/j.cageo.2020.104473, URL: http://sen2r.ranghetti.info/.
@Article{,
author = {Luigi Ranghetti and Mirco Boschetti and Francesco Nutini and Lorenzo Busetto},
title = {sen2r: An R toolbox for automatically downloading and preprocessing Sentinel-2 satellite data},
diff --git a/docs/index.html b/docs/index.html
index c44aac76..62b79be2 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -38,7 +38,7 @@
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).
sen2r was published on the ISI journal Computers & Geosciences; the manuscript is available here:
- +Users which processed Sentinel-2 data and used them for a scientific work are strongly encouraged to cite this publication within their work (see Credits).
The package can be installed from CRAN:
--install.packages("sen2r")
+install.packages("sen2r")
For detailed instructions about installing the package (including dependencies), see the Installation page.
A dockerised version of sen2r is available here. For detailed instructions about using it, see the page “Run in a Docker container”.
The simplest way to use sen2r is to execute it in interactive mode (see this vignette):
- + - -Alternatively, sen2r()
can be launched with a list of parameters (created with s2_gui()
) or passing manually the parameters as arguments of the function (see this vignette for further details).
Other specific functions can be used to run single steps separately. This is a list of the principal processing functions (the complete list can be found in the Reference page):
s2_order()
to order products from the Long Term Archive;sen2cor()
to correct level-1C products using Sen2Cor;sen2cor()
to correct level-1C products using Sen2Cor;
s2_mask()
to apply a cloud mask to Sentinel-2 products; sen2r is being developed by Luigi Ranghetti and Lorenzo Busetto (IREA-CNR), and it is released under the GNU General Public License version 3 (GPL‑3).
The sen2r logo, partially derived from the R logo, is released under the Creative Commons Attribution-ShareAlike 4.0 International license (CC-BY-SA 4.0).
To cite this library, please use the following entry:
-L. Ranghetti, M. Boschetti, F. Nutini, L. Busetto (2020). “sen2r: An R toolbox for automatically downloading and preprocessing Sentinel-2 satellite data”. Computers & Geosciences, 139, 104473. DOI: 10.1016/j.cageo.2020.104473, URL: http://sen2r.ranghetti.info.
-@Article{sen2r_cageo,
-title = {sen2r: An R toolbox for automatically downloading and preprocessing Sentinel-2 satellite data},
- author = {Luigi Ranghetti and Mirco Boschetti and Francesco Nutini and Lorenzo Busetto},
- journal = {Computers & Geosciences},
- year = {2020},
- volume = {139},
- pages = {104473},
- doi = {10.1016/j.cageo.2020.104473},
- url = {http://sen2r.ranghetti.info/},
- }
L. Ranghetti, M. Boschetti, F. Nutini, L. Busetto (2020). “sen2r: An R toolbox for automatically downloading and preprocessing Sentinel-2 satellite data”. Computers & Geosciences, 139, 104473. doi: 10.1016/j.cageo.2020.104473, URL: http://sen2r.ranghetti.info.
+@Article{sen2r_cageo,
+title = {sen2r: An R toolbox for automatically downloading and preprocessing Sentinel-2 satellite data},
+ author = {Luigi Ranghetti and Mirco Boschetti and Francesco Nutini and Lorenzo Busetto},
+ journal = {Computers & Geosciences},
+ year = {2020},
+ volume = {139},
+ pages = {104473},
+ doi = {10.1016/j.cageo.2020.104473},
+ url = {http://sen2r.ranghetti.info/},
+ }
NEWS.md
gdal_warp()
was partially rewritten: now reshaped rasters conserve square pixels also after warping operations. This change also affects sen2r()
products if reshaping features (reprojection or custom resolution) are required. This update was necessary due to changes performed in GDAL since version 3.2.0 (see OSGeo/gdal♯3294), which did not grant homogeneity between outputs produced with different GDAL versions. Note that, in case the user wants to update an existing sen2r archive produced with sen2r < 1.4.0, the old existing grid is maintained so that product grids are equal (in order to produce outputs with the new grid, users must create a new archive).s2_download()
is no more able to use existing products equivalent to found ones.s2_download()
no more uses existing SAFE products instead than downloading new equivalent ones (this in order to manage images split in two SAFE archives).service
to s2_list()
and s2_download()
for using "dhus"
API service instead of default "apihub"
(this could be useful in case of apihub
downtimes).kill_errored
to sen2cor()
(see documentation).build_example_param_file()
now generates more recent images, 2020-08-01 instead than 2019-07-23 (this because the previous ones required two SAFE which are now on LTA); the same was done for some tests.CLD
, SNW
, AOT
, WVP
(see documentation for description). The GUI and internal functions were modified to support their selection and generation.Rcc
, Gcc
, Bcc
) and Excess Green (ExG
) (#330).paths.json
).leaflet
, leafpm
, mapedit
, shiny
, shinyFiles
, shinydashboard
, shinyjs
, shinyWidgets
) are now suggested dependencies. In the case they are missing and the user tries to run the GUI, an error is returned with the command for installing them.sen2r
installation over Ubuntu Focal.gdalUtil()
: function used to perform GDAL operations, calling C-based GDAL utilities using sf::gdal_utils()
, and Python-based ones through system calls (a standalone GDAL environment is request to do it, as it was in previous versions).
rgdal
is now an explicit dependency (this because it is used by raster
but it is not a mandatory dependency).
sf
(see gdalUtil()
). This allows reducing the use of external runtime dependencies.sys
is installed (#257).*_ignorelist.txt
and *_cloudlist.txt
) were created in the directory of the parameter file (if existing) and used, during subsequent sen2r()
executions, in order not to try reprocessing images cloud covered or failed for some reason. Now these files were replaced with an hidden TOML file .ignorelist.txt
containing the list of base names of non-produced files and the dates of cloud covered images. This file is placed in the output folder, so to be linked with the produced archive. The usefulness of this edit is twofold:
RcppTOML
(used to manage TOML ignore list TOML file).shiny*
and leaflet*
dependencies to suggested (this will be done in a future release).dhus
or apihub
(experimental).GET()
calls with RETRY()
, so to avoid errors in case of temporary unavailability of services.sen2r()
defaults.max_mask
- mask_type
coherence (if max_mask < 100
and mask_type
is not specified, a warning is returned).use_python
argument in sen2r()
was deprecated (no longer needed).safelist
class for lists of SAFE Sentinel-2 archives (see safelist-class);as()
methods can be used to convert safelist
from/to character
, data.frame
and data.table
(as well as as.character()',
as.data.frame()and
as.data.table()` functions).safe_getMetadata()
: new arguments format
, simplify
and allow_oldnames
(see the function reference for details);safe_shortname()
: arguments tiles
, force_tiles
, set.seed
and multiple_names
were deprecated, since they are not used with SAFE compact names (old names are no more supported);
Sys.setenv()
effects now do not affect the R environment after exiting from sen2r() execution;sen2r
was accepted on CRAN (2019-10-21, version 1.1.0). From now, it is possible to install the CRAN version with the following command:
-install.packages("sen2r")
+
+install.packages("sen2r")
The development version – which may contain updated features – can still be installed with the following command:
--remotes::install_packages_github("ranghetti/sen2r")
+
+remotes::install_packages_github("ranghetti/sen2r")
"list_prods"
argument in sen2r()
is NULL instead of 'BOA'
.'no'
value for argument "step_atmcorr"
in sen2r()
(use 'l2a'
without selecting any L2A products instead).sen2r
package directory is no more used to store files, but a subfolder .sen2r
of the user Home directory is created and used. In this way, reinstalling sen2r will not require anymore to reinstall runtime dependencies / to reconfigure the package. The permission to write on this folder is asked to the user when the package is loaded for the first time.s2_calcindices()
: now internal raster routines are used by default instead than gdal_calc.py
, allowing reducing RAM usage and computation time.sen2r_getElements()
was rewritten in order to: 1) avoid a RAM leak present in the function, which was causing a high RAM use in the first part of the execution of sen2r()
; 2) considerably speed up the execution (now the metadata of 100 files is retrieved in 4 milliseconds instead than 80).This is an improvement of version 0.3.2, with several fixes and improvements.
-log
of function sen2r()
)s2_dop()
to know the Dates Of Passage over orbitsL. Ranghetti, M. Boschetti, F. Nutini, L. Busetto (2020). "sen2r": An R toolbox for automatically downloading and preprocessing -Sentinel-2 satellite data. Computers & Geosciences, 139, 104473. DOI: -10.1016/j.cageo.2020.104473, -URL: http://sen2r.ranghetti.info/.
+Sentinel-2 satellite data. Computers & Geosciences, 139, 104473. +doi: 10.1016/j.cageo.2020.104473 +, URL: http://sen2r.ranghetti.info/.Luigi Ranghetti, phD (2017) luigi.ranghetti@gmail.com
diff --git a/docs/reference/add_rgb_image.html b/docs/reference/add_rgb_image.html index efc2c15e..2039d575 100644 --- a/docs/reference/add_rgb_image.html +++ b/docs/reference/add_rgb_image.html @@ -72,7 +72,7 @@L. Ranghetti, M. Boschetti, F. Nutini, L. Busetto (2020). "sen2r": An R toolbox for automatically downloading and preprocessing -Sentinel-2 satellite data. Computers & Geosciences, 139, 104473. DOI: -10.1016/j.cageo.2020.104473, -URL: http://sen2r.ranghetti.info/.
+Sentinel-2 satellite data. Computers & Geosciences, 139, 104473. +doi: 10.1016/j.cageo.2020.104473 +, URL: http://sen2r.ranghetti.info/.Luigi Ranghetti, phD (2019) luigi@ranghetti.info
diff --git a/docs/reference/add_tile_suffix.html b/docs/reference/add_tile_suffix.html index a0ac4e1f..8c872fa0 100644 --- a/docs/reference/add_tile_suffix.html +++ b/docs/reference/add_tile_suffix.html @@ -76,7 +76,7 @@extract_tile_suffix()
extracts suffixes from input paths.
add_tile_suffix(paths, suffix) +add_tile_suffix(paths, suffix) -remove_tile_suffix(paths) +remove_tile_suffix(paths) -extract_tile_suffix(paths)+extract_tile_suffix(paths)