Shapely Integration¶
This module provides utility functions for integrating with Shapely.
Note
As GeoAlchemy 2 itself has no dependency on Shapely, applications using functions of this module have to ensure that Shapely is available.
-
geoalchemy2.shape.
from_shape
(shape, srid=-1, extended=False)[source]¶ Function to convert a Shapely geometry to a
geoalchemy2.types.WKBElement
.Additional arguments:
srid
An integer representing the spatial reference system. E.g. 4326. Default value is -1, which means no/unknown reference system.extended
A boolean to switch between WKB and EWKB. Default value is False.Example:
from shapely.geometry import Point wkb_element = from_shape(Point(5, 45), srid=4326) ewkb_element = from_shape(Point(5, 45), srid=4326, extended=True)