Geometry
- class geometry.shape.Shape
Represents a shape, like a point, line, polygon or multi polgygon. Provides functionality to convert to and from ESDL geometries, Shapely geometries, WKT/WKB, Leaflet (used in the ESDL MapEditor), GeoJSON. Uses a Shapely shape internally and provides different methods to convert to and from different other formats.
- __init__()
Constructor of the Shape class.
- static create(shape_input)
Function to create an instance of the right subclass of Shape based on any input. Tries to guess the input format and returns an instance of the right class.
- Parameters:
shape_input – input that represents information about the shape. Can be a list with coordinates, a dictionary with “lat” and “lng” fields, an ESDL geometry object or a Shapely geometry object.
- Returns:
an instance of the right Shape subclass
- static parse_esdl(esdl_geometry)
Function that parses an ESDL geometry object. Must be overridden by the subclass.
- static parse_leaflet(leaflet_coords)
Function that parses an list of leaflet coordinates. Must be overridden by the subclass.
- static parse_geojson_geometry(geojson_geometry)
Function that parses a GeoJSON string and creates an instance of the right Shape subclass
- Parameters:
geojson_geometry – GeoJSON string
- Returns:
an instance of the right Shape subclass with the parsed geometry information from the GeoJSON string
- static parse_wkt(wkt_geometry, crs='EPSG:4326')
Function that parses a WKT string and creates an instance of the right Shape subclass
- Parameters:
wkt_geometry – a WKT (Well Known Text) string
- Returns:
an instance of the right Shape subclass with the parsed geometry information from the WKT string
- static parse_wkb(wkb_geometry, crs='EPSG:4326')
Function that parses a WKB string and creates an instance of the right Shape subclass
- Parameters:
wkb_geometry – a WKB (Well Known Binary) byte string
- Returns:
an instance of the right Shape subclass with the parsed geometry information from the WKB string
- static parse_esdl_wkt(esdl_wkt)
Function that parses an esdl.WKT string and creates an instance of the right Shape subclass
- Parameters:
esdl_wkt – an instance of esdl.WKT
- Returns:
an instance of the right Shape subclass with the parsed geometry information from the esdl.WKT
- static parse_esdl_wkb(esdl_wkb)
Function that parses an esdl.WKB string and creates an instance of the right Shape subclass
- Parameters:
esdl_wkb – an instance of esdl.WKB
- Returns:
an instance of the right Shape subclass with the parsed geometry information from the esdl.WKB
- get_shape()
Function that returns the Shapely geometry representation of the loaded geometry
- get_esdl()
Function that returns an ESDL geometry. Must be overridden by the subclass.
- get_wkt()
Function that generates a WKT string from the loaded geometry
- Returns:
a WKT string representing the loaded geometry information
- get_geojson_feature(properties={})
Function that generates a GeoJSON feature from the loaded geometry, with the properties given as an input
- Parameters:
properties – the properties that must be added to the GeoJSON FFeature
- Returns:
a GeoJSON Feature representing the loaded geometry information, with the given properties
- static transform_crs(shp, from_crs)
Function that transforms the CRS (Coordinate Reference System) of the Shapely shape to WGS84 (EPSG:4326)
- Shp:
input Shapely shape in any CRS that is supported by pyproj
- From_crs:
the CRS used for the Shapely shape
- Returns:
Shapely shape transformed to WGS84
- class geometry.shape.ShapePoint(shape_input)
Represents a point. Provides functionality to convert to and from esdl.Point, Shapely Point, WKT/WKB, Leaflet (used in the ESDL MapEditor), GeoJSON. Uses a Shapely Point internally and provides different methods to convert to and from different other formats.
- __init__(shape_input)
Constructor of the ShapePoint class. Can be called with an esdl.Point, a dictionary with “lat” and “lng” keys, or a Shapely Point instance
- Parameters:
shape_input – the input shape, can be an esdl.Point, a dictionary with “lat” and “lng” keys, or a Shapely Point instance
- static parse_esdl(esdl_geometry)
Function that uses an esdl.Point instance as an input to generate a Shapely Point (using WGS84 as CRS)
- Parameters:
esdl_geometry – an esdl.Point instance
- Returns:
a Shapely shape (using WGS84 as CRS)
- static parse_leaflet(leaflet_coords)
Function that uses a dictionary with “lat” and “lng” keys as an input to generate a Shapely Point (using WGS84 as CRS)
- Parameters:
esdl_geometry – a dictionary with “lat” and “lng” keys
- Returns:
a Shapely Point (using WGS84 as CRS)
- get_esdl()
Function that generates an esdl.Point instance based on the loaded shape.
- Returns:
an esdl.Point instance based on the loaded shape
- class geometry.shape.ShapeLine(shape_input)
Represents a line. Provides functionality to convert to and from esdl.Line, Shapely LineString, WKT/WKB, Leaflet (used in the ESDL MapEditor), GeoJSON. Uses a Shapely LineString internally and provides different methods to convert to and from different other formats.
- __init__(shape_input)
Constructor of the ShapeLine class. Can be called with an esdl.Line, a list of dictionaries with “lat” and “lng” keys, or a Shapely LineString instance
- Parameters:
shape_input – the input shape, can be an esdl.Line, a list of dictionaries with “lat” and “lng” keys, or a Shapely LineString instance
- static parse_esdl(esdl_geometry)
Function that uses an esdl.Line instance as an input to generate a Shapely LineString (using WGS84 as CRS)
- Parameters:
esdl_geometry – an esdl.Line instance
- Returns:
a Shapely LineString (using WGS84 as CRS)
- static parse_leaflet(leaflet_coords)
Function that uses a list of dictionaries with “lat” and “lng” keys as an input to generate a Shapely LineString (using WGS84 as CRS)
- Parameters:
esdl_geometry – a list of dictionaries with “lat” and “lng” keys
- Returns:
a Shapely LineString (using WGS84 as CRS)
- get_esdl()
Function that generates an esdl.Line instance based on the loaded shape.
- Returns:
an esdl.Line instance based on the loaded shape
- class geometry.shape.ShapePolygon(shape_input)
Represents a polygon. Provides functionality to convert to and from esdl.Polygon, Shapely Polygon, WKT/WKB, Leaflet (used in the ESDL MapEditor), GeoJSON. Uses a Shapely Polygon internally and provides different methods to convert to and from different other formats.
- __init__(shape_input)
Constructor of the ShapePolygon class. Can be called with an esdl.Polygon, a list of lists of dictionaries with “lat” and “lng” keys, or a Shapely Polygon instance
- Parameters:
shape_input – the input shape, can be an esdl.Polygon, a list of lists of dictionaries with “lat” and “lng” keys, or a Shapely Polygon instance
- static parse_esdl(esdl_geometry)
Function that uses an esdl.Polygon instance as an input to generate a Shapely Polygon (using WGS84 as CRS)
- Parameters:
esdl_geometry – an esdl.Polygon instance
- Returns:
a Shapely Polygon (using WGS84 as CRS)
- static parse_leaflet(leaflet_coords)
Function that uses a list of lists of dictionaries with “lat” and “lng” keys as an input to generate a Shapely Polygon (using WGS84 as CRS). The first element in the list represents the exterior of the polygon, the other elements represent zero, one or more interiors (holes in the polygon)
- Parameters:
esdl_geometry – a list of lists of dictionaries with “lat” and “lng” keys
- Returns:
a Shapely Polygon (using WGS84 as CRS)
- get_esdl()
Function that generates an esdl.Polygon instance based on the loaded shape.
- Returns:
an esdl.Polygon instance based on the loaded shape
- class geometry.shape.ShapeMultiPolygon(shape_input)
Represents a multipolygon. Provides functionality to convert to and from esdl.MultiPolygon, Shapely MultiPolygon, WKT/WKB, Leaflet (used in the ESDL MapEditor), GeoJSON. Uses a Shapely MultiPolygon internally and provides different methods to convert to and from different other formats.
- __init__(shape_input)
Constructor of the ShapeMultiPolygon class. Can be called with an esdl.MultiPolygon, a list of lists of lists of dictionaries with “lat” and “lng” key, or a Shapely Polygon instance
- Parameters:
shape_input – the input shape, can be an esdl.Polygon, a list of lists of dictionaries with “lat” and “lng” key, or a Shapely Polygon instance
- static parse_esdl(esdl_geometry)
Function that uses an esdl.MultiPolygon instance as an input to generate a Shapely MultiPolygon (using WGS84 as CRS)
- Parameters:
esdl_geometry – an esdl.MultiPolygon instance
- Returns:
a Shapely MultiPolygon (using WGS84 as CRS)
- static parse_leaflet(leaflet_coords)
Function that uses a list of lists of lists of dictionaries with “lat” and “lng” keys as an input to generate a Shapely MultiPolygon (using WGS84 as CRS). Iterates over the outer list and calls ShapePolygon.parse_leaflet for each element
- Parameters:
esdl_geometry – a list of lists of lists of dictionaries with “lat” and “lng” keys
- Returns:
a Shapely MultiPolygon (using WGS84 as CRS)
- get_esdl()
This get_esdl function is not yet implemented for the ShapeMultiPolygon class, as MultiPolygon is not a frequent ESDL geometry
- get_polygon_list_esdl()
Function that generates a list of esdl.Polygons, based on the loaded MultiPolygon shape.
- Returns:
list of esdl.Polygons
- class geometry.shape.ShapeGeometryCollection(shape_input)
Represents a geometry collection. Provides functionality to convert to and from Shapely GeometryCollection, WKT/WKB and GeoJSON. Uses a Shapely GeometryCollection internally and provides different methods to convert to and from different other formats.
- __init__(shape_input)
Constructor of the ShapeGeometryCollection class. Can be called with a Shapely GeometryCollection instance
- Parameters:
shape_input – the input shape, can be a Shapely GeometryCollection instance
- get_esdl()
This get_esdl function is not yet implemented for the ShapeGeometryCollection class, as GeometryCollection is not a frequent ESDL geometry