Hi,

I need some help with python scripting. I'm running r.stats on two raster maps such as this:

        rstats_results  = gscript.read_command('r.stats',
                             input_=[a, b],
                             flags='n1',
                             separator='comma',
                             quiet=True)
        results = rstats_results.splitlines()


This gives me

['123,456', '456,789', '987,321']

Does anyone know an efficient way to transform this into a list of lists of numbers, such as:

[[123, 456], [456, 789], [987, 321]]

I know I can do this as follows:

mylist = []
for line in results:
        mylist.append([int(line.split(',')[0]), int(line.split(',')[1])])

But for very large raster maps this does not seem very efficient.

Is there a way of getting the output directly as a list of lists ? Or a more efficient transformation ?

Moritz
_______________________________________________
grass-dev mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/grass-dev

Reply via email to