r.patch.1grass man page

r.patch — Creates a composite raster map layer by using known category values from one (or more) map layer(s) to fill in areas of "no data" in another map layer.

Keywords

raster, geometry, mosaicking, merge, patching

Synopsis

r.patch
r.patch --help
r.patch [-z] input=name[,name,...] output=name [--overwrite] [--help] [--verbose] [--quiet] [--ui]

Flags

-z
Use zero (0) for transparency instead of NULL
--overwrite
Allow output files to overwrite existing files
--help
Print usage summary
--verbose
Verbose module output
--quiet
Quiet module output
--ui
Force launching GUI dialog

Parameters

input=name[,name,...] [required]
Name of raster maps to be patched together
output=name [required]
Name for resultant raster map

Description

The GRASS program r.patch allows the user to build a new raster map the size and resolution of the current region by assigning known data values from input raster maps to the cells in this region. This is done by filling in "no data" cells, those that do not yet contain data, contain NULL data, or, optionally contain 0 data, with the data from the first input map. Once this is done the remaining holes are filled in by the next input map, and so on. This program is useful for making a composite raster map layer from two or more adjacent map layers, for filling in "holes" in a raster map layer’s data (e.g., in digital elevation data), or for updating an older map layer with more recent data. The current geographic region definition and mask settings are respected.

The first name listed in the string input=name,name,name, ... is the name of the first map whose data values will be used to fill in "no data" cells in the current region. The second through last input name maps will be used, in order, to supply data values for for the remaining "no data" cells.

Example of filling areas

Below, the raster map layer on the far left is patched with the middle (patching) raster map layer, to produce the composite raster map layer on the right. The example assumes zero values to be treated as NULLs (-z flag).

1 1 1 0 2 2 0 0    0 0 1 1 0 0 0 0    1 1 1 1 2 2 0 0
1 1 0 2 2 2 0 0    0 0 1 1 0 0 0 0    1 1 1 2 2 2 0 0
3 3 3 3 2 2 0 0    0 0 0 0 0 0 0 0    3 3 3 3 2 2 0 0
3 3 3 3 0 0 0 0    4 4 4 4 4 4 4 4    3 3 3 3 4 4 4 4
3 3 3 0 0 0 0 0    4 4 4 4 4 4 4 4    3 3 3 4 4 4 4 4
0 0 0 0 0 0 0 0    4 4 4 4 4 4 4 4    4 4 4 4 4 4 4 4

Switching the patched and the patching raster map layers produces the following results:

0 0 1 1 0 0 0 0    1 1 1 0 2 2 0 0    1 1 1 1 2 2 0 0
0 0 1 1 0 0 0 0    1 1 0 2 2 2 0 0    1 1 1 1 2 2 0 0
0 0 0 0 0 0 0 0    3 3 3 3 2 2 0 0    3 3 3 3 2 2 0 0
4 4 4 4 4 4 4 4    3 3 3 3 0 0 0 0    4 4 4 4 4 4 4 4
4 4 4 4 4 4 4 4    3 3 3 0 0 0 0 0    4 4 4 4 4 4 4 4
4 4 4 4 4 4 4 4    0 0 0 0 0 0 0 0    4 4 4 4 4 4 4 4

Notes

Frequently, this program is used to patch together adjacent map layers which have been digitized separately. The program v.mkgrid can be used to make adjacent maps align neatly.

The user should check the current geographic region settings before running r.patch, to ensure that the region boundaries encompass all of the data desired to be included in the composite map and to ensure that the region resolution is the resolution of the desired data. To set the geographic region settings to one or several raster maps, the g.region program can be used:

g.region raster=map1[,map2[,...]]

Use of r.patch is generally followed by use of the GRASS programs g.remove and g.rename; g.remove is used to remove the original (un-patched) raster map layers, while g.rename is used to then assign to the newly-created composite (patched) raster map layer the name of the original raster map layer.

r.patch creates support files for the patched, composite output map.

Number of raster maps to be processed is given by the limit of the operating system. For example, both the hard and soft limits are typically 1024. The soft limit can be changed with e.g. ulimit -n 1500 (UNIX-based operating systems) but not higher than the hard limit. If it is too low, you can as superuser add an entry in

/etc/security/limits.conf
# <domain>      <type>  <item>         <value>
your_username  hard    nofile          1500

This would raise the hard limit to 1500 file. Be warned that more files open need more RAM. See also the Wiki page Hints for large raster data processing.

Example

Create a list of maps matching a pattern, extend the region to include them all, and patch them together to create a mosaic. Overlapping maps will be used in the order listed.

MAPS=`g.list type=raster sep=, pat="map_*"`
g.region raster=$MAPS
r.patch in=$MAPS out=mosaic

See Also

g.region, g.remove, g.rename, r.mapcalc, r.support, v.mkgrid

Hints for large raster data processing

Author

Michael Shapiro, U.S. Army Construction Engineering Research Laboratory
-z flag and performance improvement by Huidae Cho

Last changed: $Date: 2015-10-09 18:55:34 +0200 (Fri, 09 Oct 2015) $

Main index | Raster index | Topics index | Keywords index | Full index

© 2003-2016 GRASS Development Team, GRASS GIS 7.0.4 Reference Manual

Info

GRASS 7.0.4 Grass User's Manual