6

I'd like to automate downloading "slices" of data from a WCS service. This is a WCS 1.1.2 service, supporting netCDF. The data are updated daily - forecasts from an atmospheric regional model - and I'd like to automatically download netCDF "slices" of the data for a fixed geographical bounding box and for a couple of days out into the future. I am quite happy processing the netCDF once I've downloaded it.

The obvious brute-force approach is to read the OGC standard and devise the HTTP request myself, and code it up in some scripting language. I suspect I'll end up doing that. But it just feels wrong.

Can anyone recommend a WCS client library that I can use from code? Or a WCS client that I can run from a command-line? I know I could probably script QGIS or Grass or ArcGIS or something, but that seems too heavy a requirement for this task.

Can GDAL do it? Google has turned up the BADC Python WCS library (PDF) (now in OWSlib?) which I will take a look at. Java and GeoTools might be a possibility. And there's the OGC list of WCS clients which I could trudge through.

This is on the Windows platform. A .Net library would be ideal :)

I haven't linked to the actual WCS service as it's not yet publicly operational. But here is an edited GetCapabilities request below, in case anyone's interested in the details

<Capabilities xmlns:xlink="http://www.w3.org/1999/xlink"  
  xmlns:ows="http://www.opengis.net/ows/1.1" xmlns="http://www.opengis.net/wcs/1.1"  
 version="1.1.2">  
<Contents>  
<CoverageSummary>  
<ows:WGS84BoundingBox crs="urn:ogc:def:crs:OGC:2:84">  
<ows:LowerCorner>+0.0000 -90.0000</ows:LowerCorner>  
<ows:UpperCorner>+358.8750 +90.0000</ows:UpperCorner>  
</ows:WGS84BoundingBox>  
<SupportedCRS>urn:ogc:def:crs:EPSG::4326</SupportedCRS>   
<SupportedCRS>urn:ogc:def:crs:OGC:2:84</SupportedCRS>  
<SupportedFormat>image/netcdf</SupportedFormat>  
<SupportedFormat>application/x-netcdf</SupportedFormat>  
<Identifier>------------</Identifier> 
</CoverageSummary> 

1 Answer 1

4

WCS is the less-used of the WMS/WFS/WCS triangle so there isn't as much out there as you've probably noticed.

However, making requests is really really easy and you don't really need a special library. Arguably its the easiest of the three from a users perspective because you get a nice simple file back.

A valid request looks something like this:

http://my.host.com/cgi-bin/mapserv?map=mywcs.map&SERVICE=wcs &VERSION=1.0.0&REQUEST=GetCoverage&coverage=bathymetry&CRS=EPSG:42304&OX=-2200000,-712631,3072800,3840000&WIDTH=3199&HEIGHT=2833&FORMAT=GTiff

It may look complex, but broken down its very simple:

http://my.host.com/cgi-bin/mapserv?map=mywcs.map
&SERVICE=wcs
&VERSION=1.0.0
&REQUEST=GetCoverage
&coverage=bathymetry
&CRS=EPSG:42304
&BBOX=-2200000,-712631,3072800,3840000
&WIDTH=3199
&HEIGHT=2833
&FORMAT=GTiff

As you can see, most of them are self explanatory. So you just need to concatenate a string that has those variables. Most of them will probably be constants.

Coverage is the name of the layer you're requesting.

BBOX is the hardest part to do as you need to get the coordinates from somewhere.

I understand the point of libraries, but when something's this simple, "re-inventing the wheel" is actually a sensible option. You do of course need some sort of HTTP library.

A search for WCS GetCoverage finds other examples. This page has a live example: http://www.mapserver.org/ogc/wcs_server.html#test-your-wcs-1-0-server

2
  • +1 because I suspect this is exactly what I will do. I've done it before when I wanted to get images from a WMS.
    – MarkJ
    Commented Nov 16, 2012 at 12:15
  • Reporting back to say, yes, this is what I actually did...
    – MarkJ
    Commented Feb 24, 2015 at 15:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.