You can use the grass.script module 'read_command' to save the output of
commands. i.e.
In [1]: import grass.script as gscript
In [2]: rast_list = gscript.read_command('g.list', type='rast',
mapset="shkharia").strip().split('\n')
In [3]: type(rast_list)
Out[4]: list
In [5]: rast_list
Out[6]: ['aspect_4m', 'dtm_08_4m', 'dtm_4m', 'geomorph', 'shade_4m',
'slope_4m']
Typically the output will be a string (or dict), but calling split('\n')
breaks it into a list.
On 12/12/20 1:07 PM, BHARATH RAM wrote:
Hello,
I have a list of raster files inside a mapset that I need to
interpolate to a different size. I am aware of the command *g.list
type='raster' mapset='.'*
and its equivalent python version. But the command prints the
filenames out on screen instead of returning it as a list (I am
talking wrt python API).
Am I missing something or is there any workaround for this?
Thank you.
Regards,
Bharath.
------------------------------------------------------------------------
*Disclaimer: *This email and any files transmitted with it are
confidential and intended solely for the use of the individual or
entity to whom they are addressed. If you have received this email in
error please notify the system manager. This message contains
confidential information and is intended only for the individual
named. If you are not the named addressee you should not disseminate,
distribute or copy this e-mail. Please notify the sender immediately
by e-mail if you have received this e-mail by mistake and delete this
e-mail from your system. If you are not the intended recipient you are
notified that disclosing, copying, distributing or taking any action
in reliance on the contents of this information is strictly prohibited.
_______________________________________________
grass-user mailing list
[email protected]
https://lists.osgeo.org/mailman/listinfo/grass-user
--
Micha Silver
Ben Gurion Univ.
Sde Boker, Remote Sensing Lab
cell: +972-523-665918
_______________________________________________
grass-user mailing list
[email protected]
https://lists.osgeo.org/mailman/listinfo/grass-user