Spatial Functions

This module defines the GenericFunction class, which is the base for the implementation of spatial functions in GeoAlchemy. This module is also where actual spatial functions are defined. Spatial functions supported by GeoAlchemy are defined in this module. See GenericFunction to know how to create new spatial functions.

Note

By convention the names of spatial functions are prefixed by ST_. This is to be consistent with PostGIS’, which itself is based on the SQL-MM standard.

Functions created by subclassing GenericFunction can be called in several ways:

  • By using the func object, which is the SQLAlchemy standard way of calling a function. For example, without the ORM:

    select([func.ST_Area(lake_table.c.geom)])
    

    and with the ORM:

    Session.query(func.ST_Area(Lake.geom))
    
  • By applying the function to a geometry column. For example, without the ORM:

    select([lake_table.c.geom.ST_Area()])
    

    and with the ORM:

    Session.query(Lake.geom.ST_Area())
    
  • By applying the function to a geoalchemy2.elements.WKBElement object (geoalchemy2.elements.WKBElement is the type into which GeoAlchemy converts geometry values read from the database), or to a geoalchemy2.elements.WKTElement object. For example, without the ORM:

    conn.scalar(lake['geom'].ST_Area())
    

    and with the ORM:

    session.scalar(lake.geom.ST_Area())
    

Reference

class geoalchemy2.functions.GenericFunction(*args, **kwargs)[source]

The base class for GeoAlchemy functions.

This class inherits from sqlalchemy.sql.functions.GenericFunction, so functions defined by subclassing this class can be given a fixed return type. For example, functions like ST_Buffer and ST_Envelope have their type attributes set to geoalchemy2.types.Geometry.

This class allows constructs like Lake.geom.ST_Buffer(2). In that case the Function instance is bound to an expression (Lake.geom here), and that expression is passed to the function when the function is actually called.

If you need to use a function that GeoAlchemy does not provide you will certainly want to subclass this class. For example, if you need the ST_TransScale spatial function, which isn’t (currently) natively supported by GeoAlchemy, you will write this:

from geoalchemy2 import Geometry
from geoalchemy2.functions import GenericFunction

class ST_TransScale(GenericFunction):
    name = 'ST_TransScale'
    type = Geometry
class geoalchemy2.functions.ST_3DMakeBox(*args, **kwargs)

Creates a BOX3D defined by the given 3d point geometries.

see http://postgis.net/docs/ST_3DMakeBox.html

Return type: geoalchemy2.types.Geometry.

type

alias of geoalchemy2.types.Geometry

class geoalchemy2.functions.ST_AddPoint(*args, **kwargs)

Add a point to a LineString.

see http://postgis.net/docs/ST_AddPoint.html

Return type: geoalchemy2.types.Geometry.

type

alias of geoalchemy2.types.Geometry

class geoalchemy2.functions.ST_Affine(*args, **kwargs)

Apply a 3d affine transformation to a geometry.

see http://postgis.net/docs/ST_Affine.html

Return type: geoalchemy2.types.Geometry.

type

alias of geoalchemy2.types.Geometry

class geoalchemy2.functions.ST_Area(*args, **kwargs)

Returns the area of the surface if it is a polygon or multi-polygon. For geometry type area is in SRID units. For geography area is in square meters.

see http://postgis.net/docs/ST_Area.html

class geoalchemy2.functions.ST_AsBinary(*args, **kwargs)

Return the Well-Known Binary (WKB) representation of the geometry/geography without SRID meta data.

see http://postgis.net/docs/ST_AsBinary.html

class geoalchemy2.functions.ST_AsEWKB(*args, **kwargs)

Return the Well-Known Binary (WKB) representation of the geometry/geography with SRID meta data.

see http://postgis.net/docs/ST_AsEWKB.html

class geoalchemy2.functions.ST_AsEWKT(*args, **kwargs)

Return the Well-Known Text (WKT) representation of the geometry/geography with SRID metadata.

see http://postgis.net/docs/ST_AsEWKT.html

class geoalchemy2.functions.ST_AsGML(*args, **kwargs)

Return the geometry as a GML version 2 or 3 element.

see http://postgis.net/docs/ST_AsGML.html

class geoalchemy2.functions.ST_AsGeoJSON(*args, **kwargs)[source]

Return the geometry as a GeoJSON “geometry” object, or the row as a GeoJSON feature” object (PostGIS 3 only). (Cf GeoJSON specifications RFC 7946). 2D and 3D Geometries are both supported. GeoJSON only support SFS 1.1 geometry types (no curve support for example). See https://postgis.net/docs/ST_AsGeoJSON.html

class geoalchemy2.functions.ST_AsKML(*args, **kwargs)

Return the geometry as a KML element. Several variants. Default version=2, default precision=15

see http://postgis.net/docs/ST_AsKML.html

class geoalchemy2.functions.ST_AsRaster(*args, **kwargs)

Converts a PostGIS geometry to a PostGIS raster.

see http://postgis.net/docs/RT_ST_AsRaster.html

Return type: geoalchemy2.types.Raster.

type

alias of geoalchemy2.types.Raster

class geoalchemy2.functions.ST_AsSVG(*args, **kwargs)

Returns a Geometry in SVG path data given a geometry or geography object.

see http://postgis.net/docs/ST_AsSVG.html

class geoalchemy2.functions.ST_AsTWKB(*args, **kwargs)

Returns the geometry as TWKB, aka “Tiny Well-Known Binary”

see http://postgis.net/docs/ST_AsTWKB.html

class geoalchemy2.functions.ST_AsText(*args, **kwargs)

Return the Well-Known Text (WKT) representation of the geometry/geography without SRID metadata.

see http://postgis.net/docs/ST_AsText.html

class geoalchemy2.functions.ST_Azimuth(*args, **kwargs)

Returns the angle in radians from the horizontal of the vector defined by pointA and pointB. Angle is computed clockwise from down-to-up: on the clock: 12=0; 3=PI/2; 6=PI; 9=3PI/2.

see http://postgis.net/docs/ST_Azimuth.html

class geoalchemy2.functions.ST_BdMPolyFromText(*args, **kwargs)

Construct a MultiPolygon given an arbitrary collection of closed linestrings as a MultiLineString text representation Well-Known text representation.

see http://postgis.net/docs/ST_BdMPolyFromText.html

Return type: geoalchemy2.types.Geometry.

type

alias of geoalchemy2.types.Geometry

class geoalchemy2.functions.ST_BdPolyFromText(*args, **kwargs)

Construct a Polygon given an arbitrary collection of closed linestringsas a MultiLineString Well-Known text representation.

see http://postgis.net/docs/ST_BdPolyFromText.html

Return type: geoalchemy2.types.Geometry.

type

alias of geoalchemy2.types.Geometry

class geoalchemy2.functions.ST_Boundary(*args, **kwargs)

Returns the closure of the combinatorial boundary of this Geometry.

see http://postgis.net/docs/ST_Boundary.html

Return type: geoalchemy2.types.Geometry.

type

alias of geoalchemy2.types.Geometry

class geoalchemy2.functions.ST_BoundingDiagonal(*args, **kwargs)

Returns the diagonal of the supplied geometry’s bounding box.

see http://postgis.net/docs/ST_BoundingDiagonal.html

Return type: geoalchemy2.types.Geometry.

type

alias of geoalchemy2.types.Geometry

class geoalchemy2.functions.ST_Box2dFromGeoHash(*args, **kwargs)

Return a BOX2D from a GeoHash string.

see http://postgis.net/docs/ST_Box2dFromGeoHash.html

Return type: geoalchemy2.types.Geometry.

type

alias of geoalchemy2.types.Geometry

class geoalchemy2.functions.ST_Buffer(*args, **kwargs)

For geometry: Returns a geometry that represents all points whose distance from this Geometry is less than or equal to distance. Calculations are in the Spatial Reference System of this Geometry.

For geography: Uses a planar transform wrapper. Introduced in 1.5 support for different end cap and mitre settings to control shape.

see http://postgis.net/docs/ST_Buffer.html

Return type: geoalchemy2.types.Geometry.

type

alias of geoalchemy2.types.Geometry

class geoalchemy2.functions.ST_Centroid(*args, **kwargs)

Returns the geometric center of a geometry.

see http://postgis.net/docs/ST_Centroid.html

Return type: geoalchemy2.types.Geometry.

type

alias of geoalchemy2.types.Geometry

class geoalchemy2.functions.ST_CollectionExtract(*args, **kwargs)

Given a (multi)geometry, return a (multi)geometry consisting only of elements of the specified type.

see http://postgis.net/docs/ST_CollectionExtract.html

Return type: geoalchemy2.types.Geometry.

type

alias of geoalchemy2.types.Geometry

class geoalchemy2.functions.ST_CollectionHomogenize(*args, **kwargs)

Given a geometry collection, return the “simplest” representation of the contents.

see http://postgis.net/docs/ST_CollectionHomogenize.html

Return type: geoalchemy2.types.Geometry.

type

alias of geoalchemy2.types.Geometry

class geoalchemy2.functions.ST_Contains(*args, **kwargs)

Returns True if and only if no points of B lie in the exterior of A, and at least one point of the interior of B lies in the interior of A.

see http://postgis.net/docs/ST_Contains.html

class geoalchemy2.functions.ST_ContainsProperly(*args, **kwargs)

Returns True if B intersects the interior of A but not the boundary (or exterior). A does not contain properly itself, but does contain itself.

see http://postgis.net/docs/ST_ContainsProperly.html

class geoalchemy2.functions.ST_CoveredBy(*args, **kwargs)

Returns True if no point in Geometry/Geography A is outside Geometry/Geography B

see http://postgis.net/docs/ST_CoveredBy.html

class geoalchemy2.functions.ST_Covers(*args, **kwargs)

Returns True if no point in Geometry B is outside Geometry A

see http://postgis.net/docs/ST_Covers.html

class geoalchemy2.functions.ST_Crosses(*args, **kwargs)

Returns True if the supplied geometries have some, but not all, interior points in common.

see http://postgis.net/docs/ST_Crosses.html

class geoalchemy2.functions.ST_DFullyWithin(*args, **kwargs)

Returns True if all of the geometries are within the specified distance of one another

see http://postgis.net/docs/ST_DFullyWithin.html

class geoalchemy2.functions.ST_DWithin(*args, **kwargs)

Returns True if the geometries are within the specified distance of one another. For geometry units are in those of spatial reference and for geography units are in meters and measurement is defaulted to use_spheroid=True (measure around spheroid), for faster check, use_spheroid=False to measure along sphere.

see http://postgis.net/docs/ST_DWithin.html

class geoalchemy2.functions.ST_Difference(*args, **kwargs)

Returns a geometry that represents that part of geometry A that does not intersect with geometry B.

see http://postgis.net/docs/ST_Difference.html

Return type: geoalchemy2.types.Geometry.

type

alias of geoalchemy2.types.Geometry

class geoalchemy2.functions.ST_Disjoint(*args, **kwargs)

Returns True if the Geometries do not “spatially intersect” - if they do not share any space together.

see http://postgis.net/docs/ST_Disjoint.html

class geoalchemy2.functions.ST_Distance(*args, **kwargs)

For geometry type Returns the 2-dimensional cartesian minimum distance (based on spatial ref) between two geometries in projected units. For geography type defaults to return spheroidal minimum distance between two geographies in meters.

see http://postgis.net/docs/ST_Distance.html

class geoalchemy2.functions.ST_DistanceSphere(*args, **kwargs)

Returns minimum distance in meters between two lon/lat points. Uses a spherical earth and radius derived from the spheroid defined by the SRID. Faster than ST_DistanceSpheroid, but less accurate. PostGIS Versions prior to 1.5 only implemented for points. Availability: 1.5 - support for other geometry types besides points was introduced. Prior versions only work with points. Changed: 2.2.0 In prior versions this used to be called ST_Distance_Sphere

see http://postgis.net/docs/ST_DistanceSphere.html

class geoalchemy2.functions.ST_Distance_Sphere(*args, **kwargs)

Returns minimum distance in meters between two lon/lat geometries. Uses a spherical earth and radius of 6370986 meters. Faster than ST_Distance_Spheroid, but less accurate. PostGIS versions prior to 1.5 only implemented for points.

see http://postgis.net/docs/ST_Distance_Sphere.html

class geoalchemy2.functions.ST_Dump(*args, **kwargs)

Returns a set of geometry_dump (geom,path) rows, that make up a geometry g1.

see http://postgis.net/docs/ST_Dump.html

Return type: geoalchemy2.types.GeometryDump.

type

alias of geoalchemy2.types.GeometryDump

class geoalchemy2.functions.ST_DumpPoints(*args, **kwargs)

Returns a set of geometry_dump (geom,path) rows of all points that make up a geometry.

see http://postgis.net/docs/ST_DumpPoints.html

Return type: geoalchemy2.types.GeometryDump.

type

alias of geoalchemy2.types.GeometryDump

class geoalchemy2.functions.ST_EndPoint(*args, **kwargs)

Returns the last point of a LINESTRING or CIRCULARLINESTRING geometry as a POINT.

see http://postgis.net/docs/ST_EndPoint.html

Return type: geoalchemy2.types.Geometry.

type

alias of geoalchemy2.types.Geometry

class geoalchemy2.functions.ST_Envelope(*args, **kwargs)

Returns a geometry representing the double precision (float8) boundingbox of the supplied geometry.

see http://postgis.net/docs/ST_Envelope.html

Return type: geoalchemy2.types.Geometry.

type

alias of geoalchemy2.types.Geometry

class geoalchemy2.functions.ST_Equals(*args, **kwargs)

Returns True if the given geometries represent the same geometry. Directionality is ignored.

see http://postgis.net/docs/ST_Equals.html

class geoalchemy2.functions.ST_ExteriorRing(*args, **kwargs)

Returns a line string representing the exterior ring of the POLYGON geometry. Return NULL if the geometry is not a polygon. Will not work with MULTIPOLYGON.

see http://postgis.net/docs/ST_ExteriorRing.html

Return type: geoalchemy2.types.Geometry.

type

alias of geoalchemy2.types.Geometry

class geoalchemy2.functions.ST_Force2D(*args, **kwargs)

Force the geometries into a “2-dimensional mode”.

see http://postgis.net/docs/ST_Force2D.html

Return type: geoalchemy2.types.Geometry.

type

alias of geoalchemy2.types.Geometry

class geoalchemy2.functions.ST_Force3D(*args, **kwargs)

Force the geometries into XYZ mode. This is an alias for ST_Force3DZ.

see http://postgis.net/docs/ST_Force_3D.html

Return type: geoalchemy2.types.Geometry.

type

alias of geoalchemy2.types.Geometry

class geoalchemy2.functions.ST_Force3DM(*args, **kwargs)

Force the geometries into XYM mode.

see http://postgis.net/docs/ST_Force_3DM.html

Return type: geoalchemy2.types.Geometry.

type

alias of geoalchemy2.types.Geometry

class geoalchemy2.functions.ST_Force3DZ(*args, **kwargs)

Force the geometries into XYZ mode.

see http://postgis.net/docs/ST_Force_3DZ.html

Return type: geoalchemy2.types.Geometry.

type

alias of geoalchemy2.types.Geometry

class geoalchemy2.functions.ST_Force4D(*args, **kwargs)

Force the geometries into XYZM mode.

see http://postgis.net/docs/ST_Force_4D.html

Return type: geoalchemy2.types.Geometry.

type

alias of geoalchemy2.types.Geometry

class geoalchemy2.functions.ST_ForceCollection(*args, **kwargs)

Convert the geometry into a GEOMETRYCOLLECTION.

see http://postgis.net/docs/ST_Force_Collection.html

Return type: geoalchemy2.types.Geometry.

type

alias of geoalchemy2.types.Geometry

class geoalchemy2.functions.ST_ForceCurve(*args, **kwargs)

Upcast a geometry into its curved type, if applicable.

see http://postgis.net/docs/ST_ForceCurve.html

Return type: geoalchemy2.types.Geometry.

type

alias of geoalchemy2.types.Geometry

class geoalchemy2.functions.ST_ForcePolygonCCW(*args, **kwargs)

Orients all exterior rings counter-clockwise and all interior rings clockwise.

see http://postgis.net/docs/ST_ForcePolygonCCW.html

Return type: geoalchemy2.types.Geometry.

type

alias of geoalchemy2.types.Geometry

class geoalchemy2.functions.ST_ForcePolygonCW(*args, **kwargs)

Orients all exterior rings clockwise and all interior rings counter-clockwise.

see http://postgis.net/docs/ST_ForcePolygonCW.html

Return type: geoalchemy2.types.Geometry.

type

alias of geoalchemy2.types.Geometry

class geoalchemy2.functions.ST_ForceRHR(*args, **kwargs)

Force the orientation of the vertices in a polygon to follow the Right-Hand-Rule.

see http://postgis.net/docs/ST_ForceRHR.html

Return type: geoalchemy2.types.Geometry.

type

alias of geoalchemy2.types.Geometry

class geoalchemy2.functions.ST_ForceSFS(*args, **kwargs)

Force the geometries to use SFS 1.1 geometry types only.

see http://postgis.net/docs/ST_ForceSFS.html

Return type: geoalchemy2.types.Geometry.

type

alias of geoalchemy2.types.Geometry

class geoalchemy2.functions.ST_GMLToSQL(*args, **kwargs)

Return a specified ST_Geometry value from GML representation. This is an alias name for ST_GeomFromGML

see http://postgis.net/docs/ST_GMLToSQL.html

Return type: geoalchemy2.types.Geometry.

type

alias of geoalchemy2.types.Geometry

class geoalchemy2.functions.ST_GeogFromText(*args, **kwargs)

Return a specified geography value from Well-Known Text representation or extended (WKT).

see http://postgis.net/docs/ST_GeogFromText.html

Return type: geoalchemy2.types.Geography.

type

alias of geoalchemy2.types.Geography

class geoalchemy2.functions.ST_GeogFromWKB(*args, **kwargs)

Creates a geography instance from a Well-Known Binary geometry representation (WKB) or extended Well Known Binary (EWKB).

see http://postgis.net/docs/ST_GeogFromWKB.html

Return type: geoalchemy2.types.Geography.

type

alias of geoalchemy2.types.Geography

class geoalchemy2.functions.ST_GeographyFromText(*args, **kwargs)

Return a specified geography value from Well-Known Text representation or extended (WKT).

see http://postgis.net/docs/ST_GeographyFromText.html

Return type: geoalchemy2.types.Geography.

type

alias of geoalchemy2.types.Geography

class geoalchemy2.functions.ST_GeomCollFromText(*args, **kwargs)

Makes a collection Geometry from collection WKT with the given SRID. If SRID is not given, it defaults to 0.

see http://postgis.net/docs/ST_GeomCollFromText.html

Return type: geoalchemy2.types.Geometry.

type

alias of geoalchemy2.types.Geometry

class geoalchemy2.functions.ST_GeomFromEWKB(*args, **kwargs)

Return a specified ST_Geometry value from Extended Well-Known Binary representation (EWKB).

see http://postgis.net/docs/ST_GeomFromEWKB.html

Return type: geoalchemy2.types.Geometry.

type

alias of geoalchemy2.types.Geometry

class geoalchemy2.functions.ST_GeomFromEWKT(*args, **kwargs)

Return a specified ST_Geometry value from Extended Well-Known Text representation (EWKT).

see http://postgis.net/docs/ST_GeomFromEWKT.html

Return type: geoalchemy2.types.Geometry.

type

alias of geoalchemy2.types.Geometry

class geoalchemy2.functions.ST_GeomFromGML(*args, **kwargs)

Takes as input GML representation of geometry and outputs a PostGIS geometry object

see http://postgis.net/docs/ST_GeomFromGML.html

Return type: geoalchemy2.types.Geometry.

type

alias of geoalchemy2.types.Geometry

class geoalchemy2.functions.ST_GeomFromGeoHash(*args, **kwargs)

Return a geometry from a GeoHash string.

see http://postgis.net/docs/ST_GeomFromGeoHash.html

Return type: geoalchemy2.types.Geometry.

type

alias of geoalchemy2.types.Geometry

class geoalchemy2.functions.ST_GeomFromGeoJSON(*args, **kwargs)

Takes as input a geojson representation of a geometry and outputs a PostGIS geometry object

see http://postgis.net/docs/ST_GeomFromGeoJSON.html

Return type: geoalchemy2.types.Geometry.

type

alias of geoalchemy2.types.Geometry

class geoalchemy2.functions.ST_GeomFromKML(*args, **kwargs)

Takes as input KML representation of geometry and outputs a PostGIS geometry object

see http://postgis.net/docs/ST_GeomFromKML.html

Return type: geoalchemy2.types.Geometry.

type

alias of geoalchemy2.types.Geometry

class geoalchemy2.functions.ST_GeomFromTWKB(*args, **kwargs)

Creates a geometry instance from a TWKB (“Tiny Well-Known Binary”) geometry representation.

see http://postgis.net/docs/ST_GeomFromTWKB.html

Return type: geoalchemy2.types.Geometry.

type

alias of geoalchemy2.types.Geometry

class geoalchemy2.functions.ST_GeomFromText(*args, **kwargs)

Return a specified ST_Geometry value from Well-Known Text representation (WKT).

see http://postgis.net/docs/ST_GeomFromText.html

Return type: geoalchemy2.types.Geometry.

type

alias of geoalchemy2.types.Geometry

class geoalchemy2.functions.ST_GeomFromWKB(*args, **kwargs)

Creates a geometry instance from a Well-Known Binary geometry representation (WKB) and optional SRID.

see http://postgis.net/docs/ST_GeomFromWKB.html

Return type: geoalchemy2.types.Geometry.

type

alias of geoalchemy2.types.Geometry

class geoalchemy2.functions.ST_GeometryFromText(*args, **kwargs)

Return a specified ST_Geometry value from Well-Known Text representation (WKT). This is an alias name for ST_GeomFromText

see http://postgis.net/docs/ST_GeometryFromText.html

Return type: geoalchemy2.types.Geometry.

type

alias of geoalchemy2.types.Geometry

class geoalchemy2.functions.ST_GeometryN(*args, **kwargs)

Return the 1-based Nth geometry if the geometry is a GEOMETRYCOLLECTION, (MULTI)POINT, (MULTI)LINESTRING, MULTICURVE or (MULTI)POLYGON, POLYHEDRALSURFACE Otherwise, return None.

see http://postgis.net/docs/ST_GeometryN.html

Return type: geoalchemy2.types.Geometry.

type

alias of geoalchemy2.types.Geometry

class geoalchemy2.functions.ST_GeometryType(*args, **kwargs)

Return the geometry type of the ST_Geometry value.

see http://postgis.net/docs/ST_GeometryType.html

class geoalchemy2.functions.ST_Height(*args, **kwargs)

Returns the height of the raster in pixels.

see http://postgis.net/docs/RT_ST_Height.html

class geoalchemy2.functions.ST_InteriorRingN(*args, **kwargs)

Return the Nth interior linestring ring of the polygon geometry. Return NULL if the geometry is not a polygon or the given N is out of range.

see http://postgis.net/docs/ST_InteriorRingN.html

Return type: geoalchemy2.types.Geometry.

type

alias of geoalchemy2.types.Geometry

class geoalchemy2.functions.ST_Intersection(*args, **kwargs)

Returns a geometry that represents the shared portion of geomA and geomB. The geography implementation does a transform to geometry to do the intersection and then transform back to WGS84.

see http://postgis.net/docs/ST_Intersection.html

Return type: geoalchemy2.types.Geometry.

type

alias of geoalchemy2.types.Geometry

class geoalchemy2.functions.ST_Intersects(*args, **kwargs)

Returns True if the Geometries/Geography “spatially intersect in 2D” - (share any portion of space) and False if they don’t (they are Disjoint). For geography – tolerance is 0.00001 meters (so any points that close are considered to intersect)

see http://postgis.net/docs/ST_Intersects.html

class geoalchemy2.functions.ST_IsValid(*args, **kwargs)

Returns True if the ST_Geometry is well formed.

see http://postgis.net/docs/ST_IsValid.html

class geoalchemy2.functions.ST_Length(*args, **kwargs)

Returns the 2d length of the geometry if it is a linestring or multilinestring. geometry are in units of spatial reference and geography are in meters (default spheroid)

see http://postgis.net/docs/ST_Length.html

class geoalchemy2.functions.ST_LineFromEncodedPolyline(*args, **kwargs)

Creates a LineString from an Encoded Polyline.

see http://postgis.net/docs/ST_LineFromEncodedPolyline.html

Return type: geoalchemy2.types.Geometry.

type

alias of geoalchemy2.types.Geometry

class geoalchemy2.functions.ST_LineFromMultiPoint(*args, **kwargs)

Creates a LineString from a MultiPoint geometry.

see http://postgis.net/docs/ST_LineFromMultiPoint.html

Return type: geoalchemy2.types.Geometry.

type

alias of geoalchemy2.types.Geometry

class geoalchemy2.functions.ST_LineFromText(*args, **kwargs)

Makes a Geometry from WKT representation with the given SRID. If SRID is not given, it defaults to 0.

see http://postgis.net/docs/ST_LineFromText.html

Return type: geoalchemy2.types.Geometry.

type

alias of geoalchemy2.types.Geometry

class geoalchemy2.functions.ST_LineFromWKB(*args, **kwargs)

Makes a LINESTRING from WKB with the given SRID

see http://postgis.net/docs/ST_LineFromWKB.html

Return type: geoalchemy2.types.Geometry.

type

alias of geoalchemy2.types.Geometry

class geoalchemy2.functions.ST_LineLocatePoint(*args, **kwargs)

Returns a float between 0 and 1 representing the location of the closest point on LineString to the given Point, as a fraction of total 2d line length.

see http://postgis.net/docs/ST_LineLocatePoint.html

class geoalchemy2.functions.ST_LineMerge(*args, **kwargs)

Returns a (set of) LineString(s) formed by sewing together the constituent line work of a MULTILINESTRING.

see http://postgis.net/docs/ST_LineMerge.html

Return type: geoalchemy2.types.Geometry.

type

alias of geoalchemy2.types.Geometry

class geoalchemy2.functions.ST_LineSubstring(*args, **kwargs)

Return a linestring being a substring of the input one starting and ending at the given fractions of total 2d length. Second and third arguments are float8 values between 0 and 1. This only works with LINESTRINGs. To use with contiguous MULTILINESTRINGs use in conjunction with ST_LineMerge.If ‘start’ and ‘end’ have the same value this is equivalent to ST_LineInterpolatePoint.

see http://postgis.net/docs/ST_LineSubstring.html

Return type: geoalchemy2.types.Geometry.

type

alias of geoalchemy2.types.Geometry

class geoalchemy2.functions.ST_LinestringFromWKB(*args, **kwargs)

Makes a geometry from WKB with the given SRID.

see http://postgis.net/docs/ST_LinestringFromWKB.html

Return type: geoalchemy2.types.Geometry.

type

alias of geoalchemy2.types.Geometry

class geoalchemy2.functions.ST_M(*args, **kwargs)

Return the M coordinate of the point, or NULL if not available. Input must be a point.

see http://postgis.net/docs/ST_M.html

class geoalchemy2.functions.ST_MLineFromText(*args, **kwargs)

Return a specified ST_MultiLineString value from WKT representation.

see http://postgis.net/docs/ST_MLineFromText.html

Return type: geoalchemy2.types.Geometry.

type

alias of geoalchemy2.types.Geometry

class geoalchemy2.functions.ST_MPointFromText(*args, **kwargs)

Makes a Geometry from WKT with the given SRID. If SRID is not given, it defaults to 0.

see http://postgis.net/docs/ST_MPointFromText.html

Return type: geoalchemy2.types.Geometry.

type

alias of geoalchemy2.types.Geometry

class geoalchemy2.functions.ST_MPolyFromText(*args, **kwargs)

Makes a MultiPolygon Geometry from WKT with the given SRID. If SRID is not given, it defaults to 0.

see http://postgis.net/docs/ST_MPolyFromText.html

Return type: geoalchemy2.types.Geometry.

type

alias of geoalchemy2.types.Geometry

class geoalchemy2.functions.ST_MakeBox2D(*args, **kwargs)

Creates a BOX2D defined by the given point geometries.

see http://postgis.net/docs/ST_MakeBox2D.html

Return type: geoalchemy2.types.Geometry.

type

alias of geoalchemy2.types.Geometry

class geoalchemy2.functions.ST_MakeEnvelope(*args, **kwargs)

Creates a rectangular Polygon formed from the given minimums and maximums. Input values must be in SRS specified by the SRID.

see http://postgis.net/docs/ST_MakeEnvelope.html

Return type: geoalchemy2.types.Geometry.

type

alias of geoalchemy2.types.Geometry

class geoalchemy2.functions.ST_MakeLine(*args, **kwargs)

Creates a Linestring from point, multipoint, or line geometries.

see http://postgis.net/docs/ST_MakeLine.html

Return type: geoalchemy2.types.Geometry.

type

alias of geoalchemy2.types.Geometry

class geoalchemy2.functions.ST_MakePoint(*args, **kwargs)

Creates a 2D, 3DZ or 4D point geometry.

see http://postgis.net/docs/ST_MakePoint.html

Return type: geoalchemy2.types.Geometry.

type

alias of geoalchemy2.types.Geometry

class geoalchemy2.functions.ST_MakePointM(*args, **kwargs)

Creates a point geometry with an x y and m coordinate.

see http://postgis.net/docs/ST_MakePointM.html

Return type: geoalchemy2.types.Geometry.

type

alias of geoalchemy2.types.Geometry

class geoalchemy2.functions.ST_MakePolygon(*args, **kwargs)

Creates a Polygon formed by the given shell. Input geometries must be closed LINESTRINGS.

see http://postgis.net/docs/ST_MakePolygon.html

Return type: geoalchemy2.types.Geometry.

type

alias of geoalchemy2.types.Geometry

class geoalchemy2.functions.ST_MakeValid(*args, **kwargs)

Attempts to make an invalid geometry valid without losing vertices.

see http://postgis.net/docs/ST_MakeValid.html

Return type: geoalchemy2.types.Geometry.

type

alias of geoalchemy2.types.Geometry

class geoalchemy2.functions.ST_Multi(*args, **kwargs)

Return the geometry as a MULTI* geometry.

see http://postgis.net/docs/ST_Multi.html

Return type: geoalchemy2.types.Geometry.

type

alias of geoalchemy2.types.Geometry

class geoalchemy2.functions.ST_NPoints(*args, **kwargs)

Return the number of points (vertices) in a geometry.

see http://postgis.net/docs/ST_NPoints.html

class geoalchemy2.functions.ST_Normalize(*args, **kwargs)

Return the geometry in its canonical form.

see http://postgis.net/docs/ST_Normalize.html

Return type: geoalchemy2.types.Geometry.

type

alias of geoalchemy2.types.Geometry

class geoalchemy2.functions.ST_OrderingEquals(*args, **kwargs)

Returns True if the given geometries represent the same geometry and points are in the same directional order.

see http://postgis.net/docs/ST_OrderingEquals.html

class geoalchemy2.functions.ST_Overlaps(*args, **kwargs)

Returns True if the Geometries share space, are of the same dimension, but are not completely contained by each other.

see http://postgis.net/docs/ST_Overlaps.html

class geoalchemy2.functions.ST_PatchN(*args, **kwargs)

Return the 1-based Nth geometry (face) if the geometry is a POLYHEDRALSURFACE, POLYHEDRALSURFACEM. Otherwise, return NULL.

see http://postgis.net/docs/ST_PatchN.html

Return type: geoalchemy2.types.Geometry.

type

alias of geoalchemy2.types.Geometry

class geoalchemy2.functions.ST_Perimeter(*args, **kwargs)

Return the length measurement of the boundary of an ST_Surface or ST_MultiSurface geometry or geography. (Polygon, Multipolygon). geometry measurement is in units of spatial reference and geography is in meters.

see http://postgis.net/docs/ST_Perimeter.html

class geoalchemy2.functions.ST_Point(*args, **kwargs)

Returns an ST_Point with the given coordinate values. OGC alias for ST_MakePoint.

see http://postgis.net/docs/ST_Point.html

Return type: geoalchemy2.types.Geometry.

type

alias of geoalchemy2.types.Geometry

class geoalchemy2.functions.ST_PointFromGeoHash(*args, **kwargs)

Return a point from a GeoHash string.

see http://postgis.net/docs/ST_PointFromGeoHash.html

Return type: geoalchemy2.types.Geometry.

type

alias of geoalchemy2.types.Geometry

class geoalchemy2.functions.ST_PointFromText(*args, **kwargs)

Makes a point Geometry from WKT with the given SRID. If SRID is not given, it defaults to unknown.

see http://postgis.net/docs/ST_PointFromText.html

Return type: geoalchemy2.types.Geometry.

type

alias of geoalchemy2.types.Geometry

class geoalchemy2.functions.ST_PointFromWKB(*args, **kwargs)

Makes a geometry from WKB with the given SRID

see http://postgis.net/docs/ST_PointFromWKB.html

Return type: geoalchemy2.types.Geometry.

type

alias of geoalchemy2.types.Geometry

class geoalchemy2.functions.ST_PointN(*args, **kwargs)

Return the Nth point in the first LineString or circular LineString in the geometry. Negative values are counted backwards from the end of the LineString. Returns NULL if there is no linestring in the geometry.

see http://postgis.net/docs/ST_PointN.html

Return type: geoalchemy2.types.Geometry.

type

alias of geoalchemy2.types.Geometry

class geoalchemy2.functions.ST_Points(*args, **kwargs)

Returns a MultiPoint containing all of the coordinates of a geometry.

see http://postgis.net/docs/ST_Points.html

Return type: geoalchemy2.types.Geometry.

type

alias of geoalchemy2.types.Geometry

class geoalchemy2.functions.ST_Polygon(*args, **kwargs)

Returns a polygon built from the specified linestring and SRID.

see http://postgis.net/docs/ST_Polygon.html

Return type: geoalchemy2.types.Geometry.

type

alias of geoalchemy2.types.Geometry

class geoalchemy2.functions.ST_PolygonFromText(*args, **kwargs)

Makes a Geometry from WKT with the given SRID. If SRID is not given, it defaults to 0.

see http://postgis.net/docs/ST_PolygonFromText.html

Return type: geoalchemy2.types.Geometry.

type

alias of geoalchemy2.types.Geometry

class geoalchemy2.functions.ST_Project(*args, **kwargs)

Returns a POINT projected from a start point using a distance in meters and bearing (azimuth) in radians.

see http://postgis.net/docs/ST_Project.html

Return type: geoalchemy2.types.Geography.

type

alias of geoalchemy2.types.Geography

class geoalchemy2.functions.ST_QuantizeCoordinates(*args, **kwargs)

Sets least significant bits of coordinates to zero.

see http://postgis.net/docs/ST_QuantizeCoordinates.html

Return type: geoalchemy2.types.Geometry.

type

alias of geoalchemy2.types.Geometry

class geoalchemy2.functions.ST_Relate(*args, **kwargs)

Returns True if this Geometry is spatially related to anotherGeometry, by testing for intersections between the Interior, Boundary and Exterior of the two geometries as specified by the values in the intersectionMatrixPattern. If no intersectionMatrixPattern is passed in, then returns the maximum intersectionMatrixPattern that relates the 2 geometries.

see http://postgis.net/docs/ST_Relate.html

class geoalchemy2.functions.ST_RemovePoint(*args, **kwargs)

Remove point from a linestring.

see http://postgis.net/docs/ST_RemovePoint.html

Return type: geoalchemy2.types.Geometry.

type

alias of geoalchemy2.types.Geometry

class geoalchemy2.functions.ST_Reverse(*args, **kwargs)

Return the geometry with vertex order reversed.

see http://postgis.net/docs/ST_Reverse.html

Return type: geoalchemy2.types.Geometry.

type

alias of geoalchemy2.types.Geometry

class geoalchemy2.functions.ST_Rotate(*args, **kwargs)

Rotate a geometry rotRadians counter-clockwise about an origin.

see http://postgis.net/docs/ST_Rotate.html

Return type: geoalchemy2.types.Geometry.

type

alias of geoalchemy2.types.Geometry

class geoalchemy2.functions.ST_RotateX(*args, **kwargs)

Rotate a geometry rotRadians about the X axis.

see http://postgis.net/docs/ST_RotateX.html

Return type: geoalchemy2.types.Geometry.

type

alias of geoalchemy2.types.Geometry

class geoalchemy2.functions.ST_RotateY(*args, **kwargs)

Rotate a geometry rotRadians about the Y axis.

see http://postgis.net/docs/ST_RotateY.html

Return type: geoalchemy2.types.Geometry.

type

alias of geoalchemy2.types.Geometry

class geoalchemy2.functions.ST_RotateZ(*args, **kwargs)

Rotate a geometry rotRadians about the Z axis.

see http://postgis.net/docs/ST_RotateZ.html

Return type: geoalchemy2.types.Geometry.

type

alias of geoalchemy2.types.Geometry

class geoalchemy2.functions.ST_SRID(*args, **kwargs)

Returns the spatial reference identifier for the ST_Geometry as defined in spatial_ref_sys table.

see http://postgis.net/docs/ST_SRID.html

class geoalchemy2.functions.ST_Scale(*args, **kwargs)

Scale a geometry by given factors.

see http://postgis.net/docs/ST_Scale.html

Return type: geoalchemy2.types.Geometry.

type

alias of geoalchemy2.types.Geometry

class geoalchemy2.functions.ST_Segmentize(*args, **kwargs)

Return a modified geometry/geography having no segment longer than the given distance.

see http://postgis.net/docs/ST_Segmentize.html

Return type: geoalchemy2.types.Geometry.

type

alias of geoalchemy2.types.Geometry

class geoalchemy2.functions.ST_SetPoint(*args, **kwargs)

Replace point of a linestring with a given point.

see http://postgis.net/docs/ST_SetPoint.html

Return type: geoalchemy2.types.Geometry.

type

alias of geoalchemy2.types.Geometry

class geoalchemy2.functions.ST_SetSRID(*args, **kwargs)

Set the SRID on a geometry to a particular integer value.

see http://postgis.net/docs/ST_SetSRID.html

Return type: geoalchemy2.types.Geometry.

type

alias of geoalchemy2.types.Geometry

class geoalchemy2.functions.ST_Simplify(*args, **kwargs)

Returns a “simplified” version of the given geometry using the Douglas-Peucker algorithm.

see http://postgis.net/docs/ST_Simplify.html

Return type: geoalchemy2.types.Geometry.

type

alias of geoalchemy2.types.Geometry

class geoalchemy2.functions.ST_Snap(*args, **kwargs)

Snap segments and vertices of input geometry to vertices of a reference geometry.

see http://postgis.net/docs/ST_Snap.html

Return type: geoalchemy2.types.Geometry.

type

alias of geoalchemy2.types.Geometry

class geoalchemy2.functions.ST_SnapToGrid(*args, **kwargs)

Snap all points of the input geometry to a regular grid.

see http://postgis.net/docs/ST_SnapToGrid.html

Return type: geoalchemy2.types.Geometry.

type

alias of geoalchemy2.types.Geometry

class geoalchemy2.functions.ST_StartPoint(*args, **kwargs)

Returns the first point of a LINESTRING geometry as a POINT.

see http://postgis.net/docs/ST_StartPoint.html

Return type: geoalchemy2.types.Geometry.

type

alias of geoalchemy2.types.Geometry

class geoalchemy2.functions.ST_Touches(*args, **kwargs)

Returns True if the geometries have at least one point in common, but their interiors do not intersect.

see http://postgis.net/docs/ST_Touches.html

class geoalchemy2.functions.ST_TransScale(*args, **kwargs)

Translate a geometry by given factors and offsets.

see http://postgis.net/docs/ST_TransScale.html

Return type: geoalchemy2.types.Geometry.

type

alias of geoalchemy2.types.Geometry

class geoalchemy2.functions.ST_Transform(*args, **kwargs)

Return a new geometry with its coordinates transformed to the SRID referenced by the integer parameter.

see http://postgis.net/docs/ST_Transform.html

Return type: geoalchemy2.types.Geometry.

type

alias of geoalchemy2.types.Geometry

class geoalchemy2.functions.ST_Translate(*args, **kwargs)

Translate a geometry by given offsets.

see http://postgis.net/docs/ST_Translate.html

Return type: geoalchemy2.types.Geometry.

type

alias of geoalchemy2.types.Geometry

class geoalchemy2.functions.ST_Union(*args, **kwargs)

Returns a geometry that represents the point set union of the Geometries.

see http://postgis.net/docs/ST_Union.html

Return type: geoalchemy2.types.Geometry.

type

alias of geoalchemy2.types.Geometry

class geoalchemy2.functions.ST_Value(*args, **kwargs)

Returns the value of a given band in a given columnx, rowy pixel or at a particular geometric point. Band numbers start at 1 and assumed to be 1 if not specified. If exclude_nodata_value is set to false, then all pixels include nodata pixels are considered to intersect and return value. If exclude_nodata_value is not passed in then reads it from metadata of raster.

see http://postgis.net/docs/RT_ST_Value.html

class geoalchemy2.functions.ST_WKBToSQL(*args, **kwargs)

Return a specified ST_Geometry value from Well-Known Binary representation (WKB). This is an alias name for ST_GeomFromWKB that takes no srid

see http://postgis.net/docs/ST_WKBToSQL.html

Return type: geoalchemy2.types.Geometry.

type

alias of geoalchemy2.types.Geometry

class geoalchemy2.functions.ST_WKTToSQL(*args, **kwargs)

Return a specified ST_Geometry value from Well-Known Text representation (WKT). This is an alias name for ST_GeomFromText

see http://postgis.net/docs/ST_WKTToSQL.html

Return type: geoalchemy2.types.Geometry.

type

alias of geoalchemy2.types.Geometry

class geoalchemy2.functions.ST_Width(*args, **kwargs)

Returns the width of the raster in pixels.

see http://postgis.net/docs/RT_ST_Width.html

class geoalchemy2.functions.ST_Within(*args, **kwargs)

Returns True if the geometry A is completely inside geometry B

see http://postgis.net/docs/ST_Within.html

class geoalchemy2.functions.ST_X(*args, **kwargs)

Return the X coordinate of the point, or None if not available. Input must be a point.

see http://postgis.net/docs/ST_X.html

class geoalchemy2.functions.ST_Y(*args, **kwargs)

Return the Y coordinate of the point, or None if not available. Input must be a point.

see http://postgis.net/docs/ST_Y.html

class geoalchemy2.functions.ST_Z(*args, **kwargs)

Return the Z coordinate of the point, or None if not available. Input must be a point.

see http://postgis.net/docs/ST_Z.html

class geoalchemy2.functions.TableRowElement(selectable)[source]