[GIS] programmatically create and publish geotiff layer in geoserver

apigeoservergeotiff-tiffrest

We need to automatize process of creating datastore and publishing geotiff layer. Also, before publishing we need to change Declared SRS and to save Native Bounding Box to our database.

Geotiff file will be uploaded to the file system by our customer.

Yes, I`ve seen Create a Layer in GeoServer using REST, also I see that there is publishGeoTIFF(…) methods in Geoserver-manager in GeoServerRESTPublisher.java.

Another solution that I see – is to make all the operations with bot written with selenium or htmlUnit.

Could you please suggest us, what approach is more elegant and suitable for us. Is there any actions in our workflow that we will not be able to do with Geoserver-manager.

P.S.: we also have seen at gsrcj project, but it can`t create programmatically geotiff layer.

Thank you in advance,
Dmitry.

Best Answer

I was able to do it using geoserver-manager.

The code is:

GeoServerRESTPublisher geoServerRESTPublisher = new GeoServerRESTPublisher("http://localhost:8090/geoserver", "admin", "geoserver");
geoServerRESTPublisher.publishGeoTIFF("myWS", "myTiff", "myTiff",
        new File("d:\\work\\myTiff.tif"), "EPSG:900913",
        GSResourceEncoder.ProjectionPolicy.REPROJECT_TO_DECLARED, defaultRasterStyle, null);

Now I am working on how to get bbox of just the created layer.