Vector patching

From GRASS-Wiki
Jump to: navigation, search

Q: How can I patch several vector map together, i.e. merge them? Especially SHAPE files?

A 1: To patch vector maps in GRASS:

Merge them with v.patch. The output of v.patch will require further cleaning. From the manual: "Boundaries may need to be cleaned with v.clean ... tool=break,rmdupl,rmsa repeatedly until the rmsa tool ("remove small angles at nodes") no longer modifies any boundaries. If vector topology is still not clean, boundaries may also need to be snapped with v.clean ... tool=snap,break,rmdupl"

A 2: SHAPE: There are 3 ways to patch shapefiles:

1) before import with ogr2ogr -append. But it will not quite work when the attribute tables are not compatible.

2) during import into GRASS GIS:

You need to specify the folder with the shapefiles as dsn for v.in.ogr: then all OGR layers are imported at once and patched together. Each OGR layer will result in a separate GRASS layer in the output GRASS vector. Each GRASS vector layer will have its own attribute table, i.e. it does not matter if attribute tables are not compatible.

3) after import with v.patch:

Categories might need to be prepared first in order to avoid that areas from different input vector maps end up with the same category. Note: Preserving attributes with v.patch is not trivial.

The output of v.patch will require further cleaning. From the manual: "Boundaries may need to be cleaned with v.clean ... tool=break,rmdupl,rmsa repeatedly until the rmsa tool ("remove small angles at nodes") no longer modifies any boundaries. If vector topology is still not clean, boundaries may also need to be snapped with v.clean ... tool=snap,break,rmdupl"

See also