Hello All,<br><br>I'm using mapserver to display some rasters as WMS layers using Openlayers. At the moment I have all my rasters in a web-readable folder and it works fine. I want to try accessing the rastes using postgis, but I'm not sure exactly how to do this. I've read through this <a href="http://mapserver.org/input/vector/postgis.html">http://mapserver.org/input/vector/postgis.html</a> and the relevant part of PostGIS in action. My original map file (which worked) looked like this:<br>
<br>LAYER<br>NAME "new_york_pop"<br>DATA "/home//htdocs/data/new_york_pop.tif"<br>STATUS OFF<br>TYPE RASTER<br>METADATA<br>"wms_title" "WMS new_york Raster"<br>"wms_srs" "EPSG:900913"<br>
END<br>END<br><br>I tried changing this to the following:<br><br>LAYER<br>NAME "new_york_pop"<br>TYPE RASTER<br>CONNECTIONTYPE POSTGIS<br>CONNECTION "host=18.00.00.00 dbname=raster_analysis user=postgres password=mypassword port=5434"<br>
DATA "SELECT ST_AsTIFF(ST_Clip(r.rast, 1, p.geom, NULL, TRUE)) FROM us_pop_800 AS r, cities AS p WHERE ST_Intersects(r.rast, p.geom) AND <a href="http://p.name">p.name</a> = 'new_york'"<br>STATUS OFF<br>
METADATA<br>"wms_title" "WMS new_york Raster"<br>"wms_srs" "EPSG:900913"<br>END<br>END<br><br>The SQL query runs fine within the SQL console of Postgresql and returns a few tiffs, but it does not work on mapserver. My mapserver error log shows the following:<br>
<br>[Tue Feb 14 12:16:29 2012].918681 msDrawMap(): Image handling error. Failed to draw layer named 'new_york_pop'.<br>[Tue Feb 14 12:16:29 2012].917535 msDrawMap(): rendering using outputformat named png (AGG/PNG).<br>
[Tue Feb 14 12:16:29 2012].918757 msDrawRasterLayerLow(): Unable to access file. Corrupt, empty or missing file 'SELECT ST_AsTIFF(ST_Clip(r.rast, 1, p.geom, NULL, TRUE)) FROM us_pop_raster AS r, cities AS p WHERE ST_Intersects(r.rast, p.geom) AND <a href="http://p.name">p.name</a> = 'new_york'' for layer 'new_york_pop'. <br>
[Tue Feb 14 12:16:29 2012].918766 msDrawMap(): Image handling error. Failed to draw layer named 'new_york_pop'.<br><br>I would appreciate any suggestions for debugging this. I have connected to the postgresql database using a php file from the same location so mapserver should have the correct permissions to connect (and my port is 5434, rather than the usual 5432).<br>
<br>Thank you,<br>David<br><br>