eblondel / ows4R

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

Add RESX and RESY for WCS getCoverage #113

Closed pmlefeuvre-met closed 10 months ago

pmlefeuvre-met commented 10 months ago

Hei @eblondel,

I am trying to download a WCS with getCoverage but the service I am trying to reach requires a RESX and RESY. How can I add &RESX=1&RESY=1 to my fetching URL.

Thanks for your help.

<ServiceExceptionReport version="1.2.0" xsi:schemaLocation="http://www.opengis.net/ogc http://schemas.opengeospatial.net/wms/1.1.1/OGC-exception.xsd">
<ServiceException code="MissingParameterValue"> parameter WIDTH/RESX is required </ServiceException>
<ServiceException code="MissingParameterValue"> parameter HEIGHT/RESY is required </ServiceException>
<ServiceException code="InvalidParameterValue"> parameter RESX is invalid </ServiceException>
<ServiceException code="InvalidParameterValue"> parameter RESY is invalid </ServiceException>
</ServiceExceptionReport>
eblondel commented 10 months ago

Hi @pmlefeuvre-met can you share the WCS server you try to use? and the code you tried? thanks

pmlefeuvre-met commented 10 months ago

Yes, ^^ 1) this url is from the provider and delivers a geotiff file

https://wcs.geonorge.no/skwms1/wcs.hoyde-dom-nhm-25833?SERVICE=WCS&REQUEST=GetCoverage&VERSION=1.0.0&COVERAGE=nhm_dom_topo_25833&CRS=EPSG:25833&BBOX=260500,6652500,261500,6653000&RESX=1&RESY=1&FORMAT=GEOTIFF

2) this one is produced by ows4R (without &RESX=1&RESY=1) and produces the XML error message copied above

https://wcs.geonorge.no/skwms1/wcs.hoyde-dom-nhm-25833?service=WCS&version=1.0.0&coverage=nhm_dom_topo_25833&BBOX=260500,6652500,261500,6653000&CRS=EPSG:25833&format=GeoTIFF&request=GetCoverage 

The R code

WCS <- WCSClient$new("https://wcs.geonorge.no/skwms1/wcs.hoyde-dom-nhm-25833", "1.0.0", logger = "INFO")
caps <- WCS$getCapabilities()
name <- "nhm_dom_topo_25833"
chla <- caps$findCoverageSummaryById(name, exact = T)
cov_data <- chla$getCoverage(crs = "EPSG:25833",gridbaseCRS = "EPSG:25833",
                             bbox=OWSUtils$toBBOX(260500,261500,6652500,6653000),
                             filename = "dom_25833_1.tif")
eblondel commented 10 months ago

First thing I see is that your WCS server implements up to WCS 2.0.1. I would recommend to start using this service version, since WCS 1.0 is quite old and one cons was this need to specify these extra parameters. In ows4R, so far i tested the WCS 1.0.0 against Thredds data servers. Do you know which WCS server software is used behind https://wcs.geonorge.no ? Mapserver?

Switchinng to WCS 2.0.1, I also get an issue, different, that i'm now investigating. The response provided by service gives a multipart/related content-type, which is not implemented in ows4R. The behavior seems related to https://github.com/MapServer/MapServer/issues/6551 Keep digging and let you know if I find a possible patch for ows4R

eblondel commented 10 months ago

Ok I now see that it uses ArcGIS WCS server. I will investigate there

eblondel commented 10 months ago

If you stick with WCS 1.0.0, you can always extend getCoverage adding more parameters. I had to fix a minor bug, so please reinstall from Github: remotes::install_github("eblondel/ows4R")

WCS <- WCSClient$new("https://wcs.geonorge.no/skwms1/wcs.hoyde-dom-nhm-25833", "1.0.0", logger = "INFO")
caps <- WCS$getCapabilities()
name <- "nhm_dom_topo_25833"
chla <- caps$findCoverageSummaryById(name, exact = T)
cov_data <- chla$getCoverage(crs = "EPSG:25833",gridbaseCRS = "EPSG:25833",
                             bbox=OWSUtils$toBBOX(260500,261500,6652500,6653000),
                             filename = "dom_25833_1.tif",
                             RESX = 1, RESY = 1)

This will allow to reproduce the GetCoverage you did manually.

This said, I will keep investigating about the above request made with WCS 2.0.1, and will use this WCS server for further tests.

Let me know

pmlefeuvre-met commented 10 months ago

Thanks Emmanuel! I now uses your last solution that works perfectly for my use! Thanks for your help! Cheers, PiM

eblondel commented 10 months ago

Great to hear @pmlefeuvre-met! thanks for your feedback