I am trying to find a least cost path script for Python. I came across r.drain from GRASS GIS. Is it possible to use GRASS GIS in a Python stand alone script? If so where can I download the bindings?
yes, see for example:
- GRASS and Python
- On scripting GRASS GIS: Building location-independent command line tools
- Python Scripts For GRASS GIS
- Using Python scripts that call GRASS modules or access GRASS layers from outside the GRASS.app with Mac OS X: a little summary
- How to access vector coordinates in GRASS GIS from python?
Yes, and there are more resources available now (besides the one listed by gene):
- Working with GRASS without starting it explicitly by manually setting some or all necessary variables and files
- grass.script.setup.init function which helps in setting up the required variables and files
- GRASS Batch jobs using
GRASS_BATCH_JOBenvironment variable and GRASS executable
- exec interface example for direct calling of GRASS executable with module or script as a parameter (available in the development version only, future 7.1 release)
- List of GRASS environment variables
API for Python are part of GRASS itself, so you just have to install GRASS GIS but note that GRASS does not add its packages to the system Python nor messes with it in any way (to be on the safe side). Similarly the GRASS executable does not not have to be on PATH, although it typically is in Linux distributions.