Elements¶
- class geoalchemy2.elements._SpatialElement(data, srid: int = -1, extended: bool | None = None)[source]¶
Bases:
objectThe base class for public spatial elements.
- Parameters:
data – The first argument passed to the constructor is the data wrapped by the
_SpatialElementobject being constructed.srid – An integer representing the spatial reference system. E.g.
4326. Default value is-1, which means no/unknown reference system.extended – A boolean indicating whether the extended format (EWKT or EWKB) is used. Default is
None.
- class geoalchemy2.elements.WKTElement(data: str, srid: int = -1, extended: bool | None = None)[source]¶
Bases:
_SpatialElementInstances of this class wrap a WKT or EWKT value.
Usage examples:
wkt_element_1 = WKTElement('POINT(5 45)') wkt_element_2 = WKTElement('POINT(5 45)', srid=4326) wkt_element_3 = WKTElement('SRID=4326;POINT(5 45)', extended=True)
- SPLIT_WKT_PATTERN = re.compile('((SRID=\\d+) *; *)?([\\w ]+) *(\\([-\\d\\. ,\\(\\)]+\\))')¶
- as_ewkt() WKTElement[source]¶
- as_wkt() WKTElement[source]¶
- property desc: str¶
This element’s description string.
- geom_from: str = 'ST_GeomFromText'¶
- geom_from_extended_version: str = 'ST_GeomFromEWKT'¶
- class geoalchemy2.elements.WKBElement(data: str | bytes | memoryview, srid: int = -1, extended: bool | None = None)[source]¶
Bases:
_SpatialElementInstances of this class wrap a WKB or EWKB value.
Geometry values read from the database are converted to instances of this type. In most cases you won’t need to create
WKBElementinstances yourself.If
extendedisTrueandsridis-1at construction time then the SRID will be read from the EWKB data.Note: you can create
WKBElementobjects from Shapely geometries using thegeoalchemy2.shape.from_shape()function.- as_ewkb() WKBElement[source]¶
- as_wkb() WKBElement[source]¶
- property desc: str¶
This element’s description string.
- geom_from: str = 'ST_GeomFromWKB'¶
- geom_from_extended_version: str = 'ST_GeomFromEWKB'¶
- class geoalchemy2.elements.RasterElement(data: str | bytes | memoryview)[source]¶
Bases:
_SpatialElementInstances of this class wrap a
rastervalue.Raster values read from the database are converted to instances of this type. In most cases you won’t need to create
RasterElementinstances yourself.- property desc: str¶
This element’s description string.