geonode.base.bbox_utils
Classes
A bounding box representation to avoid use of list indices when dealing with bounding boxes. |
Functions
|
Normalise x-axis value/longtitude to fall within [-180, 180] |
|
Constructs a Polygon object with srid from a provided bbox. |
|
Filters a queryset by a provided bounding box. |
|
|
|
|
|
Module Contents
- class geonode.base.bbox_utils.BBOXHelper(minmaxform)[source]
A bounding box representation to avoid use of list indices when dealing with bounding boxes.
- geonode.base.bbox_utils.normalize_x_value(value)[source]
Normalise x-axis value/longtitude to fall within [-180, 180]
- geonode.base.bbox_utils.polygon_from_bbox(bbox, srid=4326)[source]
Constructs a Polygon object with srid from a provided bbox.
- geonode.base.bbox_utils.filter_bbox(queryset, bbox)[source]
Filters a queryset by a provided bounding box.
- Parameters:
bbox – Comma-separated coordinates as “xmin,ymin,xmax,ymax”
- geonode.base.bbox_utils.check_crossing(lon1: float, lon2: float, validate: bool = False, dlon_threshold: float = 180.0)[source]
-
Assuming a minimum travel distance between two provided longitude coordinates, checks if the 180th meridian (antimeridian) is crossed.
- geonode.base.bbox_utils.translate_polygons(geometry_collection: shapely.geometry.GeometryCollection, output_format: str = 'geojson') Generator[List[dict] | List[shapely.geometry.Polygon], None, None][source]
- geonode.base.bbox_utils.split_polygon(geojson: dict, output_format: str = 'geojson', validate: bool = False) List[dict] | List[shapely.geometry.Polygon] | shapely.geometry.GeometryCollection[source]
-
Given a GeoJSON representation of a Polygon, returns a collection of ‘antimeridian-safe’ constituent polygons split at the 180th meridian, ensuring compliance with GeoJSON standards (https://tools.ietf.org/html/rfc7946#section-3.1.9)
Assumptions:
Any two consecutive points with over 180 degrees difference in longitude are assumed to cross the antimeridian
The polygon spans less than 360 degrees in longitude (i.e. does not wrap around the globe)
However, the polygon may cross the antimeridian on multiple occasions
- Parameters:
(dict) (geojson) –
GeoJSON of input polygon to be split. For example:
{ "type": "Polygon", "coordinates": [ [ [179.0, 0.0], [-179.0, 0.0], [-179.0, 1.0], [179.0, 1.0], [179.0, 0.0] ] ] }
output_format (str): Available options: "geojson", "polygons", "geometrycollection" If "geometrycollection" returns a Shapely GeometryCollection. Otherwise, returns a list of either GeoJSONs or Shapely Polygons validate (bool): Checks if all longitudes are within [-180.0, 180.0]
- Returns:
List[dict]/List[Polygon]/GeometryCollection: antimeridian-safe polygon(s)