0

This is the first time I am using GRASS GIS. I would very much appreciate help.

I am using python, grass scripts, GRASS version 7.8.6. I tried to debug as much as possible and I think the problem is in MASK creation. It is not behaving as expected. Stats shows NAN and further in my code I clip the raster. The clipped raster's stats too is NaN. I would appreciate any hints. Thank you.

Code:

print('-----------setting MASK: START --------------')
gscript.parse_command('r.mask', vector='poly')
stats = gscript.parse_command('r.univar', map='MASK', flags='g')
print(f'r.univar --> {stats}')
gscript.parse_command('r.out.gdal', input='MASK', output='mask.tif', overwrite=True, flags='c')
print('-----------setting MASK: END--------------')

Output:

-----------setting MASK: START --------------
WARNING: No areas selected from vector map <poly@PERMANENT>
Writing raster map...
 100%
Writing raster map...
 100%
All subsequent raster operations will be limited to the MASK area. Removing
or renaming raster map named 'MASK' will restore raster operations to
normal.
r.univar --> {'n': '0', 'null_cells': '113433108', 'cells': '113433108', 'min': '-nan', 'max': '-nan', 'range': '-nan', 'mean': '-nan', 'mean_of_abs': '-nan', 'stddev': '-nan', 'variance': '-nan', 'coeff_var': '-nan', 'sum': '-nan'}
Checking GDAL data type and nodata value...
 100%
Using GDAL data type <Int32>
Input raster map contains cells with NULL-value (no-data). The value
-2147483648 will be used to represent no-data values in the input map. You
can specify a nodata value with the nodata option.
Exporting raster data to GTiff format...
 100%
r.out.gdal complete. File <mask.tif> created.
-----------setting MASK: END--------------
SDH
  • 11
  • 2

0 Answers0