0

I'm using GRASS 7.6 to clip a raster (i.e. big_raster) layer on a smaller one (i.e. small_raster). Both the rasters are made by nan and 1 values.

I used the map calc tool

r.mapcalc expression="raster_clipped = if( “small_raster@PERMANENT” , "big_raster@PERMANENT" )"

Why do I get this error?

Invalid map <“small_raster@PERMANENT”>
Parse error
ERROR: parse error
Traceback (most recent call last):
  File "/usr/lib/grass76/gui/wxpython/gui_core/goutput.py",
line 473, in OnCmdOutput

self.cmdOutput.AddStyledMessage(message, type)
  File "/usr/lib/grass76/gui/wxpython/gui_core/goutput.py",
line 771, in AddStyledMessage

self.AddTextWrapped(message, wrap=None)
  File "/usr/lib/grass76/gui/wxpython/gui_core/goutput.py",
line 720, in AddTextWrapped

txt = EncodeString(txt)
  File "/usr/lib/grass76/gui/wxpython/core/gcmd.py", line
99, in EncodeString

return string.encode(_enc)
UnicodeDecodeError
:
'ascii' codec can't decode byte 0xe2 in position 27: ordinal
not in range(128)

1 Answer 1

3

Two things:

1-You have unnecessary quotes in your expression. No need to quote the map names. So:

r.mapcalc expression="raster_clipped = if( small_raster, big_raster)"

2-However,I think this is not what you want. This expression will not clip your big raster. You will get a new raster of the same size with values only where the small raster is not null. If you want to clip, then set the region to the small raster and then a simpler mapcalc expression:

g.region -p rast=small_raster
r.mapcalc expression="raster_clipped = big_raster"
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.