pyinterp.geometry.cartesian.algorithms.from_geojson#
- pyinterp.geometry.cartesian.algorithms.from_geojson(geojson: str) pyinterp.core.geometry.cartesian.Point | pyinterp.core.geometry.cartesian.LineString | pyinterp.core.geometry.cartesian.Ring | pyinterp.core.geometry.cartesian.Polygon | pyinterp.core.geometry.cartesian.MultiPoint | pyinterp.core.geometry.cartesian.MultiLineString | pyinterp.core.geometry.cartesian.MultiPolygon#
Creates a geometry from GeoJSON representation.
Parses a GeoJSON string and constructs the corresponding geometry object. The function automatically detects the geometry type from the GeoJSON “type” field and returns the appropriate geometry object.
- Parameters:
geojson – GeoJSON string representation of the geometry.
- Returns:
Point, LineString, Ring, Polygon, MultiPoint, MultiLineString, or MultiPolygon depending on the GeoJSON type field.
- Return type:
A variant containing one of
Examples
>>> geojson_str = '{"type":"Point","coordinates":[1.0,2.0]}' >>> point = from_geojson(geojson_str) >>> # Returns Point(1.0, 2.0)
>>> geojson_str = '{"type":"Polygon","coordinates":[[[0,0],[1,0],[1,1],[0,1],[0,0]]]}' >>> polygon = from_geojson(geojson_str) >>> # Returns Polygon object