Dear Nikos and Micha,

I tried both and worked ways for constructing the list and worked well:



and also:



but still have an error problem with the loop

why could be this happening?
Thanks a lot.
Gabriel

On Wed, Jul 11, 2018 at 5:00 AM, Nikos Alexandris <[email protected]>
wrote:

> * Nikos Alexandris <[email protected]> [2018-07-11 09:14:47 +0200]:
>
>
>> Gabriel Cotlier wrote:
>>
>>>
>>>    I'm using grass 7.4.1 trying to export  all raster layers in the
>>> current
>>>    mapset out of grass to a folder as GeoTiff files though a for loop
>>> from
>>>    the python shell  as follows and I'm getting the error in red...
>>>    What could be the problem?
>>>    Thanks a lot in advance.
>>>    Regards,
>>>    Gabriel
>>>    >>>import grass.script as gscript
>>>    >>>rastlist=grass.read_command("g.list",type="rast")
>>>    >>>rastlist
>>>    F121996
>>>    F121997
>>>    F141999
>>>    F142000
>>>
>>
>> Micha Silver:
>>
>>>  Try:
>>>  rastlist=grass.read_command("g.list",type="rast").split()
>>>
>>
>> [..]
>>
>
> For me it works like:
>>
>> rasters=grass.read_command('g.list', type='raster',
>> separator='comma').split(',')
>>
>
> For splitting on newlines, there is splitlines(), i.e.
>
> ```
> rasters = grass.read_command('g.list', type='raster').splitlines()
> for raster in rasters:
>    print "Raster:", raster
>    raster += '.tif'
>    print "Raster with extension:", raster
> ```
>
> See https://docs.python.org/2/library/stdtypes.html#str.splitlines
>
> Nikos
>
> _______________________________________________
> grass-user mailing list
> [email protected]
> https://lists.osgeo.org/mailman/listinfo/grass-user
>
_______________________________________________
grass-user mailing list
[email protected]
https://lists.osgeo.org/mailman/listinfo/grass-user

Reply via email to