A Lightweight Python Library for Cleaning Geospatial Coordinates
GeoCleanr is a lightweight, educational Python library for validating, fixing, reporting, and visualizing latitude/longitude data in raw tabular datasets (e.g. CSV files). It is designed for students and researchers working with real-world, messy geospatial data before using full GIS tools.
GeoCleanr focuses specifically on coordinate-level data quality, a common problem not directly addressed by generic data libraries or heavy GIS frameworks.
- Validation: Detects missing, invalid, out-of-range, or swapped latitude/longitude values
- Automatic fixing: Clips coordinates to valid bounds, swaps axes when needed, and applies fallback values
- Reporting: Generates human-readable summaries of detected issues (Markdown/text)
- Visualization: Provides a simple ASCII heatmap for spatial overview
- CLI support: Run validation and reporting from the terminal on CSV or NDJSON data
- Testing: Includes automated tests for core functionality
- Load a CSV or tabular dataset
- Validate latitude/longitude fields
- Automatically fix common coordinate issues
- Generate a summary report
- Export cleaned data for further analysis (e.g. GIS, pandas)
Using pip
pip install -r requirements.txt
pip install -e .Using conda
conda env create -f environment.yml
conda activate geocleanr
pip install -e .To quickly verify that the project works:
pip install -r requirements.txt
pip install -e .
python -m pytestAll tests should pass.
For a functional demonstration, open:
examples/GeoCleanr_quickstart.md
or the example Jupyter notebook in the examples/ folder.
from geocleanr import GeometryValidator, CoordinateFixer
validator = GeometryValidator(lat_field="latitude", lon_field="longitude")
issues = validator.validate(rows)
fixer = CoordinateFixer(lat_field="latitude", lon_field="longitude")
cleaned = [fixer.fix_record(r).record for r in rows]GeoCleanr/
|-- src/ # Core library code
|-- tests/ # Automated tests
|-- examples/ # Example notebook and usage guide
|-- assets/ # Supporting assets
|-- environment.yml # Conda environment
|-- requirements.txt
|-- pyproject.toml
`-- README.md
GeoCleanr is intended for students, researchers, and analysts who need to clean and validate geospatial coordinates in raw CSV or tabular data before further analysis or GIS processing.
GeoCleanr focuses on coordinate-level validation and does not replace full GIS or CRS-aware validation tools such as GeoPandas or QGIS.
This project is released under the MIT License.
