eblondel / ows4R

R Interface for OGC Web-Services (OWS)

Home Page:https://eblondel.github.io/ows4R/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Arguments `crs` & `gridbaseCRS` don't seem to affect the response from a `getCoverage` request

annakrystalli opened this issue · comments

I'm trying to demonstrate in the EMODnetWCS docs how to download a coverage with the response being in a different CRS to the original coverage CRS.

I'm having a hard time understanding how to use the crs and gridbaseCRS. As mentioned in #89, the documentation for the arguments is very minimal so I'm not even sure which one I'm supposed to use or whether I'm supplying the correct input.

Trying to implement it as best I can guess in any case doesn't seem to be doing much and the coverage is still being returned in the original CRS.

Can you provide some guidance and ideally include it in the man pages and docs?

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")

ows4r_bbox <- ows4R::OWSUtils$toBBOX(xmin = 1.5,
                                     xmax = 6.5,
                                     ymin = 53,
                                     ymax = 58)

wcs$getCoverage(coverage,
                crs = "EPSG:3857",
                bbox = ows4r_bbox)
#> 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: 53 1.5 "1958-02-16T00:00:00"
#> ....|-- upperCorner: 58 6.5 "2016-11-16T00:00:00"
#> class       : SpatRaster 
#> dimensions  : 50, 49, 2  (nrow, ncol, nlyr)
#> resolution  : 0.1, 0.1  (x, y)
#> extent      : 1.55, 6.45, 53.05, 58.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_53,1.5,58,6.5.tif 
#> names       : Emodnetbio__cal~53,1.5,58,6.5_1, Emodnetbio__cal~53,1.5,58,6.5_2

wcs$getCoverage(coverage,
                bbox = ows4r_bbox,
                gridbaseCRS = "EPSG:3857")
#> <GMLEnvelope>
#> ....|-- lowerCorner: 53 1.5 "1958-02-16T00:00:00"
#> ....|-- upperCorner: 58 6.5 "2016-11-16T00:00:00"
#> class       : SpatRaster 
#> dimensions  : 50, 49, 2  (nrow, ncol, nlyr)
#> resolution  : 0.1, 0.1  (x, y)
#> extent      : 1.55, 6.45, 53.05, 58.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_53,1.5,58,6.5.tif 
#> names       : Emodnetbio__cal~53,1.5,58,6.5_1, Emodnetbio__cal~53,1.5,58,6.5_2

Created on 2022-09-16 by the reprex package (v2.0.1)

Also, it would be useful to know whether using the any of the crs arguments affects how the bbox should be specified.