The goal in my current project is to create a WMS from a GeoTIFF raster layer that was previously uploaded to a PostgreSQL database with PostGIS enabled via "raster2pgsql". That worked out well and I can create a working WMS from a single raster.
My problem is when working with temporal raster data. I have e.g. a GeoTIFF with temperature data from Africa with 10 different bands, where every raster band corresponds to a different year (e.g. data from 1990 to 2000). I successfully uploaded the multiband raster to my database with raster2pgsql (raster2pgsql –s 4326 -F –I –C –t auto myraster.tif schema.table | psql –d database) and created a .map file so i can receive a valid WMS.
The .map file looks like this:
MAP
NAME "rd_hist"
IMAGETYPE PNG24
EXTENT -25 -48 60 44
SIZE 1000 1000
PROJECTION
"init=epsg:4326"
END
WEB
METADATA
"wms_title" "rd_hist"
"wms_onlineresource" "https://localhost/cgi-bin/mapserv?map=/ms4w/data/raster/rd_hist.map"
"wms_srs" "EPSG:4326"
"wms_enable_request" "*"
END
END
LAYER
NAME "rd_hist"
TYPE RASTER
STATUS ON
DATA "PG:host=localhost port=5432 sslmode=disable user=postgres password=**** dbname=**** schema=public table=rd_hist column=rast mode=2"
PROJECTION
"init=epsg:4326"
END
CLASS
NAME "rd_hist"
END
TEMPLATE "empty"
PROCESSING
"CLOSE_CONNECTION=DEFER"
END
WEB
METADATA
"wms_title" "rd_hist"
"wms_onlineresource" "http://localhost/cgi-bin/mapserv?map=/ms4w/data/raster/rd_hist.map"
"wms_srs" "EPSG:4326"
END
END
END
END
I now want to enable the layer, so that i can use the "&TIME=xxxx" Parameter on the WMS request to request a single band, corresponding to a specific year. I could not figure out to configure this with the help of the MapServer documentation as this only states WMS Time for vector layers outside of PostGIS.
I am also not quite sure if this approach is actually doable or if i have to upload every year from my raster as a single layer. Maybe there is also an easier solution with getting just a single band directly in the WMS getMap request. But in the end i have to request with the years, as users will be chosing which layer to load depending on the year.
How do I enable my multiband temporal raster that is stored in PostGIS so i can use the &TIME attribute to get only one layer? Is there maybe an easier solution i am not aware of, to store and get multitemporal raster data in PostGIS via MapServer?
PROCESSING "BANDS=x"
. Then read about variable substitution mapserver.org/cgi/runsub.html. Define a variable "BAND" to be used inPROCESSING "BANDS="%BAND%"
. But then you must write some pre-processor to convert a year into a corresponding band number. I think I would use single band rasters as TIFF files and tileindex.