I am attempting to follow the mapscript example described here - http://trac.osgeo.org/mapserver/wiki/RasterQuery

but ran into some trouble with

s = layer.getShape(result.shapeindex, result.tileindex)

It appears that this no longer works

In [63]: s = layer.getShape(result.shapeindex, result.tileindex)
TypeError                                 Traceback (most recent call last)
/Users/calvin/work/luc/<ipython-input-63-969295303151> in <module>()
----> 1 s = layer.getShape(result.shapeindex, result.tileindex)

/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/MapScript-6.0.1-py2.7-macosx-10.7-x86_64.egg/mapscript.pyc in getShape(self, *args)
   1395     def nextShape(self): return _mapscript.layerObj_nextShape(self)
   1396     def close(self): return _mapscript.layerObj_close(self)
-> 1397     def getShape(self, *args): return _mapscript.layerObj_getShape(self, *args)
   1398     def getNumResults(self): return _mapscript.layerObj_getNumResults(self)
   1399     def getResultsBounds(self): return _mapscript.layerObj_getResultsBounds(self)

TypeError: layerObj_getShape() takes exactly 2 arguments (3 given)

What is the argument I ought to supply to getShape method to get it working again?

2 Answers 2


EPIC FAIL: I apologize, I just found out that the documentation I mentioned is not up to date.

The correct API (taken from the swig interface file) is the following:


where result is the resultObj returned by getResult.

Opened ticket and updated documentation (will go live soon).

DOCUMENTATION mentioned in the answer below IS OUTDATED

The mapscript API for layerObj is fully documented here:


by reading it one finds out that getShape has been deprecated in favor of getFeature (which takes exactly two arguments, while getShape requires three, the first of them being a shapeObj).

So your code should be:

s = layer.getFeature(result.shapeindex, result.tileindex)
  • hello @unicoletti, it appears that I don't have a "getFeature" method in my layer object. And, also, the getShape method is asking for 2 arguments, not 3... Dec 29, 2011 at 3:15
  • you're right I revised the answer (blush)
    – unicoletti
    Dec 29, 2011 at 8:04
  • Thanks @unicoletti, nice answer and via your answer, I am also beginning to get an inkling on how to look at the special SWIG interface files to check for required arguments! Appreciate your help! Dec 29, 2011 at 8:29

Same with php

ex. $oRes = $oLayer->getResult($iRes);

$oShape = $oLayer->getShape($oRes); 
//instead of  $oShape = $oLayer->getShape($oRes->tileindex,$oRes->shapeindex);

thanx unicoletti!

Your Answer

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

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