With GeoServer 3.0.2 (and 2.28), I am currently not able to reproduce this ImageMosaic example from the GeoServer docs.
With the test instance below, creating image mosaics from files stored in the GeoServer data dir, or from local GeoTiff or COG files uploaded to GeoServer via its REST API works as expected.
However, so far I had no success in creating mosaics from URLs pointing to remote COG files. Has someone been able to get it to work, or has an idea what could be the issue?
Test Setup
The test setup (on Ubuntu Linux) is started with:
docker compose -f docker-compose.yml up
with docker-compose.yml:
services:
geoserver:
image: docker.osgeo.org/geoserver:3.0.2
ports:
- "8080:8080"
environment:
- INSTALL_EXTENSIONS=true
- COMMUNITY_EXTENSIONS=cog-http
- EXTRA_JAVA_OPTS=-Diio.https.aws.region=us-west-2
- POSTGRES_JNDI_ENABLED=true
- POSTGRES_HOST=postgis
- POSTGRES_PORT=5432
- POSTGRES_DB=geoserver
- POSTGRES_USERNAME=geoserver
- POSTGRES_PASSWORD=geoserver
- POSTGRES_JNDI_RESOURCE_NAME=jdbc/postgresql
volumes:
- ./geoserver_data:/opt/geoserver_data/:Z
- ./additional_libs:/opt/additional_libs:Z # by mounting this we can install libs from host on startup
postgis:
image: postgis/postgis:17-3.4-alpine@sha256:5a1dbedac34e0e6663f8b7190d393339571f1cb3ecb2ab2f724524b4f3c7956e
ports:
- "5555:5432"
environment:
POSTGRES_USER: geoserver
POSTGRES_PASSWORD: geoserver
volumes:
- ./postgis/postgresql_data:/var/lib/postgresql/data:Z
On the host (in the command line), I create the modisvi database in PostGIS:
export PGHOST=localhost
export PGPORT=5432
export PGUSER=geoserver
export PGPASSWORD=geoserver
#export PGDATABASE=geoserver
# NOTE db geoserver already exists and contains postgis extension
psql
# enter commands below in psql prompt
CREATE DATABASE modisvi;
\c modisvi
CREATE EXTENSION postgis;
The *.properties files are created as in the example and zipped with:
zip modisvi.zip *properties
In GeoServer admin web interface, create a workspace test.
To test the database connection, I create a new PostGIS datastore with the above settings in the GeoServer admin interface, and create a new featuretype in the datastore. With psql I confirm that this creates a new table in the configured database.
REST API Call: Init Datastore
The very first REST API call from the example:
curl -u admin:geoserver -XPUT --write-out %{http_code} -H "Content-type:application/zip" --data-binary @modisvi.zip http://localhost:8080/geoserver/rest/workspaces/test/coveragestores/modisvi/file.imagemosaic?configure=none
fails with a 500. GeoServer verbose log output is attached below.
REST API Call: Working Example with Local File
After some experimenting, I found that the above REST API call succeeds if modisvi.zip includes a geotiff file, and the line Cog=true is removed from indexer.properties.
The log output is attached below.
However, this adds a local file to the mosaic, not a URL, which is of course not practical for large COGs.
It also does not seem to store any data in PostGIS, as there is no new table in the configured database. The REST API call stores files from modis.zip below ${GEOSERVER_DATA_DIR}/data/test/modisvi/modisvi/.
REST API Call: Adding URL
Trying to add a URL to the mosaic with:
curl -u admin:geoserver -XPOST -H "Content-type: text/plain" --write-out %{http_code} -d "https://modis-vi-nasa.s3-us-west-2.amazonaws.com/MOD13A1.006/2018.01.01.tif" "http://localhost:8080/geoserver/rest/workspaces/test/coveragestores/modisvi/remote.imagemosaic"
This creates additional files in the data store: modisvi.properties, modisvi.shp, etc.
However, file modisvi.dbf does not contain the added URL, only the local tiff file uploaded in modisvi.zip.