Spatial joins (sjoin/3, sjoin_nearest/3) between two GeoFrame.GeoDataFrames with GeoPandas semantics.
The matching pairs come from GeoFrame.GeoSeries.sindex_query/4 (R-tree probe, exact
refinement, computed in Rust). Rust also lays out the result rows (join order, unmatched
rows) and hands the row indices over as native-endian u32 binaries that Explorer reads
with Series.from_binary/3, so a join of millions of pairs never builds a list of indices
on the BEAM heap, and geometry never leaves Rust memory.
Result
how: :inner(default) keeps matched pairs;:leftalso keeps unmatched left rows once, with nulls on the right;:rightis the mirror image.- The geometry is the left geometry for
:innerand:left, the right geometry for:right(with that frame's geometry column name). - Columns follow GeoPandas: left attributes, then
index_right(the zero-based row position in the right frame, a nullables64), then right attributes (never the right geometry). Forhow: :rightit isindex_left, left attributes, right attributes. An attribute name present on both sides becomesname_left/name_right(:lsuffix,:rsuffix), and the index column isindex_<rsuffix>(index_<lsuffix>for a right join), as in GeoPandas. The geometry is always the last column, whichever side it comes from (GeoPandas puts the right geometry in the middle of a right join; aGeoFrame.GeoDataFramekeeps its geometry last). - Row order:
:innerand:leftby left row then right row;:rightby right row then left row.
Secondary geometry columns
The secondary geometry columns of both frames (GeoFrame.GeoDataFrame.put_geometry/3) are
attributes of the result, like the other geometry-dtype columns of a GeoPandas frame: each
keeps its own CRS, a name present on both sides gets the suffixes, and rows without a
partner hold a null geometry. They follow the active geometry (left columns first), whereas
GeoPandas leaves each at its original column position.
Nulls on the unmatched side
Explorer cannot take with missing indices, so the unmatched side is gathered from the
frame with one all-null row appended (concat_rows) and nil indices pointing at that
row. That keeps column dtypes and costs one copy of the unmatched side's attributes.
Null and empty geometries never match, but still appear in :left / :right results.
Frames whose CRS are both set and differ raise ArgumentError.
Summary
Functions
Joins left and right on a spatial relation.
Joins each left row with its nearest right geometry (planar euclidean distance,
geometry to geometry), like geopandas.sjoin_nearest.
Functions
@spec sjoin(GeoFrame.GeoDataFrame.t(), GeoFrame.GeoDataFrame.t(), keyword()) :: GeoFrame.GeoDataFrame.t()
Joins left and right on a spatial relation.
Options:
:how-:inner(default),:leftor:right.:predicate- any predicate ofGeoFrame.GeoSeries.sindex_query/4(default:intersects), read asleft.predicate(right).:distance- required for:dwithin.:lsuffix/:rsuffix- suffixes for colliding attribute names ("left"/"right").
Raises ArgumentError for bad or unknown options, a CRS mismatch, or when the result would contain
two columns with the same name (including an existing index_right / index_left).
@spec sjoin_nearest(GeoFrame.GeoDataFrame.t(), GeoFrame.GeoDataFrame.t(), keyword()) :: GeoFrame.GeoDataFrame.t()
Joins each left row with its nearest right geometry (planar euclidean distance,
geometry to geometry), like geopandas.sjoin_nearest.
Every right geometry at exactly the minimum distance is returned, so a left row can
appear several times (ties); ties are ordered by right row. For how: :right the roles
swap: each right row is joined with its nearest left geometries.
Options:
:how-:inner(default; rows without a match are dropped),:leftor:right.:max_distance- non-negative; farther candidates do not match (inclusive limit).:distance_col- name of an extraf64column holding the distance (omitted by default;nilfor unmatched rows).:exclusive- whentrue, geometries equal to the query one are ignored (defaultfalse).:lsuffix/:rsuffix- suffixes for colliding attribute names ("left"/"right").
Column order and nulls follow sjoin/3; the distance column comes after the right
attributes. Null and empty geometries never match. Raises ArgumentError for bad or unknown options,
a CRS mismatch or duplicate result column names.