As a simple test case, I'm trying to configure the software stack of OpenGeo such that I can display a GeoTIFF as an overlay to a normal map like OSM. So I perform the following steps:
- Create a spatial data base with postGIS
- Load the GeoTIFF into the data base
- Import the data base to GeoServer
- Preview it as a map overlay in GeoServer (e.g. with GeoExplorer or OpenLayers)
In contrary to a direct import of the GeoTIFF to Geoserver (which works formidably), the table imported from the data base is marked as "vector data" and not "raster data" in the GeoServer web application. In the Layer Preview, GeoExplorer does not display anything from the GeoTIFF and OpenLayers returns a WMS file reporting a ServiceExeption
:
The requested Style can not be used with this layer.
The style specifies an attribute of geom and the layer is: opengeo:test
I believe the solution is quite simple but it seems I do not understand how GeoServer interprets raster data stored in postGIS.
Can anybody tell me what point I'm missing?
My steps in detail:
- Create a spatial data base with postGIS as documented, taking
template_postgis
as a template and port 5432 as I operate on Ubuntu 12.04. Load the GeoTIFF into the data base from the command line using
raster2pgsql
as in (http://suite.opengeo.org/docs/dataadmin/pgGettingStarted/raster2pgsql.html)raster2pgsql -I -C -s 32632 test.tif public.testTable
| psql -d test -h localhost -U opengeowhere
-I
: flag to create the spatial GiST index for performance-C
: flag to apply the raster constraints-s 32632
: SRID oftest.tif
reported by toolgdalinfo
test.tif
: proper test GeoTIFFpublic.testTable
: new table in target schema-d test
: spatially enabled database-U opengeo
: owner of database (standard username)
- Import the data base to GeoServer as described in the official workshop
Answer
Install the Image Mosaic JDBC plugin
A GeoServer webpage hints at the root of the problem:
GeoServer does not come built-in with support for Postgis raster columns, it must be installed through an extension. Proceed to Image Mosaic JDBC for installation details. This extension includes the support for Postgis raster.
I followed the complex setup instructions there and managed to add an ImageMosaicJDBC Raster Data Source to my GeoServer.
Convert the GeoTIFF to 8bit
When it comes to serving/previewing the layer, the data does not get displayed properly as also experienced by another user [1]. As described there, a prior conversion of the GeoTIFF file from data type INT16 to BYTE resolved the issue (to the price of lower colour depth). The conversion can be done using the command-line tool gdal_translate:
$ gdal_translate -ot BYTE input.tif output.tif
Conclusion
You need the use the cumbersome ImageMosaicJDBC plugin and 8bit GeoTiffs to get the thing working. I did not find out why the preview modules (openLayer, GeoExt, JPEG preview,...) don't work with 16bit color depth. For the moment I agree on the comment that "PostGIS raster doesn't yet have that level of production use" [2].
[1] blank preview image for ImageMosaicJDBC (postgis raster) layer.
No comments:
Post a Comment