fairdm.utils.location.coverage#
The smallest box that holds the locations of a set of records.
Module Contents#
Classes#
A box in WGS 84 degrees. A box across the 180th meridian has |
Functions#
Return the smallest box holding every location in the given querysets. |
API#
- class Coverage#
Bases:
typing.NamedTupleA box in WGS 84 degrees. A box across the 180th meridian has
westgreater thaneast.Attributes: west: The western bound, a longitude. south: The southern bound, a latitude. east: The eastern bound, a longitude. north: The northern bound, a latitude.
- west: float#
None
- south: float#
None
- east: float#
None
- north: float#
None
- spatial_coverage(*querysets_and_fields)#
Return the smallest box holding every location in the given querysets.
Each queryset is read twice, as longitudes in -180 to 180 and as longitudes in 0 to 360, and the narrower of the two boxes is kept. Locations on both sides of the 180th meridian therefore give a narrow box with
westgreater thaneast, as DataCite writes it, and not one that spans the globe.Args: *querysets_and_fields:
(queryset, field)pairs,fieldnaming a point column or a point annotation on the queryset.Returns: The
Coverage, orNonewhen nothing in the querysets is located.Example:
python spatial_coverage( (dataset.samples.all(), "location"), (dataset.measurements.with_effective_location(None), "effective_location"), )