pyshp
Pure Python read/write support for ESRI Shapefile format
What it is and what it does
PyShp is a pure-Python library for reading and writing ESRI Shapefiles, the de facto standard vector data format in GIS. It handles the three-file shapefile format (shp, shx, dbf) without requiring compiled geospatial libraries, making it lightweight and portable. The library provides Reader and Writer classes for loading geometry and attribute data from disk, zip files, URLs, or file-like objects, and for creating new shapefiles from scratch.
The package supports the full range of shapefile geometry types including points, lines, polygons, and 3D variants with elevation (Z) and measurement (M) values. It handles encoding and decoding of text fields, spatial and attribute filtering for large files, and merging or editing existing shapefiles. Recent versions have improved Unicode support and encoding robustness, with a strict mode for catching data truncation or encoding issues before they corrupt output files.
Use it for:
- Load census or administrative boundary shapefiles to extract geometry and demographic attributes for mapping or analysis.
- Convert tabular geographic data into shapefiles for distribution to GIS software.
- Filter or merge multiple shapefiles by spatial extent or attribute values without a full GIS application.
- Read shapefile metadata (bounds, geometry type, field definitions) to validate or inspect data before processing.
- Programmatically edit existing shapefiles to update coordinates, add records, or correct encoding issues.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
PyShp reads and writes ESRI Shapefiles in pure Python, supporting geometry and attribute data in the standard GIS vector format without external dependencies.
Yes. PyShp is a mature, actively maintained library with no dependencies, permissive licensing, and no known vulnerabilities. It is the standard choice for shapefile I/O in pure Python when you do not need full geospatial frameworks. Install it if you work with shapefiles in data pipelines, GIS automation, or geospatial analysis.
Install
pyshp on PyPI
pip
pip install pyshpuv
uv add pyshppoetry
poetry add pyshpInstalling pyshp
Before you install
Installation is straightforward with no runtime dependencies and a pure-Python wheel distribution. The package is actively maintained with a recent release (20 days old) and has been stable since its initial 2011 release.
License in practice
MIT license permits unrestricted use, modification, and distribution in both open-source and commercial projects with minimal legal friction.
Quickstart
import pyshp
# Read a shapefile
reader = pyshp.Reader('example.shp')
for shape in reader.shapes():
print(shape.points)
# Write a shapefile
writer = pyshp.Writer('output.shp')
writer.field('name', 'C')
writer.point(0, 0)
writer.record('test')
writer.close()
Requires Python 3.9 or later.
Verify before relying
- Whether the package handles very large shapefiles efficiently in memory or requires streaming approaches.
- Performance characteristics when reading or writing shapefiles with thousands of records or complex geometries.
- Specific memory footprint or scalability limits for production use.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 20 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 8,371,394/month — #1,630 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: pyshp-3.1.6-py3-none-any.whl
Keywords: geographic, geospatial, gis, shapefile, shapefiles
Tags
More Libraries packages
urllib3 is an HTTP client library that provides…
permissive · top 100 on PyPI
requestsRequests is a Python HTTP library that…
permissive · top 100 on PyPI
pluggyPluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
python-dateutilProvides parsing, arithmetic, and recurrence…
permissive · top 100 on PyPI
sixSix provides utility functions to write Python…
permissive · top 100 on PyPI
pytestpytest is a testing framework that lets you…
permissive · top 100 on PyPI
pyogrioPyogrio provides fast, bulk-oriented read and…
permissive · top 5,000 on PyPI
arcgisAccess Esri's ArcGIS services and geospatial…
unclear · top 15,000 on PyPI
fionaFiona reads and writes vector GIS data…
permissive · top 5,000 on PyPI
pygeoifPyGeoIf provides lightweight, pure-Python…
copyleft · top 15,000 on PyPI
plyfileplyfile reads and writes ASCII and binary PLY…
copyleft · top 5,000 on PyPI
arcgis2geojsonConverts ArcGIS JSON format to GeoJSON format,…
permissive · top 15,000 on PyPI
geojsonEncodes, decodes, and represents GeoJSON…
permissive · top 5,000 on PyPI
lasioRead and write Log ASCII Standard (LAS) files…
permissive · top 15,000 on PyPI
dbfReads and writes dBase III, FoxPro, Visual…
permissive · top 15,000 on PyPI
dbfreadReads DBF database files (dBase, Visual FoxPro,…
permissive · top 5,000 on PyPI