By analogy with more_itertools.one.
We just want to raise an error if there are multiple distinct raster cell values (or, I suppose, if the raster is empty). If there is exactly one value, return it.
For users, this is mostly useful for migration contexts where a quantity was previously represented as a float but the user wants to migrate to allow it to vary spatially. Then the underlying representation can be changed to a raster but any methods that expect a single float can use .one safely until proper spatial variability is supported in the user's downstream applications.
By analogy with
more_itertools.one.We just want to raise an error if there are multiple distinct raster cell values (or, I suppose, if the raster is empty). If there is exactly one value, return it.
For users, this is mostly useful for migration contexts where a quantity was previously represented as a
floatbut the user wants to migrate to allow it to vary spatially. Then the underlying representation can be changed to a raster but any methods that expect a single float can use.onesafely until proper spatial variability is supported in the user's downstream applications.