-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## Major changes * **`sen2r`** package directory is no more used to store files, but a subfolder `.sen2r` of the user Home directory is created and used. In this way, reinstalling sen2r will not require anymore to reinstall runtime dependencies / to reconfigure the package. The permission to write on this folder is asked to the user when the package is loaded for the first time. ## Other changes * Small base example files were added to the package for testing purposes. * Sen2Cor version which the user wants to install can be chosen in the GUI. * Documentation was updated and improved, in particular adding function examples. ## New functions * `build_example_param_file()` (not exported) to build an example parameter file. ## Fixes * Fix generation of thumbnails in case of multiple product types.
- Loading branch information
Showing
240 changed files
with
4,597 additions
and
2,378 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
^.*\.Rproj$ | ||
^\.Rproj\.user$ | ||
^\.travis\.yml$ | ||
^\.covrignore\.yml$ | ||
^.*\.yaml$ | ||
^README\.R?md$ | ||
^WIP$ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
This package was submitted to CRAN on 2019-09-13. | ||
Once it is accepted, delete this file and tag the release (commit 48f043460c). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,25 +2,26 @@ Package: sen2r | |
Type: Package | ||
Title: Find, Download and Process Sentinel-2 Data | ||
Version: 1.1.0 | ||
Authors@R: c(person("Luigi", "Ranghetti", | ||
email = "ranghetti.[email protected]", | ||
role = c("aut", "cre"), | ||
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 = "[email protected]", | ||
person("Lorenzo", "Busetto", | ||
email = "[email protected]", | ||
role = c("aut"), | ||
comment = c(ORCID = "0000-0001-9634-6038"))) | ||
Description: Functions to download Sentinel-2 optical images | ||
and perform preliminary processing operations. | ||
'sen2r' provides the instruments required to easily perform | ||
(and eventually automate) the steps necessary to build a complete | ||
Description: Functions to download Sentinel-2 optical images | ||
and perform preliminary processing operations. | ||
'sen2r' provides the instruments required to easily perform | ||
(and eventually automate) the steps necessary to build a complete | ||
Sentinel-2 processing chain. | ||
A Graphical User Interface to facilitate data processing is also provided. | ||
License: GPL-3 | ||
Encoding: UTF-8 | ||
URL: http://sen2r.ranghetti.info, https://github.com/ranghetti/sen2r | ||
BugReports: https://github.com/ranghetti/sen2r/issues | ||
Imports: | ||
Depends: R (>= 3.5.0) | ||
Imports: | ||
reticulate, | ||
methods, | ||
digest, | ||
|
@@ -46,7 +47,7 @@ Imports: | |
units, | ||
httr | ||
Suggests: | ||
spelling, | ||
spelling, | ||
geojsonlint, | ||
httptest, | ||
knitr, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
FROM rocker/geospatial:3.5.1 | ||
|
||
LABEL maintainer="Luigi Ranghetti <ranghetti.[email protected]>" | ||
LABEL maintainer="Luigi Ranghetti <luigi@ranghetti.info>" | ||
|
||
# Install external dependencies | ||
RUN apt-get update && apt-get install -y \ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#' @title Ask permission to write settings on disk | ||
#' @description Ask users for permission to create a .sen2r settings directory, | ||
#' in which to store the files paths.json and apihub.txt. | ||
#' @return 'logical' if TRUE, the user authorised saving in this directory. | ||
#' @author Lorenzo Busetto, phD (2019) \email{lbusett@@gmail.com} | ||
#' @author Luigi Ranghetti, phD (2019) \email{luigi@@ranghetti.info} | ||
#' @note License: GPL 3.0 | ||
|
||
ask_permission <- function() { | ||
|
||
settings_dir <- normalize_path("~/.sen2r", mustWork = FALSE) | ||
|
||
if (!dir.exists(settings_dir)) { | ||
message(paste( | ||
"\nsen2r would like to create a hidden folder in your home directory, ", | ||
paste0("named '",settings_dir,"', "), | ||
"in which storing some files required by the package:", | ||
"- 'paths.json', containing the paths of sen2r runtime dependencies ", | ||
" (GDAL, aria2, Sen2Cor);", | ||
"- 'apihub.txt', in which saving the user's SciHub credentials;", | ||
"- 's2_tiles.rds', containing the Sentinel-2 tile boundaries;", | ||
"- the 'log' subfolder, used to keep trace of temporary files created ", | ||
" during processing operations.\n", | ||
"Do you authorise this?\n", | ||
"Yes: folder '.sen2r' will be created permanently, and the files ", | ||
" will be created and updated when needed. ", | ||
" You will not see this message anymore.\n", | ||
"No: a temporary folder will be used and will be lost when exiting ", | ||
" R. You will see this message every time you will restart R.\n", | ||
sep = "\n" | ||
)) | ||
choice <- "" | ||
while (!tolower(choice) %in% c("y", "yes", "n", "no")) { | ||
choice <- readline(prompt = "Choice (y/n): ") | ||
} | ||
if (tolower(choice) %in% c("y", "yes")) { | ||
dir.create(settings_dir) | ||
} | ||
} else { | ||
choice <- "y" | ||
} | ||
|
||
return(tolower(choice) %in% c("y", "yes")) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
#' @title Build an example JSON parameter file | ||
#' @description Function used to write JSON parameter file. | ||
#' A function is provided instead than a json file to ensure | ||
#' directories to match the user folder tree. | ||
#' @param json_path Path of the output file. Default is to save it on a | ||
#' temporary file, whose path is returned. | ||
#' @param overwrite Logical value: should existing output file be | ||
#' overwritten? (default: TRUE) | ||
#' @return The path of the created file. | ||
#' | ||
#' @author Luigi Ranghetti, phD (2019) \email{luigi@@ranghetti.info} | ||
#' @note License: GPL 3.0 | ||
#' @importFrom jsonlite toJSON | ||
#' @examples | ||
#' sen2r:::build_example_param_file() | ||
|
||
build_example_param_file <- function( | ||
json_path = tempfile(fileext = "_sen2r_params.json"), | ||
overwrite = TRUE | ||
) { | ||
|
||
# Check json_path | ||
if (json_path == "") {json_path <- NULL} | ||
if (!attr(path_check(dirname(json_path)), "isvalid")) { | ||
print_message( | ||
type = "error", | ||
"Path '",dirname(json_path),"' is missing or not writable." | ||
) | ||
} | ||
|
||
# Delete existing file | ||
if (file.exists(json_path)) { | ||
if (overwrite == TRUE) { | ||
file.remove(json_path) | ||
} else { | ||
print_message( | ||
type = "error", | ||
"File '",json_path,"' already exists." | ||
) | ||
} | ||
} | ||
|
||
writeLines( | ||
jsonlite::toJSON( | ||
list( | ||
"preprocess" = TRUE, | ||
"s2_levels" = c("l1c", "l2a"), | ||
"sel_sensor" = c("s2a", "s2b"), | ||
"online" = TRUE, | ||
"downloader" = "builtin", | ||
"overwrite_safe" = FALSE, | ||
"rm_safe" = "no", | ||
"max_cloud_safe" =100, | ||
"step_atmcorr" = "l2a", | ||
"timewindow" = c("2017-07-03", "2017-07-03"), | ||
"timeperiod" = "full", | ||
"extent" = system.file("extdata/vector/barbellino.geojson", package = "sen2r"), | ||
"s2tiles_selected" = NA, | ||
"s2orbits_selected" = NA, | ||
"list_prods" = c("TOA", "BOA", "SCL"), | ||
"list_indices" = c("MSAVI2", "NDVI"), | ||
"list_rgb" = c("RGB432B", "RGB432T", "RGB843B"), | ||
"rgb_ranges" = list( | ||
c(0, 2500), | ||
c(0, 2500), | ||
matrix(c(0, 0, 0, 7500, 2500, 2500), ncol = 2) | ||
), | ||
"index_source" = "BOA", | ||
"mask_type" = NA, | ||
"max_mask" = 80, | ||
"mask_smooth" = 0, | ||
"mask_buffer" = 0, | ||
"clip_on_extent" = TRUE, | ||
"extent_as_mask" = FALSE, | ||
"extent_name" = "sen2r", | ||
"reference_path" = NA, | ||
"res" = NA, | ||
"res_s2" ="10m", | ||
"unit" = "Meter", | ||
"proj"= NA, | ||
"resampling" = "near", | ||
"resampling_scl" = "near", | ||
"outformat" = "GTiff", | ||
"rgb_outformat" = "GTiff", | ||
"index_datatype" = "Int16", | ||
"compression" = "DEFLATE", | ||
"rgb_compression" = "DEFLATE", | ||
"overwrite" = FALSE, | ||
"path_l1c" = file.path(dirname(attr(load_binpaths(), "path")), "safe"), | ||
"path_l2a" = file.path(dirname(attr(load_binpaths(), "path")), "safe"), | ||
"path_tiles"= NA, | ||
"path_merged"= NA, | ||
"path_out" = tempfile(pattern = "sen2r_out_"), | ||
"path_rgb" = "", | ||
"path_indices" = "", | ||
"path_subdirs"= TRUE, | ||
"thumbnails" = TRUE, | ||
"log"= NA, | ||
"parallel" = FALSE, | ||
"processing_order" = "by_groups", | ||
"pkg_version" = as.character(packageVersion("sen2r")) | ||
), | ||
pretty = TRUE | ||
), | ||
json_path | ||
) | ||
|
||
return(json_path) | ||
|
||
} |
Oops, something went wrong.