Saturday, 23 June 2018

Use R to publish GeoTIFF as WMS in GeoServer


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 "myrastermyworkspacetrueGeoTIFF /usr/share/geoserver/data/data/myworkspace/myraster.tif" "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?



Answer




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 "EPSG:3005true" "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


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...