[GRASS-user] question on r.out.gdal in a loop
Gabriel Cotlier
gabiklm01 at gmail.com
Wed Jul 11 14:39:56 PDT 2018
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 <nik at nikosalexandris.net>
wrote:
> * Nikos Alexandris <nik at nikosalexandris.net> [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
> grass-user at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/grass-user
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-user/attachments/20180711/5ee0106e/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: micha.JPG
Type: image/jpeg
Size: 16284 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/grass-user/attachments/20180711/5ee0106e/attachment-0003.jpe>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: nikos2.JPG
Type: image/jpeg
Size: 17051 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/grass-user/attachments/20180711/5ee0106e/attachment-0004.jpe>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: results.JPG
Type: image/jpeg
Size: 54922 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/grass-user/attachments/20180711/5ee0106e/attachment-0005.jpe>
More information about the grass-user
mailing list