eblondel / ows4R

R Interface for OGC Web-Services (OWS)
https://eblondel.github.io/ows4R/
Other
36 stars 8 forks source link

`getCoverage` needs to download in tempdir instead of current wd, when no filename is provider #91

Closed annakrystalli closed 1 year ago

annakrystalli commented 2 years ago

The documentation gives the impression that files are written out only when argument filename is used. https://github.com/eblondel/ows4R/blob/48874771973249efd16acaf8b342e620af92887c/vignettes/wcs.Rmd#L115

However getCoverage() always downloads and writes out a file, regardless of whether a filename has been provided. This ends up polluting the working directory (e,g my EMODnetWCS package directory as well as the testthat directory within is constantly filling up with files from development and running tests.

If this is a default behaviour of terra should it not download to a temp directory instead if filename is not provided? At the very least the documentation should reflect this fact.

library(ows4R)
#> Loading required package: geometa
#> Loading ISO 19139 XML schemas...
#> Loading ISO 19115 codelists...
#> Loading IANA mime types...
#> No encoding supplied: defaulting to UTF-8.
#> Loading required package: keyring
coverage <- "Emodnetbio__cal_fin_19582016_L1_err"
wcs <- WCSClient$new(url = "https://geo.vliz.be/geoserver/Emodnetbio/wcs" ,
                     serviceVersion = "2.0.1")
bbox <- OWSUtils$toBBOX(0,5,40, 45)

# from wcs crs default
wcs$getCoverage(coverage,
                bbox = bbox,
                time = NULL,
                crs = NULL)
#> Loading required package: sf
#> Linking to GEOS 3.9.1, GDAL 3.4.0, PROJ 8.1.1; sf_use_s2() is TRUE
#> <GMLEnvelope>
#> ....|-- lowerCorner: 40 0 "1958-02-16T00:00:00"
#> ....|-- upperCorner: 45 5 "2016-11-16T00:00:00"
#> class       : SpatRaster 
#> dimensions  : 50, 49, 2  (nrow, ncol, nlyr)
#> resolution  : 0.1, 0.1  (x, y)
#> extent      : 0.05, 4.95, 40.05, 45.05  (xmin, xmax, ymin, ymax)
#> coord. ref. : lon/lat WGS 84 (EPSG:4326) 
#> source      : Emodnetbio__cal_fin_19582016_L1_err_2016-11-16T00_00_00.000Z_40,0,45,5.tif 
#> names       : Emodnetbio__cal~00Z_40,0,45,5_1, Emodnetbio__cal~00Z_40,0,45,5_2
fs::dir_tree()
#> .
#> ├── Emodnetbio__cal_fin_19582016_L1_err_2016-11-16T00_00_00.000Z_40,0,45,5.tif

Created on 2022-08-30 by the reprex package (v2.0.1)

Session info ``` r sessioninfo::session_info() #> ─ Session info ─────────────────────────────────────────────────────────────── #> setting value #> version R version 4.1.3 (2022-03-10) #> os macOS Big Sur/Monterey 10.16 #> system x86_64, darwin17.0 #> ui X11 #> language (EN) #> collate en_GB.UTF-8 #> ctype en_GB.UTF-8 #> tz Europe/Athens #> date 2022-08-30 #> pandoc 2.18 @ /Applications/RStudio.app/Contents/MacOS/quarto/bin/tools/ (via rmarkdown) #> #> ─ Packages ─────────────────────────────────────────────────────────────────── #> package * version date (UTC) lib source #> askpass 1.1 2019-01-13 [1] CRAN (R 4.1.0) #> assertthat 0.2.1 2019-03-21 [1] CRAN (R 4.1.0) #> class 7.3-20 2022-01-16 [1] CRAN (R 4.1.3) #> classInt 0.4-7 2022-06-10 [1] CRAN (R 4.1.2) #> cli 3.3.0 2022-04-25 [1] CRAN (R 4.1.2) #> codetools 0.2-18 2020-11-04 [1] CRAN (R 4.1.3) #> crayon 1.5.1 2022-03-26 [1] CRAN (R 4.1.2) #> curl 4.3.2 2021-06-23 [1] CRAN (R 4.1.0) #> DBI 1.1.3 2022-06-18 [1] CRAN (R 4.1.2) #> digest 0.6.29 2021-12-01 [1] CRAN (R 4.1.0) #> dplyr 1.0.9 2022-04-28 [1] CRAN (R 4.1.2) #> e1071 1.7-11 2022-06-07 [1] CRAN (R 4.1.2) #> evaluate 0.15 2022-02-18 [1] CRAN (R 4.1.2) #> fansi 1.0.3 2022-03-24 [1] CRAN (R 4.1.2) #> fastmap 1.1.0 2021-01-25 [1] CRAN (R 4.1.0) #> fs 1.5.2 2021-12-08 [1] CRAN (R 4.1.0) #> generics 0.1.2 2022-01-31 [1] CRAN (R 4.1.2) #> geometa * 0.6-6 2022-01-26 [1] CRAN (R 4.1.2) #> glue 1.6.2 2022-02-24 [1] CRAN (R 4.1.2) #> highr 0.9 2021-04-16 [1] CRAN (R 4.1.0) #> htmltools 0.5.3 2022-07-18 [1] CRAN (R 4.1.2) #> httr 1.4.3 2022-05-04 [1] CRAN (R 4.1.2) #> jsonlite 1.8.0 2022-02-22 [1] CRAN (R 4.1.2) #> KernSmooth 2.23-20 2021-05-03 [1] CRAN (R 4.1.3) #> keyring * 1.3.0 2021-11-29 [1] CRAN (R 4.1.0) #> knitr 1.39 2022-04-26 [1] CRAN (R 4.1.2) #> lifecycle 1.0.1 2021-09-24 [1] CRAN (R 4.1.0) #> magrittr 2.0.3 2022-03-30 [1] CRAN (R 4.1.2) #> openssl 2.0.2 2022-05-24 [1] CRAN (R 4.1.2) #> ows4R * 0.3 2022-08-17 [1] Github (eblondel/ows4R@1cd9dbc) #> pillar 1.8.0 2022-07-18 [1] CRAN (R 4.1.2) #> pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 4.1.0) #> proxy 0.4-27 2022-06-09 [1] CRAN (R 4.1.2) #> purrr 0.3.4 2020-04-17 [1] CRAN (R 4.1.0) #> R.cache 0.16.0 2022-07-21 [1] CRAN (R 4.1.2) #> R.methodsS3 1.8.2 2022-06-13 [1] CRAN (R 4.1.2) #> R.oo 1.25.0 2022-06-12 [1] CRAN (R 4.1.2) #> R.utils 2.12.0 2022-06-28 [1] CRAN (R 4.1.2) #> R6 2.5.1 2021-08-19 [1] CRAN (R 4.1.0) #> Rcpp 1.0.9 2022-07-08 [1] CRAN (R 4.1.2) #> reprex 2.0.1 2021-08-05 [1] CRAN (R 4.1.0) #> rlang 1.0.4 2022-07-12 [1] CRAN (R 4.1.2) #> rmarkdown 2.14 2022-04-25 [1] CRAN (R 4.1.2) #> rstudioapi 0.13 2020-11-12 [1] CRAN (R 4.1.0) #> sessioninfo 1.2.2 2021-12-06 [1] CRAN (R 4.1.0) #> sf * 1.0-7 2022-03-07 [1] CRAN (R 4.1.2) #> stringi 1.7.6 2021-11-29 [1] CRAN (R 4.1.0) #> stringr 1.4.0 2019-02-10 [1] CRAN (R 4.1.2) #> styler 1.7.0 2022-03-13 [1] CRAN (R 4.1.2) #> terra 1.5-21 2022-02-17 [1] CRAN (R 4.1.2) #> tibble 3.1.8 2022-07-22 [1] CRAN (R 4.1.2) #> tidyselect 1.1.2 2022-02-21 [1] CRAN (R 4.1.2) #> units 0.8-0 2022-02-05 [1] CRAN (R 4.1.2) #> utf8 1.2.2 2021-07-24 [1] CRAN (R 4.1.0) #> vctrs 0.4.1 2022-04-13 [1] CRAN (R 4.1.2) #> withr 2.5.0 2022-03-03 [1] CRAN (R 4.1.2) #> xfun 0.31 2022-05-10 [1] CRAN (R 4.1.2) #> XML 3.99-0.10 2022-06-09 [1] CRAN (R 4.1.2) #> yaml 2.3.5 2022-02-21 [1] CRAN (R 4.1.2) #> #> [1] /Library/Frameworks/R.framework/Versions/4.1/Resources/library #> #> ────────────────────────────────────────────────────────────────────────────── ```
eblondel commented 1 year ago

Fixed in https://github.com/eblondel/ows4R/commit/9f9a3b8a40954a375dcdf5e7c3a59717d6d71a4f#diff-dd33264846cb4a85462eed26ec6009151a2aea985622a601a1c5633403ae515bR606