I have a raster named MODIS_All_India_NDVI_2001_01_01.tif in the database named agro_dss in PostGIS, in the public.modis_all_india_ndvi_2001_01_01 table.
The import was done using:
raster2pgsql -s 4326 -I -C -M D:\Advisory\Raster\MODIS_All_India_NDVI_2001_01_01.tif -F -t auto public.MODIS_All_India_NDVI_2001_01_01 | psql -U postgres -d agro_dss -h localhost -p 5432
as I am using
GeoServer Version
2.18.1
Git Revision
95cf8a329b0b51b69e1ea8d833bcb8b2ccc9b2be
Build Date
19-Nov-2020 15:33
GeoTools Version
24.1 (rev 7d309a25d2f0c857fd67c09b0d5392432d77fc4c)
GeoWebCache Version
1.18.1 (rev 08dd9de02426482f542b003f3bf381497939eb04/08dd9de02426482f542b003f3bf381497939eb04)
so I downloaded and installed the compatible version of GeoServer PGRaster community module (geoserver-2.18-SNAPSHOT-pgraster-plugin.zip)
I unzipped the files named
- gs-pgraster-2.18-SNAPSHOT.jar
- gt-imagemosaic-jdbc-24-SNAPSHOT.jar
in the directory C:\Program Files\Apache Software Foundation\Tomcat 9.0\webapps\geoserver\WEB-INF\lib
then added the path of raster2pgsql.exe in JAVA_OPTS of Tomcat configuration .exe as
-DRASTER2PGSQL_PATH=C:\Program Files\PostgreSQL\13\bin
I then restarted the Tomcat server, and it worked fine as I was able to see the ImageMosaicJDBC - Image mosaicking/pyramidal jdbc plugin in new Raster Data Sources
to Configure ImageMosaicJDBC store, I added these 3 files in the directory C:\Program Files\Apache Software Foundation\Tomcat 9.0\webapps\geoserver\data
1st file connect.pgraster.xml.inc
<connect>
<dstype value="DBCP"/>
<username value="postgres"/>
<password value="mypassword"/>
<jdbcUrl value="jdbc:postgresql://localhost:5432/agro_dss"/>
<driverClassName value="org.postgresql.Driver"/>
<maxActive value="10"/>
<maxIdle value="0"/>
</connect>
2nd 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>
3rd 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="mosaicpgraster"/>
<coordsys name="EPSG:4326"/>
<scaleop interpolation="1"/>
<axisOrder ignore="false"/>
&mapping;
&connect;
</config>
after this 1 added an additional table in agro_dss database to store 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)
);
then added the raster to this mosaic metadata table, and assigned the name mosaicpgraster:
insert into mosaic (name,tiletable) values ('mosaicpgraster','modis_all_india_ndvi_2001_01_01 table');
Finally, as I am creating new database in ImageMosaicJDBC store, I am getting the error while connecting the mosaicpgraster.pgraster.xml file in URL
This file is located in C:\Program Files\Apache Software Foundation\Tomcat 9.0\webapps\geoserver\data
for which, I have tried to parse the URL as
file:data/mosaicpgraster.pgraster.xml
and further as
http://localhost:8080/geoserver/data/mosaicpgraster.pgraster.xml
but I am getting errors both ways,
How to rectify it?