skillfed

plpygis

Python tools for PostGIS

plpygis v0.6.1 373.0K downloads/30d#7,157 on PyPI24
Copyleft license GPL-3.0-only AGING released

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 plpygis

uv

uv add plpygis

poetry

poetry add plpygis

Installing 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

Topic :: DatabaseTopic :: Scientific/Engineering :: GIS

Tags

postgis geometry conversionwkb wkt geojson pythonpl/python geometry handlingpostgis python integrationgeometry format conversionewkb ewkt parserpostgis pl/python tools
postgispl/pythongeometry-conversion

More Database packages