- Extracts portion of the input map which overlaps with current region
Extracts portion of the input raster map which is in the current computational region
r.clip [-r] input=name output=name [--overwrite] [--help] [--verbose] [--quiet] [--ui]
- Resample input raster according to the computational region
- By default cell size and alignment of the original raster is preserved
- Allow output files to overwrite existing files
- Print usage summary
- Verbose module output
- Quiet module output
- Force launching GUI dialog
- input=name [required]
- Name of input raster map
- output=name [required]
- Name for output raster map
The module extracts portion of the input
raster map according to
the current computational region. The areas outside of the computational
region are clipped and only the inner part is kept.
raster map is left intact and a new (clipped)
raster map is created in the process.
By default the cell size and the cell alignment of the original raster
is preserved. In other words, the output map inherits its resolution and
cell positions (grid) from the input raster rather than the
If resampling into the cells size and cell alignment of the
current computational is desired, the module can perform a nearest
neighbor resampling when the -r flag is used.
If more advanced resampling is required, the user is advised to to use
one of the dedicated resampling modules.
If mask (r.mask) is active, it is
respected and the output raster map will contain NULL (no data) values
according to the mask.
Otherwise, values in the input raster map are simply transfered
to the output raster map.
The color table of the output raster map is set according to the
input raster map, so that the colors in both raster maps will match.
In GRASS GIS, clipping of rasters is usually not needed because
modules respect the current computational region and clipping
(with possible resampling) is done automatically.
If the user needs to clip raster map according to another raster map or
according to a vector map,
the g.region should be used first
before running the r.clip module.
The extent of the resulting map might be slightly different based on how
the cells of the input raster align with the cells of the computational
region. The mechanism for aligning in the background is the one used in
g.region. If exact match is
desired, user is advised to resolve the cell alignment ahead using
g.region and then use
r.clip with the -r flag.
The following examples are using the full North Carolina sample
First we set the computational region to match the raster map called
which we want to use for clipping:
Now, the following will clip raster map called elevation
according to the extent of elev_lid792_1m
raster map creating
a new raster map called elevation_clipped
r.clip input=elevation output=elevation_clipped
The following example clips (crops) raster map called elevation
according to the current region resulting in a new raster map called
The computational region will be set match raster map called
since this the extent we want to work with
in this example.
First we set the computational region to match a raster map called
This is the computational region we want to have.
Now we check the new region using:
In the output, we can see extent, resolution in both directions,
and number of rows and columns:
Now we perform the clipping:
r.clip input=elevation output=clipped_elevation
Finally, we check the size of the new raster map using:
r.info map=clipped_elevation -g
In the output, we can see that the extent is the same
(exactly the same in this case) as the computational region
while the resolution and number of cells is different:
The reason for this is that the elevation
map was not
resampled, instead the cell values and positions were preserved.
The number of cells depends on the resolution which was derived from
the original elevation
map. To see it, we can use the
The output shows the resolution used for the new
as well as much higher number of cells and
larger extent of the original map:
Vaclav Petras, NCSU GeoForAll Lab
Available at: r.clip source code (history)
Main index |
Raster index |
Topics index |
Keywords index |
Graphical index |
GRASS Development Team,
GRASS GIS 7.8.4dev Reference Manual