VectorClipper

Cuts the features of a vector, points, lines or polygons, to the area covered by the polygons of another vector, as the roads of a region to a municipality. The features keep their attributes. To also get the attributes of the polygons, use VectorIntersector.

Details

The clipping polygons are merged before the cut, so a feature comes out once, with its part inside any of them, also when it crosses several. Only the attributes of the clipped vector are kept: to also get those of the polygons, with a piece of the feature for each polygon, use VectorIntersector.

The result has the multi geometry type of the clipped vector, as MultiLineString for lines. The parts of the cut of a lower dimension are left out, as the point where a line touches a polygon, and so are the features that only touch the polygons along their border.

The two vectors must have the same coordinate reference system.

Parameters

Cuts the features of a vector to the area of the polygons of another vector, keeping their attributes.

Toolbox folder: Vector Processing
Status: Certified
Keywords: JTS, Clip, Vector
Authors: Andrea Antonello
Class: org.hortonmachine.modules.VectorClipper

Inputs

Parameter

Type

Unit

Default

Description

inMap

vector file

The vector to clip: points, lines or polygons.

inClipper

vector file

The polygons to clip with.

Outputs

Parameter

Type

Unit

Description

outMap

output file

The clipped features, with their attributes.

Example

The example cuts the contour lines of ContourExtractor to the basin of ExtractBasin:

import org.hortonmachine.modules.VectorClipper

// the folder with the elevation model: change it to yours
var folder = "/data/flanginec/"

var clipper = new VectorClipper()
// the contour lines of ContourExtractor
clipper.inMap = folder + "contours.shp"
// the basin of ExtractBasin
clipper.inClipper = folder + "basin.shp"
clipper.outMap = folder + "contours_basin.shp"
clipper.process()

Of the 38 contour lines, 10 cross the basin, outlined in blue, and are kept with the part inside it and their elevation:

The contour lines cut to the basin