Stefan, a somewhat irrelevant question to the original subject:
do you think the NumPy way is worth to collage a series of `r.stats` outputs? Imagine administrative boundaries and one `r.stats` call for each. They may be tenths, or hundreds, or thousands as the script is meant to cover European wide extents. Or should I just work this out using native Python? Thank you for any thoughts, Nikos * Stefan Blumentrath <[email protected]> [2018-08-20 10:48:34 +0000]:
Hi Nikos,
You could use numpy and genfromtxt() to parse the output string...
genfromtxt() requires an StringIO object (or file) and StringIO (from io)
requires unicode()...
So you could do:
from io import StringIO
import numpy as np
output = np.genfromtxt(StringIO(unicode(grass.read_command('r.category',
map=base))) , delimiter='\t', dtype=None, names=['cat', 'label'])
That causes however some overhead [1]. So if it makes sense depends on what you
want to do with the data in the further processing chain...
Cheers
Stefan
1: https://docs.scipy.org/doc/numpy/user/basics.io.genfromtxt.html
[rest deleted]
signature.asc
Description: PGP signature
_______________________________________________ grass-dev mailing list [email protected] https://lists.osgeo.org/mailman/listinfo/grass-dev
