Hello All,<br><br>I&#39;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&#39;m not sure exactly how to do this. I&#39;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 &quot;new_york_pop&quot;<br>DATA    &quot;/home//htdocs/data/new_york_pop.tif&quot;<br>STATUS  OFF<br>TYPE    RASTER<br>METADATA<br>&quot;wms_title&quot;  &quot;WMS new_york Raster&quot;<br>&quot;wms_srs&quot;    &quot;EPSG:900913&quot;<br>
END<br>END<br><br>I tried changing this to the following:<br><br>LAYER<br>NAME &quot;new_york_pop&quot;<br>TYPE    RASTER<br>CONNECTIONTYPE POSTGIS<br>CONNECTION &quot;host=18.00.00.00 dbname=raster_analysis user=postgres password=mypassword port=5434&quot;<br>
DATA &quot;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> = &#39;new_york&#39;&quot;<br>STATUS  OFF<br>
METADATA<br>&quot;wms_title&quot;  &quot;WMS new_york Raster&quot;<br>&quot;wms_srs&quot;    &quot;EPSG:900913&quot;<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 &#39;new_york_pop&#39;.<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 &#39;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> = &#39;new_york&#39;&#39; for layer &#39;new_york_pop&#39;. <br>
[Tue Feb 14 12:16:29 2012].918766 msDrawMap(): Image handling error. Failed to draw layer named &#39;new_york_pop&#39;.<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>