* 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 F142000Micha 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
signature.asc
Description: PGP signature
_______________________________________________ grass-user mailing list [email protected] https://lists.osgeo.org/mailman/listinfo/grass-user
