Matchup — geocatalog.matchup¶
Cross-source row joins with pluggable spatial and temporal strategies.
Matchup¶
geocatalog.matchup.matchup(primary, secondary, *, spatial, temporal, join='all', tag=None, crs=None, include_self=False)
¶
Find matching tuples of observations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
primary
|
GeoCatalog | CatalogBundle | Iterable[SourceRow]
|
Primary observations — a |
required |
secondary
|
GeoCatalog | CatalogBundle | Iterable[SourceRow] | Mapping[str, GeoCatalog | CatalogBundle | Iterable[SourceRow]]
|
One input of the same kinds (pairwise — every
member gets the role |
required |
spatial
|
SpatialStrategy
|
Strategy deciding spatial matches
(e.g. |
required |
temporal
|
TemporalStrategy
|
Strategy deciding temporal matches
(e.g. |
required |
join
|
Literal['all', 'any']
|
|
'all'
|
tag
|
str | None
|
Optional user label persisted as |
None
|
crs
|
Any
|
Working CRS for the join; every footprint is reprojected
into it and |
None
|
include_self
|
bool
|
Keep tuples that pair a row with itself (same
|
False
|
Yields:
| Type | Description |
|---|---|
MatchupRow
|
|
MatchupRow
|
input order and then by |
MatchupRow
|
Duplicate tuples are emitted once. Rows whose interval is |
MatchupRow
|
missing ( |
Raises:
| Type | Description |
|---|---|
ValueError
|
If a secondary role is named |
Source code in packages/geotoolz-catalog/src/geocatalog/_src/matchup/engine.py
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 | |
geocatalog.matchup.MatchupRow
dataclass
¶
A single matched tuple, persisted to matchups.parquet.
Attributes:
| Name | Type | Description |
|---|---|---|
matchup_id |
str
|
Content hash (32 hex characters) of the strategy
parameters and the members' |
strategy |
str
|
Human-readable label naming the spatial and
temporal strategies used
( |
member_ids |
tuple[str, ...]
|
Parallel arrays with |
member_sources |
tuple[str, ...]
|
Source of each member — |
member_roles |
tuple[str, ...]
|
Role tags — |
geometry_intersect |
BaseGeometry
|
Common footprint of the members, in the
matchup's working CRS ( |
time_reference |
datetime
|
Reference instant the offsets are measured from — the primary's interval midpoint, UTC-aware. |
time_offset_sec |
tuple[float, ...]
|
Parallel to |
tolerance |
Mapping[str, Any]
|
Strategy parameters as plain JSON values —
|
member_collections |
tuple[str, ...]
|
Parallel to |
query_set |
str | None
|
Optional user label, persisted as the
|
Source code in packages/geotoolz-catalog/src/geocatalog/_src/matchup/engine.py
Spatial strategies¶
geocatalog.matchup.SpatialStrategy
¶
Bases: Protocol
A predicate over two footprints.
The engine calls match(primary, secondary) for each candidate
pair after the STRtree pre-filter narrows by envelope overlap.
The pre-filter searches the primary footprint itself. A strategy
that can accept secondaries outside it (a buffered test, say)
defines envelope(primary) returning the region to search; the
engine uses it when present (see search_envelope).
Source code in packages/geotoolz-catalog/src/geocatalog/_src/matchup/spatial.py
geocatalog.matchup.Intersects
dataclass
¶
Non-zero geometric intersection (the cheapest predicate).
Matches any pair whose footprints share at least one point. Use when the matchup definition is "any overlap counts" — a common choice for opportunistic fusion where partial coverage is still useful.
Source code in packages/geotoolz-catalog/src/geocatalog/_src/matchup/spatial.py
geocatalog.matchup.IouAtLeast
dataclass
¶
Intersection-over-union ≥ threshold.
Stricter than plain intersection — useful when you want the secondary to substantially overlap the primary (e.g. for training-data quality gates where a sliver-overlap is noise).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
threshold
|
float
|
Minimum IoU in |
required |
Notes
IoU on raw geographic CRS coordinates is degree-area, which is fine as a ratio (numerator and denominator scale the same way) but loses meaning if you compare across latitudes. For equal-area comparisons project both inputs to a meter CRS first.
Source code in packages/geotoolz-catalog/src/geocatalog/_src/matchup/spatial.py
geocatalog.matchup.CentroidWithin
dataclass
¶
Secondary centroid falls within a buffered primary footprint.
Useful when matching against point-like secondaries (in-situ stations, drifters) where a buffered-polygon test is more forgiving than strict polygon containment.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
buffer
|
float | str
|
Distance (in the geometry's CRS units) by which the
primary footprint is enlarged before the point-in-polygon
test. |
required |
Source code in packages/geotoolz-catalog/src/geocatalog/_src/matchup/spatial.py
envelope(primary)
¶
The buffered primary: every centroid match can accept lies in it.
Source code in packages/geotoolz-catalog/src/geocatalog/_src/matchup/spatial.py
geocatalog.matchup.Contains
dataclass
¶
Secondary footprint is fully contained in the primary.
The strictest spatial predicate — use when you need the secondary to be a true subset of the primary's footprint (e.g. a station tile inside an L2 swath).
Source code in packages/geotoolz-catalog/src/geocatalog/_src/matchup/spatial.py
Temporal strategies¶
geocatalog.matchup.TemporalStrategy
¶
Bases: Protocol
Selector over candidate intervals.
Concrete strategies are either predicates (Synchronous,
WithinWindow — emit every candidate that satisfies the
condition) or selectors (NearestInTime — emit at most the
single best). The engine treats both uniformly via filter.
Source code in packages/geotoolz-catalog/src/geocatalog/_src/matchup/temporal.py
filter(primary, candidates)
¶
Return the subset of candidates that match the primary.
geocatalog.matchup.NearestInTime
dataclass
¶
Pick the secondary nearest in time within dt.
"Nearest" is measured between interval midpoints. If the
nearest is still further than dt away, the result is empty.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dt
|
timedelta | str
|
Maximum allowed time offset, e.g. |
required |
Source code in packages/geotoolz-catalog/src/geocatalog/_src/matchup/temporal.py
select(primary, candidates)
¶
Position of the nearest candidate within dt; ties → first.
Source code in packages/geotoolz-catalog/src/geocatalog/_src/matchup/temporal.py
geocatalog.matchup.WithinWindow
dataclass
¶
Candidates whose midpoint falls in [primary.mid + start, primary.mid + end].
Useful for "give me everything within ±12 h of each primary".
start is typically negative (look back); end positive
(look forward).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
start
|
timedelta | str
|
Offset from the primary midpoint. Negative looks back. |
required |
end
|
timedelta | str
|
Offset from the primary midpoint. Positive looks forward. |
required |
Source code in packages/geotoolz-catalog/src/geocatalog/_src/matchup/temporal.py
select(primary, candidates)
¶
Positions of the candidates whose midpoint is in the window.
Source code in packages/geotoolz-catalog/src/geocatalog/_src/matchup/temporal.py
geocatalog.matchup.Synchronous
dataclass
¶
Candidates whose intervals overlap the primary's, within tolerance.
Equivalent to WithinWindow(start=-tolerance, end=+tolerance)
applied to interval overlap (not midpoints) — useful for
matching observations that should genuinely co-occur in time
(e.g. simultaneous flyovers).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tolerance
|
timedelta | str
|
Slack on either side of the primary interval.
|
'0s'
|
Source code in packages/geotoolz-catalog/src/geocatalog/_src/matchup/temporal.py
select(primary, candidates)
¶
Positions of the candidates overlapping the widened primary.