We already have srtm_1arc_v3.tif
raster on the postgis_raster
database, in the rasters.dem
table.
The import was done using:
raster2pgsql -s 3763 -N -32767 -t 100x100 -I -C -M -d srtm_1arc_v3.tif rasters.dem | psql -d postgis_raster -h localhost -U geobox -p 5432
We will need the GeoServer PGRaster community module.
Download and install the version for your current GeoServer installation.
cd /var/lib/tomcat7/webapps/geoserver/WEB-INF/lib
sudo unzip ~/Transferências/geoserver-2.10-SNAPSHOT-pgraster-plugin.zip
Restart Geoserver.
We need some configuration files for the ImageMosaicJDBC plugin.
Put these files in our GEOSERVER_DATA_DIR/data
.
File connect.pgraster.xml.inc
<connect>
<dstype value="DBCP"/>
<username value="geobox"/>
<password value="geobox"/>
<jdbcUrl value="jdbc:postgresql://localhost:5432/postgis_raster"/>
<driverClassName value="org.postgresql.Driver"/>
<maxActive value="10"/>
<maxIdle value="0"/>
</connect>
File mapping.pgraster.xml.inc
<spatialExtension name="pgraster"/>
<mapping>
<masterTable name="mosaic" >
<coverageNameAttribute name="name"/>
<maxXAttribute name="maxX"/>
<maxYAttribute name="maxY"/>
<minXAttribute name="minX"/>
<minYAttribute name="minY"/>
<resXAttribute name="resX"/>
<resYAttribute name="resY"/>
<tileTableNameAtribute name="tiletable" />
</masterTable>
<tileTable>
<blobAttributeName name="rast" />
</tileTable>
</mapping>
File mosaicpgraster.pgraster.xml
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE ImageMosaicJDBCConfig [
<!ENTITY mapping PUBLIC "mapping" "mapping.pgraster.xml.inc">
<!ENTITY connect PUBLIC "connect" "connect.pgraster.xml.inc">
]>
<config version="1.0">
<coverageName name="oek"/>
<coordsys name="EPSG:3763"/>
<scaleop interpolation="1"/>
<axisOrder ignore="false"/>
&mapping;
&connect;
</config>
We need one additional table on our postgis_raster
database to store simple mosaic metadata.
CREATE TABLE public.mosaic (
name character varying(254) COLLATE pg_catalog."default" NOT NULL,
tiletable character varying(254) COLLATE pg_catalog."default" NOT NULL,
minx double precision,
miny double precision,
maxx double precision,
maxy double precision,
resx double precision,
resy double precision,
CONSTRAINT mosaic_pkey PRIMARY KEY (name, tiletable)
);
Add our raster to this mosaic
metadata table, assigning the name mosaicpgraster
:
insert into mosaic (name,tiletable) values ('mosaicpgraster','rasters.dem');
Create a new ImageMosaicJDBC
store.
For the URL, use the file we created: file:data/mosaicpgraster.pgraster.xml
.
Save it.