Cropping maps means taking the contents of one map (the source) and eliminating all data outside of the area you are studying (the boundary) to yield a smaller new map (the cropped map). Techniques differ depending on whether your source is raster or vector and whether your boundary is defined by another map or by coordinates. You especially might want to do this with vectors because GRASS operations always operate on the whole vector map, even features outside of the current region.
Vector source map and vector map as boundary. Use
. Example: you have a map of roads of the USA and you want a map of only roads in California. Formerly the module operator=and
did this task; it has however been replaced by
in GRASS release 6.
Vector source map and coordinates as boundary. Set region to desired coordinates (
), create new vector from region extent to use as boundary using
Raster source map and raster map as boundary. Make boundary into mask using
then copy raster source to new map (
). All cells outside of the mask will be omitted from the new copy. Alternately, use
- "cropped = if(boundary,raster_source)"
- map=cropped rast=source # may be required to transfer the color table
Raster source map and vector boundary. Convert the vector to a raster mask (1 where inside, null elsewhere):
- in=vector_boundary out=raster_boundary use=val value=1
Then proceed as above for two rasters.