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 "myraster myworkspace true GeoTIFF /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.
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=""))
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=""))
No comments:
Post a Comment