Skip to main content

An ETL for fetching/cleaning St. Louis crime data sets.

Project description

geocrime-stl

License: MIT Python 3.10+

A Python utility for cleaning and standardizing St. Louis Metropolitan Police Department (SLMPD) crime data for spatial analysis.

✨ Features

  • End-to-End ETL: Fetch, clean, and standardize monthly SLMPD crime data files automatically.
  • Spatial Formats: Convert cleaned DataFrames seamlessly into GeoJSON, GeoPackage (GPKG), or CSV.
  • Analysis Ready: Access built-in methods for minimal data summarization and visualization.

🌐 Data Source & Disclaimer

This utility programmatically fetches publicly available crime data directly from the St. Louis Metropolitan Police Department (SLMPD) Stats Page.

⚠️ Data Disclaimer & Limitations:

  • Availability: This tool relies entirely on the upstream availability and hosting structure of the SLMPD website. If their servers are down or their URL layout changes, the extraction pipeline may fail.
  • Data Integrity & Spatial Boundaries: The data processed is strictly "as-is" from the published monthly files. To ensure high data quality for spatial analysis, this utility applies two strict filtering constraints:
    1. Temporal Filtering: Because the SLMPD frequently updates historical records retroactively, this utility isolates and preserves only the records belonging to the target month.
    2. Spatial Clipping: Records containing invalid, malformed, or erroneous latitude/longitude coordinates that plot completely outside the official St. Louis city boundaries are automatically dropped.
  • Project Status: This is an independent, open-source utility. It is not affiliated with, endorsed by, or officially maintained by the SLMPD or the City of St. Louis.

🚀 Quick Start

Install

pip install geocrime-stl

Fetch/Clean/Visualize Data

import geocrime_stl as gc

data_pkg = gc.run_pipeline(4, 2026)

gc.generate_monthly_metrics(data_pkg)

gc.plot_monthly_maps(data_pkg)

🛠️ Local Setup (Alternative)

If you want to run the demo notebook locally or explore the source code, you can clone the repository directly:

git clone https://github.com/lweber89/geocrime-stl.git
cd geocrime-stl
pip install -e .

📓 Demo & Tutorial

To see a step-by-step walkthrough of the entire ETL process, check out the interactive Jupyter notebook included in this package:

👉 View the Demo Notebook

Note: If you have cloned the repository locally, you can open this file using Jupyter Lab or Jupyter Notebook to run the cells yourself.

🤝 Contributing & Pull Requests

Thank you for your interest in the project!

⚠️ Please Note: This is a personal project I developed and maintain in an effort to better understand the implementation of Python in geospatial data engineering / solutions architecture. I am not accepting pull requests or code contributions at this time.

If you find a bug or have an idea, feel free to open an Issue to let me know, or feel free to fork the repository and adapt it for your own personal needs!

📜 License

This project is licensed under the MIT License - see the LICENSE file for details.

🔗 Project Links

GitHub Repository: https://github.com/lweber89/geocrime-stl

PyPI Home: https://pypi.org/project/geocrime-stl/

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

geocrime_stl-0.1.0.tar.gz (9.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

geocrime_stl-0.1.0-py3-none-any.whl (9.3 kB view details)

Uploaded Python 3

File details

Details for the file geocrime_stl-0.1.0.tar.gz.

File metadata

  • Download URL: geocrime_stl-0.1.0.tar.gz
  • Upload date:
  • Size: 9.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for geocrime_stl-0.1.0.tar.gz
Algorithm Hash digest
SHA256 fb0552c5a829e80b17f5f6df92a081b2eb390509feb792bdece162e0e881650f
MD5 8fd7d9b3bdb5480bb9894e180969bf41
BLAKE2b-256 67e26d675a4cb1c6c65fe9ca6fd3001d57435e01d68da761f0fabcc1c99e1d51

See more details on using hashes here.

File details

Details for the file geocrime_stl-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: geocrime_stl-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for geocrime_stl-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1ac99fd488ca9c3078a1faa69a650085a4fb5921b5cbddd2b1bbf045dbf24f4a
MD5 d8b4d26e3c7deef7d4603b5815428c83
BLAKE2b-256 22a60ff02eac7d7de75cb5c81790ccb3be7c6ab123cf2f56a6354ef8a26beb77

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page