[GRASS-dev] Parsing output of r.category which includes labels
Stefan.Blumentrath at nina.no
Thu Aug 23 00:23:12 PDT 2018
Can you give us a bit more context?
What is it you want to achieve? How are you using r.stats and what is it you want to do with the output?
Personally, I am not too familiar with performance implications of NumPy vs. plain Python, but rather use NumPy for convenience in matrix/table operations (avoiding pandas)...
From: Nikos Alexandris <nik at nikosalexandris.net>
Sent: onsdag 22. august 2018 17:57
To: Stefan Blumentrath <Stefan.Blumentrath at nina.no>
Cc: GRASS-GIS development mailing list <grass-dev at lists.osgeo.org>
Subject: Re: [GRASS-dev] Parsing output of r.category which includes labels
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,
* Stefan Blumentrath <Stefan.Blumentrath at nina.no> [2018-08-20 10:48:34 +0000]:
>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
>map=base))) , delimiter='\t', dtype=None, names=['cat', 'label'])
>That causes however some overhead . So if it makes sense depends on what you want to do with the data in the further processing chain...
More information about the grass-dev