GeoAlchemy 2 Documentation¶
Using SQLAlchemy with Spatial Databases.
GeoAlchemy 2 provides extensions to SQLAlchemy for working with spatial databases.
GeoAlchemy 2 focuses on PostGIS. PostGIS 1.5, PostGIS 2 and PostGIS 3 are supported.
SpatiaLite is also supported, but using GeoAlchemy 2 with SpatiaLite requires some specific configuration on the application side. GeoAlchemy 2 works with SpatiaLite 4.3.0 and higher (except for alembic helpers that need SpatiaLite >= 5).
GeoAlchemy 2 aims to be simpler than its predecessor, GeoAlchemy. Simpler to use, and simpler to maintain.
The current version of this documentation applies to the version 0.12.6.dev5+g6e26f1a of GeoAlchemy 2.
GeoAlchemy 2 requires SQLAlchemy >= 1.4.
What’s New in GeoAlchemy 2¶
GeoAlchemy 2 supports PostGIS’
geometrytype, as well as the
The first series had its own namespace for spatial functions. With GeoAlchemy 2, spatial functions are called like any other SQLAlchemy function, using
func, which is SQLAlchemy’s standard way of calling SQL functions.
GeoAlchemy 2 works with SQLAlchemy’s ORM, as well as with SQLAlchemy’s SQL Expression Language (a.k.a the SQLAlchemy Core). (This is thanks to SQLAlchemy’s new type-level comparator system.)
GeoAlchemy 2 supports reflection of geometry and geography columns.
GeoAlchemy 2 adds
from_shapefunctions for a better integration with Shapely.
See the Migrate to GeoAlchemy 2 page for details on how to migrate a GeoAlchemy application to GeoAlchemy 2.
GeoAlchemy 2 works with both SQLAlchemy’s Object Relational Mapping (ORM) and SQL Expression Language. This documentation provides a tutorial for each system. If you’re new to GeoAlchemy 2 start with this.
The Gallery page shows examples of the GeoAlchemy 2’s functionalities.
Use with Alembic¶
The code is available on GitHub: https://github.com/geoalchemy/geoalchemy2.
Adrien Berchet (https://github.com/adrien-berchet)
Éric Lemoine (https://github.com/elemoine)
Dolf Andringa (https://github.com/dolfandringa)
Frédéric Junod, Camptocamp SA (https://github.com/fredj)
Loïc Gasser (https://github.com/loicgasser)
Marcel Radischat (https://github.com/quiqua)
Serge Bouchut (https://github.com/SergeBouchut)
Tobias Bieniek (https://github.com/Turbo87)
Tom Payne (https://github.com/twpayne)
Many thanks to Mike Bayer for his guidance and support! He also fostered the birth of GeoAlchemy 2.