From b19c0a42c7861b33a401ab1f252ac1168dfeb6c8 Mon Sep 17 00:00:00 2001 From: Luigi Ranghetti <6874239+ranghetti@users.noreply.github.com> Date: Fri, 8 Jan 2021 07:42:15 +0100 Subject: [PATCH] Version 1.4.0 RC (#367) ## 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). ## Documentation - Update vignette data (granting using online data) (#360). --- DESCRIPTION | 3 +- NEWS.md | 38 +++ R/abs2rel.R | 5 +- R/add_rgb_image.R | 5 +- R/add_tile_suffix.R | 5 +- R/build_example_param_file.R | 5 +- R/calcindex.R | 7 +- R/check_gdal.R | 5 +- R/check_gui_deps.R | 5 +- R/check_param_list.R | 5 +- R/check_sen2r_deps.R | 5 +- R/compute_s2_paths.R | 5 +- R/comsub.R | 5 +- R/create_indices_db.R | 10 +- R/create_s2_dop.R | 5 +- R/expand_path.R | 10 +- R/expect_equal_crs.R | 5 +- R/fix_envi_format.R | 5 +- R/gdalUtil.R | 17 +- R/gdal_abs2rel.R | 5 +- R/gdal_warp.R | 252 +++++++++--------- R/gdalwarp_grid.R | 13 +- R/gipp.R | 12 +- R/give_write_permission.R | 7 +- R/helpers_extent.R | 5 +- R/ignorelist.R | 5 +- R/init_python.R | 5 +- R/install_aria2.R | 5 +- R/install_sen2cor.R | 9 +- R/list_indices.R | 5 +- R/load_binpaths.R | 7 +- R/mountpoint.R | 5 +- R/nn.R | 5 +- R/path_check.R | 2 +- R/print_message.R | 5 +- R/projpar.R | 5 +- R/raster_metadata.R | 5 +- R/s2_calcindices.R | 10 +- R/s2_dop.R | 5 +- R/s2_download.R | 25 +- R/s2_gui.R | 7 +- R/s2_list.R | 9 +- R/s2_mask.R | 14 +- R/s2_merge.R | 5 +- R/s2_order.R | 7 +- R/s2_rgb.R | 11 +- R/s2_thumbnails.R | 15 +- R/s2_tiles.R | 5 +- R/s2_translate.R | 5 +- R/safe_getMetadata.R | 5 +- R/safe_is_online.R | 7 +- R/safe_shortname.R | 5 +- R/safelist-class.R | 5 +- R/scihub_login.R | 7 +- R/sen2cor.R | 11 +- R/sen2r.R | 74 +++-- R/sen2r_getElements.R | 5 +- R/sen2r_process_report.R | 7 +- R/smooth_mask.R | 5 +- R/st_as_text_2.R | 34 +-- R/st_crs2.R | 5 +- R/str_pad2.R | 5 +- R/tiles_intersects.R | 5 +- R/trace_functions.R | 5 +- README.Rmd | 8 +- README.md | 100 ++++--- cran-comments.md | 21 +- docs/404.html | 2 +- docs/CODE-OF-CONDUCT.html | 2 +- docs/ISSUE_TEMPLATE.html | 189 +++++++++++++ docs/LICENSE.html | 40 +-- docs/articles/docker.html | 15 +- .../anchor-sections-1.0/anchor-sections.css | 4 + .../anchor-sections-1.0/anchor-sections.js | 33 +++ .../header-attrs-2.5/header-attrs.js | 12 + docs/articles/index.html | 2 +- docs/articles/installation.html | 131 ++++----- .../anchor-sections-1.0/anchor-sections.css | 4 + .../anchor-sections-1.0/anchor-sections.js | 33 +++ .../header-attrs-2.5/header-attrs.js | 12 + docs/articles/outstructure.html | 29 +- .../anchor-sections-1.0/anchor-sections.css | 4 + .../anchor-sections-1.0/anchor-sections.js | 33 +++ .../header-attrs-2.5/header-attrs.js | 12 + docs/articles/sen2r_cmd.html | 117 ++++---- .../anchor-sections-1.0/anchor-sections.css | 4 + .../anchor-sections-1.0/anchor-sections.js | 33 +++ .../header-attrs-2.5/header-attrs.js | 12 + docs/articles/sen2r_gui.html | 11 +- .../anchor-sections-1.0/anchor-sections.css | 4 + .../anchor-sections-1.0/anchor-sections.js | 33 +++ .../header-attrs-2.5/header-attrs.js | 12 + docs/authors.html | 4 +- docs/index.html | 54 ++-- docs/news/index.html | 153 +++++++---- docs/pkgdown.yml | 4 +- docs/reference/Rplot003.png | Bin 0 -> 11613 bytes docs/reference/Rplot004.png | Bin 0 -> 122522 bytes docs/reference/Rplot005.png | Bin 0 -> 218714 bytes docs/reference/Rplot006.png | Bin 0 -> 216983 bytes docs/reference/abs2rel.html | 8 +- docs/reference/add_rgb_image.html | 8 +- docs/reference/add_tile_suffix.html | 26 +- docs/reference/build_example_param_file.html | 10 +- docs/reference/calcindex.html | 8 +- docs/reference/check_gdal.html | 8 +- docs/reference/check_gui_deps.html | 8 +- docs/reference/check_param_list.html | 8 +- docs/reference/check_sen2r_deps.html | 8 +- docs/reference/compute_s2_paths.html | 8 +- docs/reference/comsub.html | 8 +- docs/reference/create_indices_db.html | 8 +- docs/reference/create_s2_dop.html | 8 +- docs/reference/dontuse.html | 2 +- docs/reference/expand_path.html | 8 +- docs/reference/expect_equal_crs.html | 8 +- docs/reference/fix_envi_format.html | 8 +- docs/reference/gdalUtil-1.png | Bin 4831 -> 47070 bytes docs/reference/gdalUtil-2.png | Bin 14542 -> 14806 bytes docs/reference/gdalUtil-3.png | Bin 10765 -> 9725 bytes docs/reference/gdalUtil.html | 26 +- docs/reference/gdal_abs2rel_rel2abs.html | 8 +- docs/reference/gdal_warp-1.png | Bin 48211 -> 48529 bytes docs/reference/gdal_warp-2.png | Bin 13631 -> 14175 bytes docs/reference/gdal_warp-3.png | Bin 64940 -> 61304 bytes docs/reference/gdal_warp-4.png | Bin 77765 -> 76411 bytes docs/reference/gdal_warp.html | 66 ++--- docs/reference/gdalwarp_grid-1.png | Bin 4831 -> 13842 bytes docs/reference/gdalwarp_grid.html | 20 +- docs/reference/gipp.html | 8 +- docs/reference/gipp_init.html | 8 +- docs/reference/give_write_permission.html | 10 +- docs/reference/ignorelist.html | 8 +- docs/reference/index.html | 2 +- docs/reference/init_python.html | 8 +- docs/reference/install_aria2.html | 8 +- docs/reference/install_sen2cor.html | 12 +- docs/reference/list_indices.html | 16 +- docs/reference/load_binpaths.html | 8 +- docs/reference/load_extent.html | 8 +- docs/reference/mountpoint.html | 8 +- docs/reference/nn.html | 8 +- docs/reference/normalize_path.html | 8 +- docs/reference/path_check.html | 4 +- docs/reference/print_message.html | 8 +- docs/reference/projpar.html | 12 +- docs/reference/raster2rgb.html | 8 +- docs/reference/raster_metadata.html | 22 +- docs/reference/s2_calcindices-1.png | Bin 4831 -> 14476 bytes docs/reference/s2_calcindices.html | 21 +- docs/reference/s2_defNA.html | 2 +- docs/reference/s2_dop.html | 61 ++--- docs/reference/s2_download.html | 10 +- docs/reference/s2_gui.html | 8 +- docs/reference/s2_list.html | 10 +- docs/reference/s2_mask-1.png | Bin 4831 -> 13658 bytes docs/reference/s2_mask.html | 25 +- docs/reference/s2_merge.html | 8 +- docs/reference/s2_order.html | 20 +- docs/reference/s2_rgb-1.png | Bin 18643 -> 19484 bytes docs/reference/s2_rgb.html | 24 +- docs/reference/s2_thumbnails.html | 8 +- docs/reference/s2_tiles.html | 12 +- docs/reference/s2_translate.html | 8 +- docs/reference/safe_getMetadata.html | 8 +- docs/reference/safe_is_online.html | 10 +- docs/reference/safe_shortname.html | 36 +-- docs/reference/safelist-class.html | 8 +- docs/reference/scihub_login.html | 10 +- docs/reference/sen2cor.html | 14 +- docs/reference/sen2r-1.png | Bin 11738 -> 12612 bytes docs/reference/sen2r-2.png | Bin 16945 -> 18877 bytes docs/reference/sen2r-3.png | Bin 16009 -> 17721 bytes docs/reference/sen2r-4.png | Bin 857001 -> 859055 bytes docs/reference/sen2r-5.png | Bin 1597970 -> 1601993 bytes docs/reference/sen2r-6.png | Bin 1515318 -> 1518233 bytes docs/reference/sen2r.html | 114 ++++---- docs/reference/sen2r_getElements.html | 8 +- docs/reference/sen2r_process_report.html | 10 +- docs/reference/smooth_mask.html | 8 +- docs/reference/st_as_text_2.html | 4 +- docs/reference/st_crs2.html | 8 +- docs/reference/stack2rgb.html | 8 +- docs/reference/str_pad2.html | 8 +- docs/reference/suppress_warnings.html | 2 +- docs/reference/tiles_intersects.html | 8 +- docs/reference/trace_function.html | 8 +- index.Rmd | 8 +- index.md | 95 ++++--- inst/CITATION | 2 +- inst/extdata/settings/indices.json | 4 +- man/abs2rel.Rd | 5 +- man/add_rgb_image.Rd | 5 +- man/add_tile_suffix.Rd | 5 +- man/build_example_param_file.Rd | 5 +- man/calcindex.Rd | 5 +- man/check_gdal.Rd | 5 +- man/check_gui_deps.Rd | 5 +- man/check_param_list.Rd | 5 +- man/check_sen2r_deps.Rd | 5 +- man/compute_s2_paths.Rd | 5 +- man/comsub.Rd | 5 +- man/create_indices_db.Rd | 5 +- man/create_s2_dop.Rd | 5 +- man/expand_path.Rd | 5 +- man/expect_equal_crs.Rd | 5 +- man/fix_envi_format.Rd | 5 +- man/gdalUtil.Rd | 17 +- man/gdal_abs2rel_rel2abs.Rd | 5 +- man/gdal_warp.Rd | 33 ++- man/gdalwarp_grid.Rd | 13 +- man/gipp.Rd | 5 +- man/gipp_init.Rd | 5 +- man/give_write_permission.Rd | 7 +- man/ignorelist.Rd | 5 +- man/init_python.Rd | 5 +- man/install_aria2.Rd | 5 +- man/install_sen2cor.Rd | 9 +- man/list_indices.Rd | 5 +- man/load_binpaths.Rd | 5 +- man/load_extent.Rd | 5 +- man/mountpoint.Rd | 5 +- man/nn.Rd | 5 +- man/normalize_path.Rd | 5 +- man/path_check.Rd | 2 +- man/print_message.Rd | 5 +- man/projpar.Rd | 5 +- man/raster2rgb.Rd | 5 +- man/raster_metadata.Rd | 5 +- man/s2_calcindices.Rd | 10 +- man/s2_dop.Rd | 5 +- man/s2_download.Rd | 7 +- man/s2_gui.Rd | 5 +- man/s2_list.Rd | 7 +- man/s2_mask.Rd | 14 +- man/s2_merge.Rd | 5 +- man/s2_order.Rd | 7 +- man/s2_rgb.Rd | 11 +- man/s2_thumbnails.Rd | 5 +- man/s2_tiles.Rd | 5 +- man/s2_translate.Rd | 5 +- man/safe_getMetadata.Rd | 5 +- man/safe_is_online.Rd | 7 +- man/safe_shortname.Rd | 5 +- man/safelist-class.Rd | 5 +- man/scihub_login.Rd | 7 +- man/sen2cor.Rd | 11 +- man/sen2r.Rd | 31 ++- man/sen2r_getElements.Rd | 5 +- man/sen2r_process_report.Rd | 7 +- man/smooth_mask.Rd | 5 +- man/st_crs2.Rd | 5 +- man/stack2rgb.Rd | 5 +- man/str_pad2.Rd | 5 +- man/tiles_intersects.Rd | 5 +- man/trace_function.Rd | 5 +- tests/testthat/test-gdal_warp.R | 75 +++--- tests/testthat/test-sen2r-02_warp.R | 4 +- utils/code/gdal_formats_db.R | 5 +- vignettes/installation.Rmd | 6 +- vignettes/sen2r_cmd.Rmd | 73 +++-- 261 files changed, 2048 insertions(+), 1534 deletions(-) create mode 100644 docs/ISSUE_TEMPLATE.html create mode 100644 docs/articles/docker_files/anchor-sections-1.0/anchor-sections.css create mode 100644 docs/articles/docker_files/anchor-sections-1.0/anchor-sections.js create mode 100644 docs/articles/docker_files/header-attrs-2.5/header-attrs.js create mode 100644 docs/articles/installation_files/anchor-sections-1.0/anchor-sections.css create mode 100644 docs/articles/installation_files/anchor-sections-1.0/anchor-sections.js create mode 100644 docs/articles/installation_files/header-attrs-2.5/header-attrs.js create mode 100644 docs/articles/outstructure_files/anchor-sections-1.0/anchor-sections.css create mode 100644 docs/articles/outstructure_files/anchor-sections-1.0/anchor-sections.js create mode 100644 docs/articles/outstructure_files/header-attrs-2.5/header-attrs.js create mode 100644 docs/articles/sen2r_cmd_files/anchor-sections-1.0/anchor-sections.css create mode 100644 docs/articles/sen2r_cmd_files/anchor-sections-1.0/anchor-sections.js create mode 100644 docs/articles/sen2r_cmd_files/header-attrs-2.5/header-attrs.js create mode 100644 docs/articles/sen2r_gui_files/anchor-sections-1.0/anchor-sections.css create mode 100644 docs/articles/sen2r_gui_files/anchor-sections-1.0/anchor-sections.js create mode 100644 docs/articles/sen2r_gui_files/header-attrs-2.5/header-attrs.js create mode 100644 docs/reference/Rplot003.png create mode 100644 docs/reference/Rplot004.png create mode 100644 docs/reference/Rplot005.png create mode 100644 docs/reference/Rplot006.png 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) + [![CRAN @@ -23,7 +29,10 @@ Covenant](https://img.shields.io/badge/Contributor%20Covenant-v1.4%20adopted-ff6 # sen2r: Find, Download and Process Sentinel-2 Data -sen2r +sen2r is an R library which helps to download and preprocess Sentinel-2 optical images. The purpose of the functions contained in the library is to provide the instruments required to easily perform (and eventually @@ -31,28 +40,32 @@ automate) all the steps necessary to build a complete Sentinel-2 processing chain, without the need of any manual intervention nor the needing to manually integrate any external tool. -In particular, -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() -

Alternatively, @@ -142,23 +158,22 @@ 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_list()`](http://sen2r.ranghetti.info/reference/s2_list.html) to +- [`s2_list()`](http://sen2r.ranghetti.info/reference/s2_list.html) to retrieve the list of available Sentinel-2 products based on input parameters; - - [`s2_download()`](http://sen2r.ranghetti.info/reference/s2_download.html) +- [`s2_download()`](http://sen2r.ranghetti.info/reference/s2_download.html) to download Sentinel-2 products; - - [`s2_order()`](http://sen2r.ranghetti.info/reference/s2_order.html) +- [`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/); - - [`s2_mask()`](http://sen2r.ranghetti.info/reference/s2_mask.html) to +- [`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) to +- [`s2_rgb()`](http://sen2r.ranghetti.info/reference/s2_rgb.html) to generate RGB images from Sentinel-2 Surface Reflectance multiband - raster - files; - - [`s2_calcindices()`](http://sen2r.ranghetti.info/reference/s2_calcindices.html) + raster files; +- [`s2_calcindices()`](http://sen2r.ranghetti.info/reference/s2_calcindices.html) to compute maps of spectral indices from Sentinel-2 Surface Reflectance multiband raster files. @@ -170,14 +185,19 @@ details). -sen2r +sen2r is being developed by Luigi Ranghetti and Lorenzo Busetto ([IREA-CNR](http://www.irea.cnr.it)), and it is released under the [GNU -General Public License -version 3](https://www.gnu.org/licenses/gpl-3.0.html) (GPL‑3). +General Public License version +3](https://www.gnu.org/licenses/gpl-3.0.html) (GPL‑3). -The -[sen2r +The [sen2r logo](https://github.com/ranghetti/sen2r/raw/master/man/figures/sen2r_logo_200px.png), partially derived from the [R logo](https://www.r-project.org/logo), is released under the [Creative Commons Attribution-ShareAlike 4.0 @@ -188,7 +208,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: +satellite data”**. *Computers & Geosciences*, 139, 104473. doi: 10.1016/j.cageo.2020.104473, URL: http://sen2r.ranghetti.info. diff --git a/cran-comments.md b/cran-comments.md index d8bd0a84..83b6f64d 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -1,11 +1,20 @@ -# sen2r v. 1.3.9 +# sen2r v. 1.4.0 ## Test environments -* [local installation] Ubuntu 18.04, 64 bit, R 3.6.3 -* [local installation] Archlinux, 64 bit, R 4.0.2 -* [local installation] Windows 10, 64 bit, R 3.6.3 -* [travis-ci] Ubuntu 16.04.6 LTS, 64 bit, R unstable, 4.0.0 and 3.6.3 (devel, release and oldrelease) -* [win-builder] R unstable, 4.0.2 and 3.6.3 (devel, release and oldrelease) +* [local installation] Ubuntu 18.04, 64 bit, R 4.0.3 +* [local installation] Archlinux, 64 bit, R 4.0.3 +* [local installation] Windows 10, 64 bit, R 4.0.3 +* [win-builder] R unstable, 4.0.3 and 3.6.3 (devel, release and oldrelease) ## R CMD check results There were no ERRORs, WARNINGs or NOTEs. + + +## CRAN review +> The auto-check found additional issues for the *last* version released on CRAN: + M1mac +CRAN incoming checks do not test for these additional issues and you will need +an appropriately instrumented build of R to reproduce these. +Hence please reply-all and explain: Have these been fixed? + +All the errors found in M1mac were fixed (see the NEWS.md file for details). diff --git a/docs/404.html b/docs/404.html index 2df9b140..c7c721db 100644 --- a/docs/404.html +++ b/docs/404.html @@ -71,7 +71,7 @@ sen2r - 1.3.9 + 1.4.0 diff --git a/docs/CODE-OF-CONDUCT.html b/docs/CODE-OF-CONDUCT.html index 54d3a19e..3243a210 100644 --- a/docs/CODE-OF-CONDUCT.html +++ b/docs/CODE-OF-CONDUCT.html @@ -71,7 +71,7 @@ sen2r - 1.3.9 + 1.4.0 diff --git a/docs/ISSUE_TEMPLATE.html b/docs/ISSUE_TEMPLATE.html new file mode 100644 index 00000000..3555e7c5 --- /dev/null +++ b/docs/ISSUE_TEMPLATE.html @@ -0,0 +1,189 @@ + + + + + + + + + • sen2r + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + +
+ +
+
+ + + + +
+ + + +
+ + + +
+ + +
+

Site built with pkgdown 1.6.1.

+
+ +
+
+ + + + + + + + diff --git a/docs/LICENSE.html b/docs/LICENSE.html index 83cd6e2e..4949052f 100644 --- a/docs/LICENSE.html +++ b/docs/LICENSE.html @@ -71,7 +71,7 @@ sen2r - 1.3.9 + 1.4.0 @@ -351,27 +351,27 @@

How to Apply These Terms to Your New Programs

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:

-
sen2r Copyright (C) 2019 Luigi Ranghetti, Lorenzo Busetto
-This program comes with ABSOLUTELY NO WARRANTY; for details type 'show w'.
-This is free software, and you are welcome to redistribute it
-under certain conditions; type 'show c' for details.
+
sen2r Copyright (C) 2019 Luigi Ranghetti, Lorenzo Busetto
+This program comes with ABSOLUTELY NO WARRANTY; for details type 'show w'.
+This is free software, and you are welcome to redistribute it
+under certain conditions; type 'show c' for details.

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 @@ sen2r - 1.3.9 + 1.4.0 @@ -106,7 +106,8 @@ -
+ +
diff --git a/docs/articles/docker_files/anchor-sections-1.0/anchor-sections.css b/docs/articles/docker_files/anchor-sections-1.0/anchor-sections.css new file mode 100644 index 00000000..07aee5fc --- /dev/null +++ b/docs/articles/docker_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/docker_files/anchor-sections-1.0/anchor-sections.js b/docs/articles/docker_files/anchor-sections-1.0/anchor-sections.js new file mode 100644 index 00000000..570f99a0 --- /dev/null +++ b/docs/articles/docker_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/docker_files/header-attrs-2.5/header-attrs.js b/docs/articles/docker_files/header-attrs-2.5/header-attrs.js new file mode 100644 index 00000000..dd57d92e --- /dev/null +++ b/docs/articles/docker_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/index.html b/docs/articles/index.html index 7085fdce..22370713 100644 --- a/docs/articles/index.html +++ b/docs/articles/index.html @@ -71,7 +71,7 @@ sen2r - 1.3.9 + 1.4.0
diff --git a/docs/articles/installation.html b/docs/articles/installation.html index 0035bdf7..bc3a40e0 100644 --- a/docs/articles/installation.html +++ b/docs/articles/installation.html @@ -31,7 +31,7 @@ sen2r - 1.3.9 + 1.4.0
@@ -106,7 +106,8 @@ -
+ +
@@ -250,23 +251,23 @@

On Windows

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:

- +

Alternatively, the development version can be installed from GitHub with the R package remotes. To do it:

  1. install the package remotes, if missing:

    -
    -install.packages("remotes")
    +
    +install.packages("remotes")
  2. 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 @@

On MacOS

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:

- +

Alternatively, the development version can be installed from GitHub with the R package remotes. To do it:

  1. install the package remotes, if missing:

    -
    -install.packages("remotes")
    +
    +install.packages("remotes")
  2. 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 @@

Installing Sen2Cor

-

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

- +

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:

- +

@@ -325,13 +326,13 @@

aria2 is an alternative downloader which can be used to faster the download of SAFE archives; it can be optionally installed and used. Since the number of concurrent downloads from ESA SciHub is limited to 2, the use of aria2 is generally not faster than the default downloader; for this reason, its use is recommended only in case of problems with the default downloader.

These dependences can be graphically checked launching the function

- +

Alternatively, they can be installed individually from the command line with the following functions (see their respective references for further details):

- +

Note on GDAL installation on MacOS

@@ -339,13 +340,13 @@

  1. 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);

  2. 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>).

diff --git a/docs/articles/installation_files/anchor-sections-1.0/anchor-sections.css b/docs/articles/installation_files/anchor-sections-1.0/anchor-sections.css new file mode 100644 index 00000000..07aee5fc --- /dev/null +++ b/docs/articles/installation_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/installation_files/anchor-sections-1.0/anchor-sections.js b/docs/articles/installation_files/anchor-sections-1.0/anchor-sections.js new file mode 100644 index 00000000..570f99a0 --- /dev/null +++ b/docs/articles/installation_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/installation_files/header-attrs-2.5/header-attrs.js b/docs/articles/installation_files/header-attrs-2.5/header-attrs.js new file mode 100644 index 00000000..dd57d92e --- /dev/null +++ b/docs/articles/installation_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/outstructure.html b/docs/articles/outstructure.html index 79227653..b3730972 100644 --- a/docs/articles/outstructure.html +++ b/docs/articles/outstructure.html @@ -31,7 +31,7 @@ sen2r - 1.3.9 + 1.4.0

@@ -106,7 +106,8 @@ -
+ +
@@ -106,7 +106,8 @@ -
+ +

Load processing parameters from a previously saved JSON file

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:

    @@ -263,12 +264,12 @@

    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.

diff --git a/docs/articles/sen2r_cmd_files/anchor-sections-1.0/anchor-sections.css b/docs/articles/sen2r_cmd_files/anchor-sections-1.0/anchor-sections.css new file mode 100644 index 00000000..07aee5fc --- /dev/null +++ b/docs/articles/sen2r_cmd_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_cmd_files/anchor-sections-1.0/anchor-sections.js b/docs/articles/sen2r_cmd_files/anchor-sections-1.0/anchor-sections.js new file mode 100644 index 00000000..570f99a0 --- /dev/null +++ b/docs/articles/sen2r_cmd_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_cmd_files/header-attrs-2.5/header-attrs.js b/docs/articles/sen2r_cmd_files/header-attrs-2.5/header-attrs.js new file mode 100644 index 00000000..dd57d92e --- /dev/null +++ b/docs/articles/sen2r_cmd_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_gui.html b/docs/articles/sen2r_gui.html index 20097b9a..f7e7309e 100644 --- a/docs/articles/sen2r_gui.html +++ b/docs/articles/sen2r_gui.html @@ -31,7 +31,7 @@ sen2r - 1.3.9 + 1.4.0
@@ -106,7 +106,8 @@ -
+ +
@@ -155,7 +155,7 @@

Citation

Source: 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 @@
       
       
         sen2r
-        1.3.9
+        1.4.0
       
     
@@ -116,7 +116,18 @@
- + +

diff --git a/docs/news/index.html b/docs/news/index.html index 1b155091..cd684798 100644 --- a/docs/news/index.html +++ b/docs/news/index.html @@ -71,7 +71,7 @@ sen2r - 1.3.9 + 1.4.0

@@ -155,9 +155,52 @@

Changelog

Source: NEWS.md
+
+

+Version 1.4.0 Unreleased +

+
+

+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), 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. +
    3. now s2_download() is no more able to use existing products equivalent to found ones.
    4. +
    +
  • +
+
+
+

+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 Unreleased +Version 1.3.9 2020-10-14

@@ -171,9 +214,9 @@

Version 1.3.8 2020-08-26

-
+

-Minor changes

+Minor changes

-
+

-Changes in default values

+Changes in default values