I got a point layer into QGIS from postgresql database. After this I used a plugin to export it to a map file.After exporting the following is the starting of the map file.

 # Map image size
 EXTENT 59.396660 7.316000 105.983338 35.204001
 Imagecolor 255 255 255
 SIZE 100 100
 UNITS meters
 Imagetype jpeg

 FONTSET 'C:\ms4w\Apache\htdocs\fontset.txt'


Now when I change the size parameter to 600 400 and the units to dd. It gives me the following error while rendering the layer.

msDrawMap(): Image handling error. Failed to draw layer named 'growth_1'. msPostGISLayerWhichShapes(): Query error. Error executing query: ERROR: column "%growth_1_id%" does not exist LINE 1: ...ary(ST_Force_2D("the_geom"),'NDR'),'hex') as geom,"%growth_1... ^

First of all I am not sure why is it taking units as meter.But if I dont change it to dd , the legends come up but the layer is not rendered. Also the extent which i get is in the range of 100's and not the one which I have defined.

Could someone tell me where is this thing going wrong.

enter image description here


I assume this relates to Why does Mapserver throw "msQueryByPoint(): Search returned no results."? ? If so and as far as the error you are getting, I suspect its because you have not defined (does not exist?) a pk column in the postgis layer. Your growth_1 layer should include the USING UNIQUE in the DATA keyword e.g.:

CONNECTION "dbname='postgis' host=localhost port=5432 user='postgres' password='xxxxxxx' sslmode=disable"
DATA 'the_geom FROM "growth_1" USING srid=4326  USING unique [your_pk_column]'

I am not sure, but I pressume that if you don't define the unique column mapserver will assume its called [layer_name]_id and this is why you are getting this error.

Also, have a look at the mapserver documentation here and here

| improve this answer | |
  • I did try the unique column after I posted the question, but it doesnt seem to help my case: CONNECTION "dbname='postgis' host=localhost port=5432 user='postgres' password='xxxxxxx' sslmode=disable" DATA "the_geom FROM growth_1 USING unique oid USING srid=4326" – SNT Apr 26 '12 at 6:00
  • Are you sure OID exists in the table? I think OID is one of Postgis system fields. I would suggest creating a new unique column, call it-say- gid and then define this in the mapfile. i.e. ALTER TABLE xyz > > ADD COLUMN gid serial; I think I remember something about OIDs that are not supposed to be defined as the unique key in the mapfile. – mapoholic Apr 26 '12 at 6:44
  • I added a column named as oid .Now what happens is I get the query table output with field names but not the values. I shall add the screenshot of the query result. – SNT Apr 26 '12 at 7:03
  • You have asked this on a different question Senthil. Do you still get the error for THIS question? – mapoholic Apr 26 '12 at 8:29
  • I think this thread should be closed.I dont get this error any more . I get a new error now. – SNT Apr 26 '12 at 9:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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