Utils module
Utils
module#
- gfinder.utils.add_roi_to_geojson(geojson_file, id, center_lon, center_lat, diameter, body_radius, n_vertices)[source]#
- gfinder.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.
- gfinder.utils.nomenclature_to_roi(input_geojson_file, output_geojson_file, body_radius, n_vertices)[source]#
Turn an input nomenclature GeoJSON file containing the longitude, latitude, and diameter of each POINT feature into an output GeoJSON file containing a ‘polygonized’ geometry features.
- gfinder.utils.split_polygon(geojson: dict, output_format: str = 'geojson', validate: bool = False) Union[List[dict], List[shapely.geometry.polygon.Polygon], shapely.geometry.collection.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
geojson (dict) –
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
antimeridian-safe polygon(s)
- Return type
List[dict]/List[Polygon]/GeometryCollection