eblondel / ows4R

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

Error when using summary$getCoverage() with `crs = NULL` (the default) #90

Closed annakrystalli closed 1 year ago

annakrystalli commented 2 years ago

crs = null appears to be the default for the getCoverage() method when using it both from a summary object or a wcs object (although not 100% percent clear from the docs, see https://github.com/eblondel/ows4R/discussions/89).

When I explicitly use this default in wcs$getCoverage() it works. However when I use it with summary$getCoverage() it throws an error. All other defaults work however.

This is a problem however when trying to build a wrapper. I need to use the summary$getCoverage() because it's the only way I can also access summary$getCoverageStack() if more than one timepoints are requested. But I also want to allow users to pass additional arguments and set those to the default values in the wrapper. Hence, summary$getCoverage(crs = NULL) needs to work as expected.

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")
summary <- wcs$getCapabilities()$findCoverageSummaryById(coverage)
cov_bbox <-  summary$getBoundingBox()$BoundingBox$getBBOX()
cov_bbox
#>   xmin   ymin   xmax   ymax 
#> -75.05  34.95  20.05  75.05
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

# from summary no defaults
summary$getCoverage(coverage,
                bbox = bbox)
#> <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

# from summary all defaults
summary$getCoverage(coverage,
                bbox = bbox,
                time = NULL,
                crs = NULL,
                elevation = NULL,
                format = NULL,
                rangesubset = NULL,
                filename = NULL)
#> <GMLEnvelope>
#> ....|-- lowerCorner: 40 0 "1958-02-16T00:00:00"
#> ....|-- upperCorner: 45 5 "2016-11-16T00:00:00"
#> Warning: `/private/var/folders/yb/936h04ss57x2rdmly_tv561m0000gp/
#> T/RtmpsLCdv5/reprex-156b624026c3a-petit-dore/
#> Emodnetbio__cal_fin_19582016_L1_err_2016-11-16T00_00_00.000Z_40,0,45,5.tif' not
#> recognized as a supported file format. (GDAL error 4)
#> Error: [rast] cannot open file: /private/var/folders/yb/936h04ss57x2rdmly_tv561m0000gp/T/RtmpsLCdv5/reprex-156b624026c3a-petit-dore/Emodnetbio__cal_fin_19582016_L1_err_2016-11-16T00_00_00.000Z_40,0,45,5.tif

# from summary all defaults but no crs default
summary$getCoverage(coverage,
                bbox = bbox,
                time = NULL,
                #crs = NULL,
                elevation = NULL,
                format = NULL,
                rangesubset = NULL,
                filename = NULL)
#> <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

Created on 2022-08-29 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-29 #> 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) #> 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 #> #> ────────────────────────────────────────────────────────────────────────────── ```
annakrystalli commented 2 years ago

It would also be great if you could address https://github.com/eblondel/ows4R/discussions/89 as I need to provide more detail to our users on what arguments are and what type of values are accepted for each.

annakrystalli commented 2 years ago

Same behaviour if bbox is NULL