Skip to main content

🗺️ GeoJSON Image Organizer

PyPI version Python License: MIT Tests

A Python package that automatically attaches images to GeoJSON features based on name matching. It uses fuzzy string matching to intelligently link spatial features with corresponding image files — even when names are slightly different, misspelled, or formatted inconsistently.


✨ Features

  • Reads GeoJSON files and matches features to images automatically
  • Uses fuzzy matching (rapidfuzz) for intelligent name linking
  • Normalizes names — handles spaces, hyphens, underscores, and case differences
  • Returns null honestly when no image matches — no silent fallbacks
  • Exports a CSV report of unmatched features
  • Configurable match sensitivity with --cutoff
  • Full CLI support — use it directly from terminal
  • Supports jpg, jpeg, png, webp, gif image formats

🧠 How It Works

GeoJSON features          Image folder
─────────────────         ─────────────
"Kathmandu"    ──fuzzy──▶  kathmandu.jpg   ✅ matched
"Patan Durbar" ──fuzzy──▶  patan-durbar.jpg ✅ matched
"XYZ Place"    ──no match─▶ null            ⚠️ reported
  1. Load GeoJSON file
  2. Read all images from folder
  3. Normalize names (lowercase, remove spaces/symbols)
  4. Match feature names to image filenames using fuzzy matching
  5. Attach best-matching image path to each feature
  6. Save updated GeoJSON + optional CSV report of unmatched features

📁 Project Structure

project/
│
├── geojsonfileandimageattacher/
│   ├── __init__.py
│   ├── core.py           # Main logic
│   └── cli.py            # CLI interface
│
├── tests/
│   └── test_core.py      # Full test suite
│
├── demo/
│   ├── input.geojson     # Sample input
│   ├── images/           # Sample images
│   └── output.geojson    # Generated output
│
├── setup.py
├── pyproject.toml
└── README.md

⚙️ Requirements

  • Python 3.6+
  • rapidfuzz

📦 Installation

pip install geojsonfile_image_attacher

Or for local development:

git clone https://github.com/subekshya-s/geojson_image_attacher.git
cd geojson_image_attacher
pip install -e .

▶️ Usage

# Basic usage
geojson-attach --input map.geojson --images ./photos --output result.geojson

# Stricter matching (default is 75)
geojson-attach --input map.geojson --images ./photos --output result.geojson --cutoff 85

# With CSV report of unmatched features
geojson-attach --input map.geojson --images ./photos --output result.geojson --report

# Help
geojson-attach --help

Python API

from geojsonfileandimageattacher import GeoImageOrganizer

organizer = GeoImageOrganizer(
    input_geojson="input.geojson",
    image_folder="images/",
    output_geojson="output.geojson",
    cutoff=75           # match sensitivity 0-100
)

organizer.run()

📊 Output Example

Input feature:

{
  "type": "Feature",
  "properties": {
    "name": "Kathmandu"
  }
}

Output feature:

{
  "type": "Feature",
  "properties": {
    "name": "Kathmandu",
    "image": "images/kathmandu.jpg",
    "image_match_score": 100.0
  }
}

Unmatched feature:

{
  "type": "Feature",
  "properties": {
    "name": "Unknown Place",
    "image": null,
    "image_match_score": 0
  }
}

📄 CSV Report (--report flag)

When --report is used, a CSV file is generated next to your output:

feature_name,status
Bhaktapur,no image found
Unknown Place XYZ,no image found

🖼️ Screenshots

Add screenshots here after running on demo data

Example:

🗺️  GeoJSON Image Organizer
   Input:   demo/input.geojson
   Images:  demo/images
   Output:  demo/output.geojson
   Cutoff:  75

📊 Results: 5/8 features matched

⚠️  No image found for:
   - Bhaktapur
   - Unknown Place XYZ
   - [unnamed feature]

💾 Output saved to demo/output.geojson
📄 Report saved to demo/output_unmatched.csv

🧪 Running Tests

pip install pytest
python -m pytest tests/ -v

Expected output:

test_normalize                         PASSED ✅
test_get_image_mapping                 PASSED ✅
test_attach_images_with_match          PASSED ✅
test_attach_images_no_match            PASSED ✅
test_save_output                       PASSED ✅
test_missing_geojson_raises_error      PASSED ✅
test_missing_image_folder_raises_error PASSED ✅
test_invalid_json_raises_error         PASSED ✅

🔧 CLI Options

Option Required Default Description
--input ✅ — Path to input GeoJSON file
--images ✅ — Path to image folder
--output ✅ — Path to output GeoJSON file
--cutoff ❌ 75 Match sensitivity 0-100
--report ❌ False Export unmatched CSV report

📝 License

MIT License — see LICENSE for details.


👩‍💻 Author

Subekshya Subedi


🤝 Contributing

Pull requests are welcome! For major changes, please open an issue first.

git clone https://github.com/subekshya-s/geojson_image_attacher.git
pip install -e .
python -m pytest tests/ -v

Metadata

Release files for geojsonfile-image-attacher 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for geojsonfile-image-attacher 0.2.0
File Size Uploaded Provenance Actions
geojsonfile_image_attacher-0.2.0.tar.gz 8.0 kB Without provenance Details for geojsonfile_image_attacher-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for geojsonfile-image-attacher 0.2.0
File Interpreter ABI Platform Actions
geojsonfile_image_attacher-0.2.0-py3-none-any.whl Python 3 none any Details for geojsonfile_image_attacher-0.2.0-py3-none-any.whl

Total release size: 16.0 kB

Release files / geojsonfile_image_attacher-0.2.0.tar.gz

Download URL geojsonfile_image_attacher-0.2.0.tar.gz
Size 8.0 kB
Tags Source
SHA-256 checksum
How to use checksums
8d2d36d1508f52816b97b30c0edb2ca14021bd3642c34122742adfa9a0861a78
BLAKE2b-256 checksum
How to use checksums
598195ebb96e25b84d61beab62abb504c7139f8770c10856c194fd18714ec2e8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release files / geojsonfile_image_attacher-0.2.0-py3-none-any.whl

Download URL geojsonfile_image_attacher-0.2.0-py3-none-any.whl
Size 8.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
895cb6431c3b39246ce0b4a72452a38250ce269d3c6d4fc371230b1ec9eacf0b
BLAKE2b-256 checksum
How to use checksums
da86e870f7de98efa76d3f2b9e8561d962596d9bd39d251ab370a8d9d99148e4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Security for geojsonfile-image-attacher 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page