Cut by region extent

Author: Paulo van Breugel
Updated on: 2016-04-22


One of the great features of GRASS GIS is the concept of the region. In GRASS, a region refers to a geographic area with some defined boundaries, based on a specific map coordinate system and map projection and a specific spatial resolution. The region's boundaries are given as the northernmost, southernmost, easternmost, and westernmost points that define its extent.

Typically all raster and display modules are affected by the current region settings, but not vector modules. So what if you are working with a specific region, and you have a vector layer that extents beyond the region bounds, and you want to limit your vector layer to that region. In other words, how can you cut out a vector layer by the region extents?


The v.in.region function creates a vector polygon from the current region extent. You can subsequently use that newly created vector to cut out your areas of interest from the original vector layer. For example, if we have the map of the United States (e.g, from the Global Administrative Areas database) and we want to cut out the region defined by north=348000, south=-16000, west=124000 and east=964000 (for the curious, this is the extent of North Carolina in the NC sample database).

On the command line

g.region n=348000 s=-16000 w=124000 e=964000
v.in.region output=VectRegion
v.overlay ainput=USA_adm1 binput=VectRegion operator=and output=USA_adm1cut
g.remove -f type=vector name=VectRegion 

In Python/ in the wxGUI Interactive Python Shell

from grass.script import parser, run_command
run_command("g.region", flags='a', n="348000", s="-16000",
            e="964000", w="124000")
run_command("v.in.region", output="VectRegion", type="area", cat=1)
run_command("v.overlay", ainput="USA_adm1", atype="auto", binput="VectRegion", 
		btype="area", operator="and", output="Final_output")
run_command("g.remove", flags='f', type="vector", name="VectRegion") 

Using the graphical model builder

You can also build and run the above in the graphical model builder. To run the model below, download the model defintion file and open it in the graphical modeler.


Software: @grassgis @python @bash
Tools: @graphical_model_builder @v_in_region @v_overlay
Subject: @region @cut