--- id: geoalchemy2 version: "0.20.0" license: MIT license_treatment: permissive maintenance: active --- # GeoAlchemy2 — Using SQLAlchemy with Spatial Databases License: permissive · Maintenance: active · Downloads: 5.2M/mo ## What it is and what it does GeoAlchemy2 is a Python toolkit that bridges SQLAlchemy and spatial databases, allowing you to work with geographic data types and spatial queries through an ORM interface. It builds on SQLAlchemy's declarative system to map geographic columns and operations to database-native spatial types, letting you query and manipulate geographic data using Python objects rather than raw SQL. The package is designed for applications that need to store, retrieve, and analyze geographic information—such as location-based services, mapping applications, or GIS analysis workflows. It handles the translation between Python spatial objects and the spatial data types supported by your underlying database, abstracting away database-specific SQL syntax for common geographic operations. Use it for: - Build location-based web services that query geographic points, polygons, or routes stored in a spatial database - Develop GIS analysis tools that need to perform spatial operations like distance calculations or intersection tests through an ORM - Create mapping applications that store and retrieve geographic features alongside relational data - Implement geofencing or proximity-based filtering in applications backed by a spatial database ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. GeoAlchemy2 extends SQLAlchemy to work with spatial databases, providing an ORM layer for geographic data types and operations. Yes. GeoAlchemy2 is actively maintained, has low install friction, carries a permissive MIT license, and fills a clear need for ORM-based spatial database access. It is well-established and supports current Python versions. Install it if you need to work with geographic data in a SQLAlchemy-based application. ## Install pip install geoalchemy2 uv add geoalchemy2 poetry add geoalchemy2 ## Installing GeoAlchemy2 Before you install: Low friction installation with only two runtime dependencies (SQLAlchemy and packaging). Active maintenance with recent releases and a stable repository. License in practice: MIT license permits commercial and private use with minimal restrictions. Quickstart: pip install geoalchemy2 from geoalchemy2 import Geometry from sqlalchemy import Column, Integer, create_engine from sqlalchemy.orm import declarative_base Base = declarative_base() class Location(Base): __tablename__ = 'locations' id = Column(Integer, primary_key=True) geom = Column(Geometry('POINT')) Requires a spatial database backend (such as PostGIS) to be installed and configured separately; Python 3.10 or later. Verify before relying: - Which spatial database backends are supported (PostGIS, SpatiaLite, etc.) - Whether a spatial database system must be installed separately - Performance characteristics for large geographic datasets ## Package facts - License: MIT (permissive) - Python support: supports_current - Install friction: low - Maintenance: active - Downloads: 5.2M/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags sqlalchemy spatial database, gis orm python, geographic data sqlalchemy, spatial queries orm, geospatial database mapping, spatial orm, gis, spatial-data, orm [View on SkillFed](https://skillfed.io/packages/geoalchemy2) · [View on PyPI](https://pypi.org/project/geoalchemy2/)