skillfed

pyshp

Pure Python read/write support for ESRI Shapefile format

pyshp v3.1.6 8.4M downloads/30d#1,630 on PyPI1,154
Permissive license MIT Active released

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 pyshp

uv

uv add pyshp

poetry

poetry add pyshp

Installing 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

Development Status :: 5 - Production/StableProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3 :: OnlyTopic :: Scientific/Engineering :: GISTopic :: Software Development :: LibrariesTopic :: Software Development :: Libraries :: Python Modules

Tags

shapefile read write pythonesri shapefile librarygis vector data formatgeospatial data pythonshapefile parsergeographic information systemdbf shp shx files
gisgeospatialshapefile

More Libraries packages