I'm having trouble getting a PostGIS raster to load and display in MapServer. I'm not sure, but suspect it's a version problem. My mapfile layer and the error message are shown below.

    NAME bio12_2_5m
    TYPE raster
    DATA "PG:host=localhost port=31600 dbname='wdata' user='postgres' password='*****' schema='worldclim' table='bio12_2_5m'"  

msDrawMap(): Image handling error. Failed to draw layer named 'bio12_2_5m'.
msDrawRasterLayerLow(): Unable to access file. Corrupt, empty or missing file 'PG:host=localhost port=31600 dbname='wdata' user='postgres' password='**' schema='worldclim' table='bio12_2_5m'' for layer 'bio12_2_5m'. Sorry, but table bio12_2_5m doesn't seem to have regular blocking arrangement. Only tables with regular blocking arrangement can be read from now

This is WorldClim data loaded into PostGIS with raster2pgsql like:

raster2pgsql -s 4326 bio12.bil worldclim.bio12_2_5m > bio12.sql

To get around what seems like a blocking problem I've also tried:

raster2pgsql -s 4326 -C -r bio12.bil worldclim.test > test.sql
raster2pgsql -s 4326 -t 10x10 bio12.bil worldclim.test2 > test2.sql

And with the MapServer layer I've tried setting mode=1 or mode=2, still no success.

Versions ... Ubuntu 12.04 LTS, PostgreSQL 9.1.11, GDAL 1.10.0, PostGIS 2.0.4 with raster support, and MapServer 6.0.1. But (always a but) to be fair I started with GDAL 1.7.3 via the default ubuntu repository, and at the end updated GDAL to 1.10.0 via the Ubuntu GIS "unstable" repository since it seems like the newer versions of GDAL are required to address/support the blocking items.

Thanks, very close I suspect and not sure if installing everything from scratch would help starting with the 1.10.0 GDAL. Also tried building GDAL from source and no success there.

1 Answer 1


With a bit more work I've answered my own question. It required setup and testing of a new server and then application to the existing server.

What I had done previously with GDAL ... enabled Ubuntu GIS "unstable" repository, installed what looked like the required update to 1.10.0:

sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable
sudo apt-get update
sudo apt-get install libgdal1-dev

This reported (seemingly incorrectly) that I was at 1.10.0 via gdal-config --version. What needed to be run:

sudo apt-get install gdal-bin

This got gdalinfo working and correctly reading the raster info from PostGIS with:

gdalinfo  "PG:host=localhost port=31600 dbname='wdata' user='postgres' password='****' schema='worldclim' table=bio12_2_5m"

Next step was MapServer:

sudo apt-get install cgi-mapserver
sudo apt-get install mapserver-bin

MapServer is now at 6.4.1 via /usr/lib/cgi-bin/mapserv -v

This got shp2img working like:

shp2img -m worldclim12.map -o worldclim12.png -all_debug 3

And, finally some tweaks to the layer file to make it into a WMS layer for consumption by leaflet:

  NAME bio12_2_5m
  TYPE raster
    "wms_title" "bio12_2_5m"
    "wms_srs" "EPSG:4326"
    "wms_enable_request" "*"
    "wms_feature_info_mime_type" "text/html" 
  EXTENT -180 -60 180 90
  DATA "PG:host=localhost port=31600 dbname='wdata' user='postgres' password='****' schema='worldclim' table='bio12_2_5m'"      

Moral to this story is I could understand more about how the various packages exist in the Ubuntu GIS "unstable" repository. Thus far still seems easier to goto these than build from source.

It's 30-40 seconds to render the image on a webpage so performance will be next.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.