Measure¶
geoops.measure wraps skimage.measure for region properties and contour extraction. Outputs are
either label GeoArrays or GeoDataFrames with geometries in the input CRS.
LabelConnectedComponents— component labelling withconnectivity=4|8(skimage's1|2spelling is not accepted) and an optionalmin_area_pxfilterRegionProps— per-component property table, called asRegionProps()(labels, intensity_image)(the optional intensity image must share the label map's grid); carriesforbid_in_yaml=True(extra_propertiescallables cannot round-trip). Property columns are in pixel units (areas in pixels, lengths in pixel widths, positions as(row, col));scale_to_crs=Trueconverts areas / lengths / second moments to CRS units. Thegeometrycolumn is always in CRS units.FindContours— marching-squares iso-contours emitted asLineStringfeatures (CRS units)SkeletonLength— longest Euclidean path through the mask skeleton, in pixel widths (scale_to_crs=Truefor CRS units)ProfileLine— sample values along a line between two pointsRANSAC— generic model fitting on(N, 2)coordinate pairsShannonEntropy— single-band scalar entropy
Shared primitives (also used by geoops.mask and geoops.plume): label_components,
skeleton_length, regionprops_frame and DEFAULT_REGIONPROPS, plus
regionprops_to_crs_units (the scale_to_crs=True conversion).
geoops.measure
¶
Measurement operators for labels, regions, contours, and transects.
DEFAULT_REGIONPROPS = ('label', 'area', 'area_convex', 'area_filled', 'centroid', 'major_axis_length', 'minor_axis_length', 'orientation', 'eccentricity', 'solidity', 'perimeter', 'bbox', 'inertia_tensor_eigvals')
module-attribute
¶
Region properties computed by default by measure.RegionProps and
plume.PlumeFootprint. All are in pixel units (areas in pixels,
lengths in pixel widths, positions as (row, col) indices).
FindContours
¶
Bases: Operator
Extract iso-value contours as LineString geometries.
Wraps :func:skimage.measure.find_contours over a single-band
(H, W) or (1, H, W) image and maps each contour's pixel
coordinates into world coordinates. Geo-dependent: the output
geometries need the carrier's transform/CRS, so the input must be a
georeferenced GeoArray (plain arrays raise TypeError).
Units: the geometry column is in CRS units (contour vertices are
sub-pixel positions mapped through the transform, pixel centres at
integer (row, col)); contour_id is a 1-based index. There are
no pixel-unit columns, so there is no scale_to_crs switch.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
level
|
float | None
|
Iso-value along which to find contours; |
None
|
fully_connected
|
str
|
Whether high- or low-valued pixels are
considered fully connected ( |
'low'
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If the input is not a georeferenced GeoArray. |
Source code in packages/geotoolz-ops/src/geoops/measure/_src/operators.py
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 | |
LabelConnectedComponents
¶
Bases: Operator
Convert a binary mask into an int32 connected-component label map.
Delegates to :func:geoops.measure.label_components. Expects a
single-band (H, W) or (1, H, W) mask; pixels different from
background are foreground. Accepts a GeoArray or a plain
np.ndarray and returns an int32 label map (contiguous labels
1..K in raster order) in the same carrier kind, with
fill_value=0. Nodata input pixels (non-finite or equal to
the input's fill) are background 0 and never join components.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
connectivity
|
Connectivity
|
|
4
|
background
|
int
|
Pixel value treated as background and labelled |
0
|
min_area_px
|
int
|
Minimum component size in pixels; smaller components
become background. |
0
|
Source code in packages/geotoolz-ops/src/geoops/measure/_src/operators.py
ProfileLine
¶
Bases: Operator
Sample values along a line between two pixel coordinates.
Wraps :func:skimage.measure.profile_line over a single-band
(H, W) or (1, H, W) image. Endpoints are pixel (row, col)
coordinates and the returned profile is a plain 1-D np.ndarray,
so both GeoArray and plain-array carriers are accepted.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
src
|
tuple[int, int]
|
|
required |
dst
|
tuple[int, int]
|
|
required |
linewidth
|
int
|
Width of the sampling band, in pixels. |
1
|
order
|
int
|
Spline interpolation order (0 = nearest neighbour). |
1
|
mode
|
str
|
Boundary handling mode for samples outside the image. |
'reflect'
|
Source code in packages/geotoolz-ops/src/geoops/measure/_src/operators.py
RANSAC
¶
Bases: Operator
Robust model fitting via :func:skimage.measure.ransac.
Carrier-agnostic: the input is whatever data layout the chosen model
class consumes (e.g. an (N, D) point array), and the output is
the (model, inlier_mask) pair returned by ransac.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_class
|
type[Any]
|
skimage model class to fit (e.g.
|
required |
min_samples
|
int
|
Minimum number of samples per model estimate. |
required |
residual_threshold
|
float
|
Maximum residual for a sample to count as an inlier. |
required |
**kwargs
|
Any
|
Extra keyword arguments forwarded to
:func: |
{}
|
Source code in packages/geotoolz-ops/src/geoops/measure/_src/operators.py
RegionProps
¶
Bases: Operator
Extract a GeoDataFrame of per-region statistics from a label map.
Wraps :func:skimage.measure.regionprops_table over a single-band
(H, W) or (1, H, W) integer label map. When the centroid
property is requested (the default), each row carries a Point
geometry at the region centroid in world coordinates. Geo-dependent:
the output geometry needs the carrier's transform/CRS, so the input
must be a georeferenced GeoArray (plain arrays raise
TypeError).
Units: the geometry column is in CRS units. The property columns
are in pixel units by default -- areas in pixels, lengths
(perimeter, major_axis_length, ...) in pixel widths, second
moments (inertia_tensor*) in squared pixel widths, positions
(centroid-*, bbox-*) as (row, col) indices. With
scale_to_crs=True areas, lengths and second moments are converted
to CRS units (m^2 / m / m^2 for a projected metric CRS); positions,
angles and dimensionless ratios are unchanged.
Called as op(labels, intensity_image=None). The optional
intensity_image is a single-band carrier on the label map's pixel
grid (ValueError otherwise) and enables intensity-based
properties.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
properties
|
Sequence[str] | None
|
Property names passed to |
None
|
extra_properties
|
Sequence[Callable[..., Any]] | None
|
Optional callables computing custom per-region properties (see skimage docs). Not YAML-serialisable, so instances are forbidden in YAML. Their outputs are never rescaled. |
None
|
scale_to_crs
|
bool
|
Convert area / length / second-moment columns from pixel to CRS units using the carrier's transform. |
False
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If the input is not a georeferenced GeoArray. |
ValueError
|
If |
Source code in packages/geotoolz-ops/src/geoops/measure/_src/operators.py
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 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 | |
ShannonEntropy
¶
Bases: Operator
Compute Shannon entropy of the input image.
Wraps :func:skimage.measure.shannon_entropy over a single-band
(H, W) or (1, H, W) image. The result is a plain float, so
both GeoArray and plain-array carriers are accepted.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
base
|
float
|
Logarithm base for the entropy ( |
2.0
|
Source code in packages/geotoolz-ops/src/geoops/measure/_src/operators.py
SkeletonLength
¶
Bases: Operator
Longest path through the skeleton of a binary mask.
Delegates to :func:geoops.measure.skeleton_length: the mask is
skeletonised with :func:skimage.morphology.skeletonize and the
longest geodesic path through the 8-connected skeleton is measured
between pixel centres, each step weighted by its Euclidean length
(a diagonal step counts sqrt(2)). This is the geodesic "fiber
length" of Pérez Carrasco et al. (2026) with Euclidean rather than
unit step weights.
Units: pixel widths by default, so both GeoArray and plain-array
carriers are accepted. With scale_to_crs=True steps are measured
through the carrier's transform (anisotropic and rotated grids
included) and the result is in CRS units (m for a projected metric
CRS); the input must then be a georeferenced GeoArray.
Returns 0.0 for empty masks or skeletons that collapse to a single
pixel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scale_to_crs
|
bool
|
Measure in CRS units via the carrier's transform instead of pixel widths. |
False
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
Source code in packages/geotoolz-ops/src/geoops/measure/_src/operators.py
label_components(mask, *, connectivity=8, min_area_px=0)
¶
Label connected True regions and drop components below min_area_px.
Uses :func:scipy.ndimage.label (raster-order labels, identical to
:func:skimage.measure.label on a boolean mask), then renumbers the
surviving components contiguously (1..K) without a second
labelling pass -- dropping pixels from a labelled image cannot merge
distinct components.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mask
|
Bool[ndarray, 'h w']
|
2-D mask; any array-like is coerced with
|
required |
connectivity
|
Connectivity
|
|
8
|
min_area_px
|
int
|
Minimum component size in pixels; smaller components
become background. |
0
|
Returns:
| Type | Description |
|---|---|
Int[ndarray, 'h w']
|
An |
Int[ndarray, 'h w']
|
surviving components and |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in packages/geotoolz-ops/src/geoops/_src/labels.py
regionprops_frame(labels, *, intensity_image=None, properties=DEFAULT_REGIONPROPS, extra_properties=None)
¶
Per-region property table of an integer label image.
Thin wrapper around :func:skimage.measure.regionprops_table; every
value is in pixel units (see :data:DEFAULT_REGIONPROPS).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
labels
|
Int[ndarray, 'h w']
|
2-D integer label image; |
required |
intensity_image
|
Shaped[ndarray, 'h w'] | None
|
Optional 2-D intensity image aligned with
|
None
|
properties
|
Sequence[str]
|
Property names to compute. |
DEFAULT_REGIONPROPS
|
extra_properties
|
Sequence[Callable[..., Any]] | None
|
Optional custom per-region callables. |
None
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
One row per label, columns named as skimage names them |
DataFrame
|
( |
Source code in packages/geotoolz-ops/src/geoops/_src/labels.py
regionprops_to_crs_units(frame, transform)
¶
Convert pixel-unit region-property columns to CRS units.
With A = |a·e - b·d| the pixel area and s the pixel side:
area → area · A, length → length · s, moment → moment · s²
Columns are matched by their base name (inertia_tensor-0-1 →
inertia_tensor); unlisted columns are copied unchanged.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
frame
|
DataFrame
|
A :func: |
required |
transform
|
Any
|
Affine-like object exposing |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
A converted copy of |
Raises:
| Type | Description |
|---|---|
ValueError
|
If a length or moment column is present and the pixels are not square (anisotropic or sheared), where no single pixel length exists. |
Examples:
>>> from affine import Affine
>>> frame = pd.DataFrame({"label": [1], "area": [4.0], "perimeter": [8.0]})
>>> regionprops_to_crs_units(frame, Affine(10, 0, 0, 0, -10, 0))
label area perimeter
0 1 400.0 80.0
Source code in packages/geotoolz-ops/src/geoops/measure/_src/array.py
skeleton_length(mask, *, step=(1.0, 1.0), connectivity=8)
¶
Longest geodesic path through the skeleton of a binary mask.
The mask is skeletonised with :func:skimage.morphology.skeletonize
and each step between neighbouring skeleton pixels is weighted by its
Euclidean length, so a diagonal step on square unit pixels counts
sqrt(2) and anisotropic / rotated grids are measured correctly.
The path runs between skeleton pixel centres: a straight line of
n pixels measures n - 1 steps.
The result is the exact graph diameter of each connected skeleton
component (the longest of its shortest paths), maximised over
components. A tree-shaped component uses a double Dijkstra sweep
(farthest pixel from a seed, then farthest from that), which is exact
for trees; a component with a loop -- where that sweep can
under-estimate -- runs Dijkstra from every pixel. The sweep seed is
the lexicographically smallest (row, col), so the result is
deterministic.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mask
|
Shaped[ndarray, 'h w']
|
2-D mask. Boolean input is used as is; other dtypes are
foreground where |
required |
step
|
tuple[float, float] | Any
|
Pixel size, either a |
(1.0, 1.0)
|
connectivity
|
Connectivity
|
|
8
|
Returns:
| Type | Description |
|---|---|
float
|
The longest path length in the units of |
float
|
empty mask or when every skeleton component is a single pixel. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |