I have DEM named "HD_DEM" (asc file) and vector map for lakes that named "Lakes". I want to crop lakes from HD_DEM. By following instructions of this link https://grasswiki.osgeo.org/wiki/Cropping_maps ,I tried to crop.

v.to.rast in=Lakes@TEST out=Lakes_MASK3@TEST use=val value=1


r.mask vector=Lakes@TEST

the both gave me strange output. (Grey: Lakes, Yellows: output) mask_problem

1 Answer 1


First set your region to the lakes vector. Next, there's no need to convert to the vector mask layer to raster. Recent versions of r.mask can take a vector layer as input. But you need the -i option to create an "inverse" mask. So:

g.region -p vector=Lakes
r.mask -i vect=Lakes
r.mapcalc "HD_DWM_cropped = HD_DEM"

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.