Skip to content

Commit

Permalink
version 0.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
norival authored and cran-robot committed Jan 20, 2020
1 parent 3b6b795 commit 6ca121e
Show file tree
Hide file tree
Showing 15 changed files with 261 additions and 117 deletions.
14 changes: 7 additions & 7 deletions DESCRIPTION
@@ -1,28 +1,28 @@
Package: theiaR
Title: Download and Manage Data from Theia
Version: 0.2.0
Version: 0.3.0
Authors@R: person("Xavier", "Laviron", email = "xavier.laviron@gmx.fr",
role = c("aut", "cre"),
comment = c(ORCID = "0000-0002-9882-3253"))
Description: Provides a simple interface to search available data provided by
Theia (<https://theia.cnes.fr>), download it, and manage it. Data can be downloaded
based on a search result or from a cart file downloaded from Theia website.
Depends: R (>= 3.5)
Imports: httr (>= 1.3), R6 (>= 2.3), raster (>= 2.6), tiff (>= 0.1),
tools (>= 3.5), XML (>= 3.86), askpass (>= 1.1)
Imports: httr (>= 1.3), R6 (>= 2.3), raster (>= 2.6), tools (>= 3.5),
XML (>= 3.86), askpass (>= 1.1)
License: GPL (>= 3.0)
URL: https://github.com/norival/theiaR
BugReports: https://github.com/norival/theiaR/issues
Encoding: UTF-8
LazyData: true
RoxygenNote: 6.1.1
Suggests: knitr, rmarkdown, covr
RoxygenNote: 7.0.2
Suggests: knitr, rmarkdown, covr, gdalcubes
Collate: 'TheiaAuth.R' 'TheiaTile.R' 'TheiaCollection.R' 'TheiaQuery.R'
'theiaR.R' 'utils.R'
VignetteBuilder: knitr
NeedsCompilation: no
Packaged: 2019-03-26 12:21:58 UTC; lavironx
Packaged: 2020-01-20 15:32:30 UTC; xavier
Author: Xavier Laviron [aut, cre] (<https://orcid.org/0000-0002-9882-3253>)
Maintainer: Xavier Laviron <xavier.laviron@gmx.fr>
Repository: CRAN
Date/Publication: 2019-03-26 12:30:03 UTC
Date/Publication: 2020-01-20 16:00:02 UTC
26 changes: 13 additions & 13 deletions MD5
@@ -1,23 +1,23 @@
f58e7c76a96db32873f59418cc106ce7 *DESCRIPTION
32cd00ed1a391ef5127de3d0477e1a25 *DESCRIPTION
ef23d45adbf8c14d401b111bc2893b63 *NAMESPACE
dd9e59e8e560094d6977fa7dbeda6f9b *NEWS.md
c9013bfe7c302967f41403a6d86cbce2 *NEWS.md
27473226eb1ecd86ec6f0a8a019aa46e *R/TheiaAuth.R
2cb15ee5c6a3645b9c36807e9d304556 *R/TheiaCollection.R
0e44c42a08c788eac0fd798b7fb9f5b0 *R/TheiaQuery.R
202587baa754139d02c4724174025151 *R/TheiaTile.R
1cb7c8c02008cc47242114d95deae30f *R/TheiaCollection.R
83cd0e0e4d511dc77c4852cd98a39ef9 *R/TheiaQuery.R
00f6d83b34c6b3a8a31f62a8f7e5b212 *R/TheiaTile.R
cfb66bdb35f83ff44b9005b69fe14f44 *R/theiaR.R
47070be27ab473402afac7fc3c34fc84 *R/utils.R
e88d39c685096c136bb319fa9bcc21b6 *README.md
f971297cba03e29eb8c3829b6816fa6d *build/vignette.rds
f3a24f434452b425530cdd6f44d0752b *inst/WORDLIST
1d16ec6de26a1ee331948214e8a8ebd3 *inst/doc/quick-start.R
43a92c24ca54a5e5b031f4d8a21366c3 *build/vignette.rds
8b5cd7638064badfecf54f7761da6b93 *inst/WORDLIST
6b1a65b62ab33b56d3d992d8244b4c9f *inst/doc/quick-start.R
ff542859e7d16cd3c52de8f14881841a *inst/doc/quick-start.Rmd
a94188ffaa28509efc131f9fc32bc633 *inst/doc/quick-start.html
f4e170ed77266f4987fac3710c8ecfba *inst/doc/quick-start.html
31f38b1780aff70c46e3de53c853e72d *inst/extdata/cart.meta4
7a6688ec0b711859a022cdbfd8b299f9 *inst/extdata/dummy_tile.zip
acdbbf4d5eb10d242c61a1a843bcd28d *inst/templates/gdalcubes_theia.json
e60ca1b59ddb91d5b7e0a0deaade3f71 *man/TheiaAuth.Rd
78713cc3c1b83dcf4196b91bb0a3590c *man/TheiaCollection.Rd
6e12f6337fa5c7ad82f956a04160c11e *man/TheiaCollection.Rd
b4bbbe6e27b24fdd802952e04de6cb77 *man/TheiaQuery.Rd
ca5226f7340fa33a548eb5159db04dfa *man/TheiaTile.Rd
70b672cdce97f164a78472ec59d6fc5d *man/theiaR.Rd
4108da0c693b84f88ee7912d1662559d *man/TheiaTile.Rd
c427909fd2fcce0ae42d0ab0e155f664 *man/theiaR.Rd
ff542859e7d16cd3c52de8f14881841a *vignettes/quick-start.Rmd
24 changes: 24 additions & 0 deletions NEWS.md
@@ -1,3 +1,27 @@
# theiaR 0.3.0

## New features

- Adds export to gdalcubes' image collection

## Bug fixes

- Fix error due to bad file path on Windows

## Minor changes

- Adds quiet arguments to control verbose output
- Adds 'check' argument to 'TheiaTile' and 'TheiaCollection' download methods
- Do not parse meta.data on tile creation, but do it on the fly


# theiaR 0.2.1

## Bug fixes

- Fix printing of TheiaQuery objects


# theiaR 0.2.0

## New features
Expand Down
70 changes: 60 additions & 10 deletions R/TheiaCollection.R
Expand Up @@ -14,12 +14,14 @@
#' query = NULL,
#' dir.path = NULL,
#' check = TRUE)
#' quiet = TRUE)
#'
#' c$download(auth, overwrite = FALSE)
#' c$download(auth, overwrite = FALSE, check = TRUE, quiet = TRUE)
#' c$check()
#' c$status
#' c$extract(overwrite = FALSE, dest.dir = NULL)
#' c$read(bands)
#' c$as_gdalcube(out.file = "gdalcube_collection.sqlite")
#' }
#'
#' @section Arguments:
Expand All @@ -28,6 +30,7 @@
#' \item{c:}{A \code{TheiaCollection} object}
#' \item{dir.path:}{The path to the directory containing zip files}
#' \item{check:}{Whether or not to check existing files on collection's creation}
#' \item{quiet:}{Control verbose output}
#' \item{tiles:}{A list of TheiaTile objects}
#' \item{cart:}{An XML cart parsed from a 'meta4' file downloaded from Theia}
#' website. Used only if Collection is created from a cart
Expand All @@ -39,12 +42,13 @@
#' Or a \code{\link{TheiaAuth}} object}
#' \item{overwrite:}{Overwrite existing tiles (default to `FALSE`)}
#' \item{bands:}{A character vector of bands to load from tiles}
#' \item{out.file:}{Filename to store gdalcubes' image collection}
#' }
#'
#' @section Details:
#' \code{TheiaCollection$new()} Create a new instance of the class
#'
#' \code{c$download(overwrite = FALSE)} Download the tiles of the collection
#' \code{c$download(overwrite = FALSE, check = TRUE)} Download the tiles of the collection
#' and check the resulting files
#'
#' \code{$ccheck()} Check the tiles of the collection
Expand All @@ -58,6 +62,10 @@
#' (as specified in Theia's product information), and return a list of
#' RasterStack objects (one stack per tile)
#'
#' \code{c$as_gdalcube(out.file)} Create a `gdalcubes` image collection from
#' downloaded tiles. See \url{https://github.com/appelmar/gdalcubes_R} for
#' more details.
#'
#' @examples
#'
#' \donttest{
Expand Down Expand Up @@ -114,9 +122,16 @@ TheiaCollection <-
tiles = NULL,
query = NULL,
dir.path = NULL,
check = TRUE)
check = TRUE,
quiet = TRUE)
{
.TheiaCollection_initialize(self, cart.path, tiles, query, dir.path, check)
if (quiet == TRUE) {
suppressMessages({
.TheiaCollection_initialize(self, cart.path, tiles, query, dir.path, check)
})
} else {
.TheiaCollection_initialize(self, cart.path, tiles, query, dir.path, check)
}
},

print = function(...)
Expand All @@ -129,9 +144,9 @@ TheiaCollection <-
.TheiaCollection_check(self)
},

download = function(auth, overwrite = FALSE)
download = function(auth, overwrite = FALSE, check = TRUE, quiet = TRUE)
{
.TheiaCollection_download(self, auth, overwrite)
.TheiaCollection_download(self, auth, overwrite, check, quiet)
},

extract = function(overwrite = FALSE, dest.dir = NULL)
Expand All @@ -142,6 +157,11 @@ TheiaCollection <-
read = function(bands)
{
.TheiaCollection_read(self, private, bands)
},

as_gdalcube = function(out.file)
{
.TheiaCollection_as_gdalcube(self, private, out.file)
}),

# active -----------------------------------------------------------
Expand Down Expand Up @@ -246,7 +266,7 @@ TheiaCollection <-
}


.TheiaCollection_download <- function(self, auth, overwrite)
.TheiaCollection_download <- function(self, auth, overwrite, check, quiet)
{
if (is.character(auth)) {
# create authentification system if not supplied
Expand All @@ -255,10 +275,10 @@ TheiaCollection <-

# download needed tiles
lapply(self$tiles,
function(x, auth, overwrite) {
x$download(auth, overwrite = overwrite)
function(x, auth, overwrite, check, quiet) {
x$download(auth, overwrite = overwrite, check = check, quiet)
},
auth = auth, overwrite = overwrite)
auth = auth, overwrite = overwrite, check = check, quiet = quiet)

return(invisible(self))
}
Expand Down Expand Up @@ -303,3 +323,33 @@ TheiaCollection <-

return(tiles.list)
}


.TheiaCollection_as_gdalcube <- function(self, private, out.file = "gdalcube_collection.sqlite")
{
# export collection as a gdalcube image collection
if (!(requireNamespace("gdalcubes", quietly = TRUE))) {
# check if package 'gdalcubes' is installed
stop("Package 'gdalcubes' needed for this function. Please install it.",
call. = FALSE)
}

if (!(all(as.logical(self$status$exists)))) {
# check if all files are downloaded
stop("Some files in the collection are not downloaded. Please check `mycollection$status()`",
call. = FALSE)
}

# extract file paths to collection
files <- unname(sapply(self$tiles, function(x) x$file.path))

# create gdalcubes image collection
gdalcubes.col <-
gdalcubes::create_image_collection(files = files,
format = system.file("templates",
"gdalcubes_theia.json",
package = "theiaR"),
out_file = out.file)

return(gdalcubes.col)
}
6 changes: 5 additions & 1 deletion R/TheiaQuery.R
Expand Up @@ -129,11 +129,15 @@ TheiaQuery <-

cat("Search terms:\n")

# get maximum length of search terms to format printing
max.chars <- max(nchar(names(self$query))) + 1

# print search terms
lapply(1:length(self$query),
function(x) {
l <- nchar(names(self$query))[[x]]

cat(" ", names(self$query)[[x]], rep(" ", 11 - l), ": ",
cat(" ", names(self$query)[[x]], rep(" ", max.chars - l), ": ",
self$query[[x]], "\n",
sep = "")

Expand Down

0 comments on commit 6ca121e

Please sign in to comment.