bounds
Classes
Module Contents
- class bounds.BoundingBox(x_min, x_max, y_min, y_max, crs=coordinate_reference_systems.DEFAULT_CRS)
- contains_point(point, crs=None)
Determine whether or not a point lies within this bounding box.
- Parameters:
point (tuple) – An x, y tuple representing the coordinates of the point.
crs (cartopy.crs.CRS, optional) – The coordinate reference system on which the x and y coordinates of the given point are defined. If None (default), assumes the input point uses the same coordinate reference system as this bounding box.
- Return type:
bool
- crs
- property east
Convenience property to access this bbox’s furthest east point.
- classmethod from_bbox(bbox, source_crs=None, target_crs=None)
Generate a bounding box which completely contains another bounding box.
The intended use case of this method is to generate a bounding box on a different coordinate reference system to an input bounding box, ensuring that the entire input bounding box is countained.
- Parameters:
bbox (list or earthkit.plots.geo.bounds.BoundingBox) – The bounding box around which to generate a new bounding box. If a list, mus
source_crs (cartopy.crs.CRS, optional) – The coordinate reference system of the source bounding box. If None (default), assumes a cylindrical lat-lon CRS, unless the source bounding box is an earthkit.plots.geo.bounds.BoundingBox with its own CRS.
target_crs (cartopy.crs.CRS, optional) – The coordinate reference system in which to generate a new bounding box which entriely contains the input bounding box. If None (default), attempts to find an “optimised” target CRS based on the domain extents.
- Return type:
earthkit.plots.geo.bounds.BoundingBox
- classmethod from_geometry(geometry, source_crs=coordinate_reference_systems.DEFAULT_CRS, target_crs=None)
Generate a tight bounding box around a geometry.
- Parameters:
geometry (shapely.geometry) – A shapely geometry around which the bounding box should be drawn.
source_crs (cartopy.crs.CRS, optional) – The coordinate reference system on which the geometry’s coordinates are defined. If None, assumes a cylindrical lat-lon CRS.
target_crs (cartopy.crs.CRS, optional) – The target coordinate reference system for the generated bounding box.
- Return type:
earthkit.plots.geo.bounds.BoundingBox
- property north
Convenience property to access this bbox’s furthest north point.
- property south
Convenience property to access this bbox’s furthest south point.
- to_bbox(target_crs)
Convert bounding box onto a new coordinate reference system.
Paratemers
- target_crscartopy.crs.CRS
The coordinate reference system to use for the new bounding box.
- rtype:
earthkit.plots.geo.BoundingBox
- to_cartopy_bounds()
Convert bounding box to a cartopy-compatible list of bounds.
- Return type:
tuple
- to_latlon_bbox()
Generate a tight bounding box around a geometry.
- Parameters:
geometry (shapely.geometry) – A shapely geometry around which the bounding box should be drawn.
source_crs (cartopy.crs.CRS, optional) – The coordinate reference system on which the geometry’s coordinates are defined. If None, assumes a cylindrical lat-lon CRS.
target_crs (cartopy.crs.CRS, optional) – The target coordinate reference system for the generated bounding box.
- Return type:
earthkit.plots.geo.bounds.BoundingBox
- to_optimised_bbox()
Generate a new bounding box using the “optimised” CRS for these extents.
- The method for choosing an optimised CRS is as follows:
If the area of the map is greater than 60% of the globe, use a global equirectangular CRS.
If the central latitude is within ±25 degrees, use an equirectangular CRS.
If the central latitude is greater (less) than +(-)75 degrees, use a North (South) Polar Stereo CRS.
If the central latitude falls between ±25 and ±75 degrees and the aspect ratio is > 0.8, use an Albers Equal Area CRS.
If the central latitude falls between ±25 and ±75 degrees and the aspect ratio is < 0.8, use a Transverse Mercator CRS.
This method is adapted from the method used by https://projectionwizard.org, which is discussed in the following article: Šavrič, B., Jenny, B. and Jenny, H. (2016). Projection Wizard – An online map projection selection tool. The Cartographic Journal, 53–2, p. 177–185. Doi: 10.1080/00087041.2015.1131938.
- Parameters:
bounds (list) – The latitude and longitude extents of the bounding box, given as [min_longitude, max_longitude, min_latitude, max_latitude].
- Return type:
cartopy.crs.CRS
- property west
Convenience property to access this bbox’s furthest west point.
- x_max
- x_min
- y_max
- y_min