This gem runs in .
Overview
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
Prerequisites
- Add
ProphecyDatabricksSqlSpatialversion 0.0.3 or higher to your project.
Input and Output
The SpatialMatch gem accepts the following inputs and output.
You can use the same source for both in0 and in1 if you want to match geometries from the same
dataset (self-join).
Use the following gems to create correctly formatted geometries in a dataset:
- CreatePoint gem for points
- PolyBuild gem for lines and polygons
Parameters
Configure the SpatialMatch gem using the following parameters.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 types diagram
The following diagram includes visualizations for each match type.
Example: Find stores within delivery zones
Assume you have two datasets:-
store_locationscontains store locations as points. -
delivery_zonescontains delivery zones as polygons.
- Add a SpatialMatch gem to your pipeline canvas.
- Attach
store_locationsto the in0 port of the gem. - Attach
delivery_zonesto the in1 port of the gem. - Open the gem configuration interface.
- For the Source field, select the
store_locationcolumn from thestore_locationstable. - For the Target field, select the
zone_polygoncolumn from thedelivery_zonestable. - Under Select Match Type, select Source Within Target.
- Save and run the gem.
Result
The SpatialMatch gem will return only the pairs of geometries that satisfy the selected match type. As a result:- Downtown Electronics matches the
MANHATTAN_SOUTHzone. - Queens Pharmacy matches the
QUEENS_CENTRALzone. - Upper East Side Boutique matches the
MANHATTAN_NORTHzone. - Midtown Cafe does not match any zone. This means that it is not in any delivery zone.

