GDAL – How to Convert WMS GetMap Request to GeoTIFF?

gdalshellwms

I'm accessing a WMS server that doesn't provide geotiff as one of the format capabilities, but does provide PNG and KMZ.

http://tds.marine.rutgers.edu:8081/ncWMS/wms?SERVICE=WMS&REQUEST=GetCapabilities&VERSION=1.3.0

I'm thinking that it should be possible to write a little shell script that would either:

  1. Request KMZ and convert that to geotiff, using the implied SRS and
    bounding box info

  2. Request PNG and use the WMS query bounding box and SRS to create the
    geotiff, perhaps using gdal or similar

Has anyone done something like this, or is there a better way?

Thanks,
Rich

Best Answer

Try this:

#!/bin/bash
ulx=-76.80
lrx=-67.85
lry=34.58
uly=41.71
crs=EPSG:4326
url="http://tds.marine.rutgers.edu:8081/ncWMS/wms?LAYERS=espresso_4dvar%2Ftemp&ELEVATION=-0.986111111111111&TIME=2013-08-20T12%3A00%3A00.000Z&TRANSPARENT=true&STYLES=boxfill%2Frainbow&CRS=$crs&COLORSCALERANGE=2.156%2C28.6&NUMCOLORBANDS=254&LOGSCALE=false&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&EXCEPTIONS=XML&FORMAT=image%2Fpng&BBOX=$ulx,$lry,$lrx,$uly&WIDTH=1024&HEIGHT=1024"
curl -o foo.png $url 
gdal_translate -a_srs ${crs} -a_ullr $ulx $uly $lrx $lry foo.png foo.tif

Fixed the typo