11

I use GeoServer where I created an ImageMosaic storage following this manual. When I create a new datastore, all *.tif files are indexed into the DB (PostgreSQL with PostGIS). How can I create new index entry in the DB, when I put new geotiff into my data folder, or reindex all geotiff files in the DB?

My config files:

datastore.properties:

SPI=org.geotools.data.postgis.PostgisNGDataStoreFactory
host=localhost
port=5432
database=GeoServerRaster
schema=public
user=geoserver
passwd=*******
Loose\ bbox=true
Estimated\ extends=false
validate\ connections=true
Connection\ timeout=10
preparedStatements=true

indexer.properties:

Caching=false
TimeAttribute=ingestion
ElevationAttribute=elevation
Schema=*the_geom:Polygon,location:String,ingestion:java.util.Date,elevation:Integer
PropertyCollectors=TimestampFileNameExtractorSPI[timeregex](ingestion),DoubleFileNameExtractorSPI[elevationregex](elevation)

timeregex.properties:

regex=[0-9]{8}T[0-9]{6}Z(\?!.\*[0-9]{8}T[0-9]{6}Z.\*)

elevationregex.properties:

regex=(?<=_)(\\d{1,5})(?=_)

files in directory:

tc_10000_20140807T033115Z.tif
tc_10000_20140807T040046Z.tif
tc_10000_20140807T043115Z.tif
...
5

IMHO the best way how to do it is via REST with the curl command.

To reindex the whole existing ImageMosaic, use something like the following command (remember to set correct username, password, workspace name, ImageMosaic store name and the path to the granules directory):

curl -v -u username:password -XPOST -H "Content-type: text/plain" \
 -d "file:///path/to/your/image/mosaic/directory/" \
 "http://localhost:8080/geoserver/rest/workspaces/YOUR_WORKSPACE/coveragestores/YOUR_IMAGEMOSAIC_STORE/external.imagemosaic"

This will delete all granules from the current index and then add existing files one by one. It is very time consuming.

I prefer adding a single granule (i.e. 1 raster file):

curl -v -u username:password -XPOST -H "Content-type: text/plain" \
 -d "file:///path/to/your/image/mosaic/directory/and/your/granule.tiff" \
 "http://localhost:8080/geoserver/rest/workspaces/YOUR_WORKSPACE/coveragestores/YOUR_IMAGEMOSAIC_STORE/external.imagemosaic"

Both examples assume the raster files are already present at the specified location (that's specified by external.imagemosaic at the end of the URL).

More examples are in the GeoServer docs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.