Views and extents

See Lazy views and spatial filtering for a conceptual overview.

Extents and regions

SpatialOmics.SpatialExtentType
SpatialExtent(xmin, xmax, ymin, ymax; coord_system="")
SpatialExtent(shp::SpatialShapes)

Axis-aligned bounding box in a named coordinate system.

The coord_system field is checked when combining two extents (union, intersect) or filtering elements with view — a mismatch raises an error rather than silently producing wrong results.

ext = SpatialExtent(1000.0, 2000.0, 500.0, 1500.0; coord_system="global")
roi = view(ds, ext)

See also

SpatialROI, SpatialDatasetView, SpatialElementView

SpatialOmics.SpatialROIType
SpatialROI(geometry; coord_system="")

Polygon region of interest backed by any GeoInterface-compatible geometry.

Wraps the geometry with a cached axis-aligned bounding box for fast pre-filtering. Point containment uses GeometryOps.contains; pt ∈ roi and filter(pt -> pt ∈ roi, pts) are the idiomatic containment APIs.

See also

SpatialExtent, geometry, SpatialElementView

Views

SpatialOmics.SpatialDatasetViewType
SpatialDatasetView

Lazy view across all elements of a SpatialDataset, scoped to a spatial region.

Produced by view(ds, extent) or view(ds, roi). Accessing an element via the typed accessors (points, shapes, images, labels) returns a SpatialElementView for that element — still lazy, no data copied.

roi = view(ds, SpatialExtent(1000.0, 2000.0, 500.0, 1500.0))
tx  = points(roi, "transcripts")   # SpatialElementView{SpatialPoints}
collect(tx)                        # materialise into a concrete SpatialPoints

See also

SpatialElementView, SpatialExtent

SpatialOmics.SpatialElementViewType
SpatialElementView{T, R}

Lazy spatial view into a single element, analogous to Julia's SubArray.

Holds a reference to the parent element and a region (SpatialExtent or SpatialROI). The spatial filter is applied only when accessors (coords, geometries, feature_ids, etc.) or collect are called — no data is copied on construction.

overlap controls how shapes are matched:

  • :any (default) — include shapes whose bounding box intersects the ROI
  • :full — include only shapes fully contained within the ROI

See also

SpatialDatasetView, SpatialExtent, SpatialROI

Accessors

SpatialOmics.geometryFunction
geometry(roi) → geometry

Return the underlying GeoInterface geometry from a SpatialROI.

SpatialOmics.selectFunction
select(ax, ds) → SpatialROI

Interactively draw a polygon ROI on Makie axis ax and return the result as a SpatialROI. Requires a Makie backend to be loaded.

This function is a stub; the implementation is provided by the Makie extension when a backend is loaded.

Example: constructing and intersecting extents

using SpatialOmics

a = SpatialExtent(0.0, 1000.0, 0.0, 500.0; coord_system="global")
b = SpatialExtent(500.0, 1500.0, 0.0, 500.0; coord_system="global")

intersect(a, b)   # SpatialExtent(500.0, 1000.0, 0.0, 500.0, "global")
SpatialExtent(x=500.0..1000.0, y=0.0..500.0) [global]
union(a, b)       # SpatialExtent(0.0, 1500.0, 0.0, 500.0, "global")
SpatialExtent(x=0.0..1500.0, y=0.0..500.0) [global]