VectorIntersector¶
Intersects the features of a vector, points, lines or polygons, with the polygons of another vector: each feature is cut into a piece for each polygon it crosses, with the attributes of both, as the reaches of a river with the municipality they flow through. To only cut the features to the area of the polygons, use VectorClipper.
Details¶
Each feature is cut by each polygon it overlaps, and every piece becomes a feature with the attributes of the feature and of the polygon: a river crossing three municipalities gives three pieces, each with the name of its municipality. A field of the polygons with the name of a field of the features, ignoring the case, gets the suffix _2. Where the polygons overlap, the pieces overlap too. To cut the features to the area of the polygons, without their attributes and with a single piece per feature, use VectorClipper.
The result has the multi geometry type of the first 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.
The two vectors must have the same coordinate reference system.
Parameters¶
Intersects the features of a vector with the polygons of another vector, keeping the attributes of both.
Toolbox folder: Vector Processing
Status: Certified
Keywords: Vector, Intersect, Overlay, Attributes
Authors: Andrea Antonello
Class: org.hortonmachine.modules.VectorIntersector
Inputs
Parameter |
Type |
Unit |
Default |
Description |
|---|---|---|---|---|
|
vector file |
The vector to intersect: points, lines or polygons. |
||
|
vector file |
The polygons to intersect with. |
Outputs
Parameter |
Type |
Unit |
Description |
|---|---|---|---|
|
output file |
The pieces of the features, with the attributes of the features and of the polygons. |
Example¶
The example intersects the network of NetworkAttributesBuilder with the cells of RasterCatToFeatureAttribute, so that each piece of the network gets the elevation of its cell:
import org.hortonmachine.modules.VectorIntersector
// the folder with the elevation model: change it to yours
var folder = "/data/flanginec/"
var intersector = new VectorIntersector()
// the network of NetworkAttributesBuilder
intersector.inMap1 = folder + "net_attributes.shp"
// the cells of RasterCatToFeatureAttribute, with their elevation
intersector.inMap2 = folder + "grid_elev.shp"
intersector.outMap = folder + "net_cells.shp"
intersector.process()
The 99 reaches become 126 pieces, colored by the mean elevation of their cell, with the cells in blue:
The reach 13 of the Pfafstetter numbering, on the main stream (Hack order 1), crosses three cells: its pieces keep the fields of the network and get those of their cell:
pfaf |
hack |
strahler |
id |
elev_avg |
length (m) |
|---|---|---|---|---|---|
13 |
1 |
3 |
40 |
1889.2 |
162 |
13 |
1 |
3 |
32 |
1629.2 |
387 |
13 |
1 |
3 |
33 |
1759.2 |
12 |