Geospatial · Combine and measure

Spatial Join

Joins two tables by where their shapes are, not by a key: intersects, within, contains or nearest. For example, tag each store with the region it falls in.

Also known as: Point in polygon, spatial match

How it works

Name the geometry column on each side (Left, Right) and a Predicate: Intersects, Within (point-in-polygon), Contains or Nearest. The output carries the left rows with the matching right row's columns; the right geometry is dropped unless Keep right geometry as names a column. Points on a border decides what a point exactly on a shared edge matches: One polygon (default) assigns it to exactly one, Left out drops it from Within and Contains, Every polygon on it counts it in each. For Nearest, Matches per row keeps the N closest (1 by default), Max distance drops farther ones (0 = none), Distance column and Rank column add the distance and 1..N; on lon/lat data the Distance unit is metres, kilometres or miles, on a projected system the system's units. Only left rows that match nothing turns the join into the opposite: the unmatched left rows, with the left columns only. Auto-reproject right side (on by default) transforms the right geometry onto the left's coordinate system when the two differ.

Inputs and outputs

Inputs

  • left — Table
  • right — Table

Outputs

  • data — Table

Settings

The Attributes panel of Spatial Join, as in the app: the controls work, but nothing runs — there is no data behind it.

The same settings, as the Assistant writes them
{
  predicate: "intersects"|"within"|"contains"|"nearest"
  leftGeom: string
  rightGeom: string
  distanceColumn?: string
  rightGeomAs?: string
  nearestCount?: number
  maxDistance?: number
  rankColumn?: string
  distanceUnit?: "meters"|"km"|"miles"
  distanceMethod?: "spheroid"|"sphere"
  unmatched?: boolean
  borderPoints?: "standard"|"every"
}

leftGeom/rightGeom are the geometry-column names on each input; "within" is point-in-polygon; the right geometry is dropped unless rightGeomAs names a column to keep it in. unmatched keeps only the left rows that match nothing (nearest: none within maxDistance), with the left's columns. Nearest only: distanceColumn emits the ranking distance, nearestCount keeps the N nearest (default 1), maxDistance drops farther matches (0 = no limit), rankColumn numbers them 1..N; on a lon/lat CRS distances are in distanceUnit (default meters) on the WGS84 spheroid, or with distanceMethod "sphere" the haversine distance on Alteryx Designer's sphere (R = 3956.5625 mi), on a projected CRS in CRS units. Intersects/within/contains: borderPoints decides a point exactly on a polygon border — absent assigns it to exactly one polygon as Alteryx Spatial Match does (half-open: the polygon to its right, or above on a horizontal edge; outer right/top borders match nothing), "standard" is OGC (within/contains drop it, intersects matches every polygon on that border), "every" counts it in each polygon on the border

Example

Tag each store with the region it falls in: left is the stores with geom, right is the regions with geom, predicate Within. To find the nearest warehouse instead, pick Nearest with a distance column dist_km and unit kilometres.