SpatialMatch gem
Use the SpatialMatch gem to find relationships between geometries from two different datasets. Common use cases include:
- Finding which stores are located within specific delivery zones
- Identifying roads that intersect with flood zones
- Matching customer locations to their nearest service areas
The gem uses spatial joins to compare geometries and returns only the pairs that have the spatial relationship you specify, such as shapes overlapping or shapes touching. It works with points, lines, and polygons in Well-Known Text (WKT) format.
The SpatialMatch gem has a corresponding interactive gem example. See Interactive gem examples to learn how to run sample pipelines for this and other gems.
Use the following gems to create correctly formatted geometries in a dataset:
- CreatePoint gem for points
- PolyBuild gem for lines and polygons
Input and Output
The SpatialMatch gem accepts the following inputs and output.
| Port | Description |
|---|---|
| in0 | Dataset containing geometries (points, lines, or polygons) in WKT format. This is the "left" dataset in the spatial join operation. |
| in1 | Dataset containing geometries (points, lines, or polygons) in WKT format. This is the "right" dataset in the spatial join operation. |
| out | Output dataset containing matched pairs of geometries along with all additional columns from both input datasets. Each row represents a source geometry and target geometry that satisfy the selected spatial relationship. Unmatched geometries are excluded from the output. The output includes the following columns:
|
You can use the same source for both in0 and in1 if you want to match geometries from the same dataset (self-join).
Parameters
Configure the SpatialMatch gem using the following parameters.
| Parameter | Description |
|---|---|
| Source Column | Select the column from in0 that contains one set of geometric data. |
| Target Column | Select the column from in1 that contains another set of geometric data. |
| Select Match Type | Choose the spatial relationship that determines when a source geometry matches a target geometry. Learn more in Match types. |
Match types
Review the following to understand the criteria to satisfy different match types. The SpatialMatch gem returns a row for each match condition that is met.
| Match type | Description |
|---|---|
| Source Intersects Target | Condition is met if the source and target geometries share any portion of space. This is the most general spatial relationship. Any overlap, touching, or containment satisfies intersection. |
| Source Contains Target | Condition is met if the source geometry completely contains the target geometry. The target geometry must be entirely within the source geometry's interior and boundary. |
| Source Within Target | Condition is met if the source geometry is completely contained within the target geometry. This is the inverse of the Contains relationship. |
| Source Touches Target | Condition is met if the source and target geometries have at least one point in common, but their interiors do not intersect. |
| Source Touches or Intersects Target | Condition is met if the source and target geometries either touch (share boundary points) or intersect (share any portion of space). This combines the touch and intersect relationships. |
| Source Envelope Overlaps Target Envelope | Condition is met if the minimum bounding rectangles (envelopes) of the source and target geometries overlap. This is a less precise check than a standard intersection. |
Match types diagram
The following diagram includes visualizations for each match type.