Retrieve list of values in Python

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Retrieve list of values in Python

Jenny Turner
Greetings

I would like to know how can I retrieve the list of available values in a Raster map in a Python Script?
Thanks
Best regards,
Jenny Turner

_______________________________________________
grass-user mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-user
Reply | Threaded
Open this post in threaded view
|

Re: Retrieve list of values in Python

Christian Schwartze
In order to get a list, here is just one approach:
vals = os.popen(“r.stats –Nn your_map”).readlines()
 
Christian.
 
Sent: Tuesday, March 29, 2011 11:55 PM
Subject: [GRASS-user] Retrieve list of values in Python
 
Greetings
 
I would like to know how can I retrieve the list of available values in a Raster map in a Python Script?
Thanks
Best regards,
Jenny Turner


_______________________________________________
grass-user mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-user

_______________________________________________
grass-user mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-user
Reply | Threaded
Open this post in threaded view
|

Re: Retrieve list of values in Python

Martin Landa
Hi,

2011/3/30 Christian Schwartze <[hidden email]>:
> In order to get a list, here is just one approach:
> vals = os.popen(“r.stats –Nn your_map”).readlines()

use GRASS Scripting Library [1]

grass.read_command('r.stats', flags='Nn',input = 'map').splitlines()

Martin

[1] http://grass.osgeo.org/programming7/pythonlib.html

--
Martin Landa <landa.martin gmail.com> * http://geo.fsv.cvut.cz/~landa
_______________________________________________
grass-user mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-user