1

There is a certain WCS layer that I'd like to save it to my local computer for analysis.

According to GDAL WCS driver draft:

"Accessing a WCS server is accomplished by creating a local service description xml file looking something like the following, with the coverage server url, and the name of the coverage to access. It is important that there be no spaces or other content before the element.

<WCS_GDAL>
   <ServiceURL>http://laits.gmu.edu/cgi-bin/NWGISS/NWGISS?</ServiceURL>
   <CoverageName>AUTUMN.hdf</CoverageName>
</WCS_GDAL>

I tried to create the xml file but I was unsuccessful.

Does anyone has any experience about extracting WCS layers? Are there any pointers (sites, tutorials, tips) on how to create the xml file?

EDIT:

The xml file im using to grab the first layer for a specific time is the following:

<WCS_GDAL>
   <ServiceURL>http://dmcsee.org/cgi-bin/mapserv?map=/var/www/tmp/dmcsee_wms/dmcsee_wcs.map</ServiceURL>
   <Version>1.1.1</Version>
   <CoverageName>SPI6</CoverageName>
   <supportedCRSs>EPSG:4326</supportedCRSs>
   <PreferredFormat>gtiff</PreferredFormat>
   <GetCoverageExtra>&amp;BBOX=10.0,31.995,48.005,50.0&amp;time=19900101</GetCoverageExtra>
</WCS_GDAL>

But for somereason returns an error

4
  • Are you trying to automate the download? Because the data's available from website: dmcsee.org/en/drought_monitor
    – mkennedy
    Nov 14 '12 at 17:25
  • Yes that's why I trying to use gdal_translate. I want to check how the index changes over a period of time.
    – nickves
    Nov 14 '12 at 18:02
  • 2
    What does gdalinfo wcs.xml return? I found that OWSLib (geopython.github.com/OWSLib) was very useful for accessing WCS'.
    – dmci
    Nov 15 '12 at 7:59
  • I didn't know about geopythons OWSlib. Sounds really promising I might be able to use that instead!
    – nickves
    Nov 15 '12 at 16:20
4

Using python's OWSlib which was suggest by I was able to programmatically acquire the data.

Here's the script I used for future reference:

import os
from owslib.wcs import WebCoverageService as w  #owslib ->https://github.com/geopython/OWSLib
                                                #easy_install owslib

folder = 'c:\\path\\to\\folder\\'
wcs = w(url="http://dmcsee.org/cgi-bin/mapserv?map=/var/www/tmp/dmcsee_wms/dmcsee_wcs.map",version="1.0.0")
spi6 = w['SPI6']  #The layer I am interested in 

for timep in spi6.timepositions :
   output = wcs.getCoverage('SPI6',time=[timep],bbox=(10.0,31.995,48.005,50),format='GTiff',CRS='EPSG:4326', WIDTH=380, HEIGHT=120)
   f = open(os.path.join(folder,'spi6_'+str(timep)+'.tiff'),'wb')
   f.write(output.read())
   f.close()

The above python script successfully downloaded and wrote 270+ geotiffs with their georeferenced data.

2
  • For some struggling with this, OWSLib doesn't seem to support all WCS protocols at the moment despite the documentation (e.g., 1.1.1)
    – cefect
    Mar 27 at 18:16
  • @cefect will this approach bring original data or translate cell size etc If I use QGIS to extract data it changes cell size and hence raster does not snap to each other. May 8 at 0:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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