I’ve been trying to automate the publishing of GeoTIFF rasters as a Web Map Service (WMS) to GeoServer using R. So far I’ve only been able to establish a new datastore from inside R using this:

system(paste('curl -u admin:geoserver -v -XPOST -H "Content-type: application/xml" -d "<coverageStore><name>myraster</name><workspace>myworkspace</workspace><enabled>true</enabled><type>GeoTIFF</type><url> /usr/share/geoserver/data/data/myworkspace/myraster.tif</url></coverageStore>" "http:// my_mv_ip/geoserver/rest/workspaces/myworkspace/coveragestores"', sep=""))

Similarly, you can also do this using the geosapi package in R. (https://github.com/eblondel/geosapi/wiki). But progressing to the next step of adding and publishing a GeoTIFF as a Web Map Service (WMS) has been problematic and raster management is currently not supported with geosapi.

How do I publish GeoTIFFs as WMS to GeoServer in R?

1 Answer 1


Figured it out by further configuring the REST interface.

  1. Create the coverage store from the server-resident file (which automatically creates a coverage as well).

    system(paste('curl -f -k  -u admin:geoserver -XPUT -H "Content-type: text/plain" -d "/usr/share/geoserver/data/data/myworkspace/myraster.tif" "http:// my_mv_ip/geoserver/rest/workspaces/myworkspace/coveragestores/myraster/external.geotiff"',sep=""))
  2. Set the SRS and enable the coverage:

    system(paste('curl -s -k  -u admin:geoserver -XPUT -H "Content-type: text/xml" -d "<coverage><srs>EPSG:3005</srs><enabled>true</enabled></coverage>" "http:// my_mv_ip/geoserver/rest/workspaces/myworkspace/coveragestores/myraster/coverages/myraster"',sep=""))

Reference: http://osgeo-org.1560.x6.nabble.com/How-to-use-REST-to-create-a-coverage-from-a-TIF-file-with-no-explicit-SRS-td5330129.html

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.