plpygis
Python tools for PostGIS
What it is and what it does
plpygis is a pure-Python geometry format converter that bridges PostgreSQL's PL/Python environment and PostGIS. It translates between the binary and text representations that PostGIS uses (WKB, EWKB, WKT, EWKT) and GeoJSON, allowing PL/Python functions to receive PostGIS geometry objects as native Python objects and return them back to the database. The package implements geometry subclasses (Point, LineString, Polygon, MultiPolygon, etc.) that wrap these conversions transparently.
The primary use case is writing PL/Python stored procedures that accept or return PostGIS geometries. When a geometry is passed to a PL/Python function, plpygis converts it into a Python object with accessible properties (x, y, z coordinates, SRID); when the function returns a plpygis object, it is automatically converted back to a PostGIS geometry for storage. This eliminates the need to manually parse or construct binary geometry formats in Python code.
Use it for:
- Write PL/Python functions that accept PostGIS geometry arguments and manipulate them as Python objects before returning results to the database.
- Integrate external geospatial services (elevation APIs, geocoding, etc.) with PostGIS by converting geometries to/from Python-friendly formats.
- Convert PostGIS geometries to GeoJSON for serialization to web clients or APIs.
- Parse WKB or WKT geometry strings into Python objects for analysis or transformation outside the database.
- Build geometry objects programmatically in Python and insert them into PostGIS as EWKB or WKT.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Converts geometries between WKB/EWKB, WKT/EWKT, and GeoJSON formats with no external dependencies, designed for use in PostgreSQL PL/Python functions to work with PostGIS geometry objects.
Yes, if you are writing PL/Python functions for PostgreSQL with PostGIS. The package has no dependencies, is stable, and solves a specific problem well. No, if you do not use PostgreSQL PL/Python or do not work with PostGIS geometries—the GPL-3.0-only license also makes it unsuitable for proprietary projects unless your entire codebase is copyleft-compatible.
Install
plpygis on PyPI
pip
pip install plpygisuv
uv add plpygispoetry
poetry add plpygisInstalling plpygis
Before you install
Low friction: pure Python wheel with no runtime dependencies. Maintenance is aging—last release was 318 days ago, though the repository remains unarchived and the codebase is stable for its narrow use case.
License in practice
Licensed under GPL-3.0-only (copyleft). Any code that imports plpygis must be distributed under a compatible copyleft license; this is a hard constraint for proprietary or permissively-licensed projects.
Quickstart
from plpygis import Point
p = Point((-124.005, 49.005), srid=4326)
print(p.ewkb)
print(p.geojson)
p.z = 1
print(p.wkt)
Requires Python >= 3.9
Verify before relying
- Whether the package handles all PostGIS geometry types or only a subset
- Performance characteristics when converting large or complex geometries
- Compatibility with recent PostGIS versions
Package facts
| License | GPL-3.0-only (copyleft) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | aging — 318 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 373,010/month — #7,157 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: plpygis-0.6.1-py3-none-any.whl
Keywords: gis, geospatial, postgis, postgresql, pl/python
Tags
More Database packages
psycopg2-binary is a PostgreSQL database…
copyleft · top 1,000 on PyPI
redisPython client library for connecting to and…
permissive · top 1,000 on PyPI
ydbYDB Python SDK is the official client library…
permissive · top 1,000 on PyPI
snowflake-connector-pythonConnects Python applications to Snowflake data…
permissive · top 1,000 on PyPI
sqlparsesqlparse tokenizes SQL text into a tree of…
permissive · top 1,000 on PyPI
dbt-adaptersProvides base adapter protocols and shared…
permissive · top 1,000 on PyPI
geometConverts between GeoJSON, WKT/WKB, Extended…
permissive · top 5,000 on PyPI
geoarrow-pandasIntegrates GeoArrow geometry data with pandas…
permissive · top 15,000 on PyPI
geoarrow-typesProvides pure Python utilities to manage,…
permissive · top 15,000 on PyPI
antimeridianFixes Shapely geometries and GeoJSON features…
permissive · top 15,000 on PyPI
geojsonEncodes, decodes, and represents GeoJSON…
permissive · top 5,000 on PyPI
arcgis2geojsonConverts ArcGIS JSON format to GeoJSON format,…
permissive · top 15,000 on PyPI
pygeoifPyGeoIf provides lightweight, pure-Python…
copyleft · top 15,000 on PyPI
osm2geojsonConverts OpenStreetMap and Overpass API data…
permissive · top 15,000 on PyPI
fudgeofudgeo creates and manages OGC…
permissive · top 15,000 on PyPI
descartesConverts geometric objects and GeoJSON-like…
permissive · top 15,000 on PyPI