Re: [GRASS-user] How to obtain list of all raster maps

2020-12-12 Thread BHARATH RAM
Dear Mr. Neteler & Mr. Silver,

Thank you both for your responses. Yes both of the methods seems to be
working.

Also, while going through some other documentation i discovered another
metho. We can output the entire data into a text file by including an
output argument in the command. (*g.list type='raster' mapset='.'
output='rasterNames.txt' )*

Problem solved... Thanks

Regards,
Bharath

Bsr

On Sat, Dec 12, 2020, 5:05 PM Micha Silver  wrote:

> 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
> > grass-user@lists.osgeo.org
> > https://lists.osgeo.org/mailman/listinfo/grass-user
>
> --
> Micha Silver
> Ben Gurion Univ.
> Sde Boker, Remote Sensing Lab
> cell: +972-523-665918
>
>

-- 
*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
grass-user@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/grass-user


[GRASS-user] How to obtain list of all raster maps

2020-12-12 Thread BHARATH RAM
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
grass-user@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/grass-user


Re: [GRASS-user] How to obtain list of all raster maps

2020-12-12 Thread Micha Silver
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
grass-user@lists.osgeo.org
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
grass-user@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/grass-user


Re: [GRASS-user] How to obtain list of all raster maps

2020-12-12 Thread Markus Neteler
Hi

BHARATH RAM  schrieb am Sa., 12. Dez. 2020, 12:07:

> 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).
>


Would this work for you?

https://grasswiki.osgeo.org/wiki/GRASS_Python_Scripting_Library#Interface_to_listing_maps_.28g.list.29

Best
Markus
___
grass-user mailing list
grass-user@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/grass-user