Skip to content
VarunGore36Public

About

AI-powered geospatial intelligence API that converts satellite imagery and geographic datasets into structured, actionable intelligence.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

48 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🌍 GeoMind

AI-powered geospatial intelligence platform.

License: MIT Python 3.11+ FastAPI PostGIS Tests Docker


GeoMind transforms open geospatial data β€” satellite imagery, OpenStreetMap, elevation models, and live camera feeds β€” into structured, queryable, actionable intelligence through developer-friendly APIs.

🎯 Vision

Make geographic intelligence accessible through simple APIs and scalable infrastructure β€” no GIS expertise required.


πŸ›°οΈ Core Modules

1. Location Intelligence API (/api/v1/location-intelligence)

Extract real-world metrics around any coordinate:

Metric Description Unit
Building Density Footprint area Γ· analysis area ratio (0–1)
Road Density Total road length Γ· area km/kmΒ²
Vegetation Coverage Vegetated land Γ· area ratio (0–1)
Water Proximity Distance to nearest water + coverage meters + ratio
Elevation Center + ring samples (min/max/mean) meters

Data sources: OpenStreetMap (via Overpass API), SRTM elevation (OpenTopoData/Open-Elevation)
Provenance: Every response includes source metadata, cache status, timestamps, and licenses (ODbL, public domain).

curl "http://localhost:8000/api/v1/location-intelligence?lat=52.52&lon=13.405&radius_m=500"

2. Camera Pipeline (/api/v1/cameras)

Ingest live MJPEG/JPEG feeds, deduplicate, and serve latest frames.

Feature Details
Multi-feed Configure N cameras with individual intervals
Deduplication Perceptual hash (pHash) β€” skips visually identical frames
Scheduling APScheduler with per-feed intervals + exponential backoff retries
Storage Files organized by camera_id/YYYYMMDD_HHMMSS_NNNNNN.jpg
Persistence Async SQLAlchemy (PostgreSQL/SQLite) for frame metadata
API Health, list, latest frame (JSON + JPEG), manual trigger

Config (cameras.yaml):

feeds:
  - feed_url: "https://images.webcams.travel/api/cam/1471069946/image.jpg"
    camera_id: "nyc_times_square"
    fetch_interval_seconds: 30
    timeout_seconds: 10
    max_retries: 3

πŸš€ Quick Start

Docker (Recommended)

git clone https://github.com/VarunGore36/GeoMind
cd GeoMind

# Start PostGIS + Redis + API
docker-compose up -d

# API at http://localhost:8000
# Docs at http://localhost:8000/docs

Local Development

# Install with camera extras
pip install -e ".[camera]"

# Copy config template
cp cameras.yaml.example cameras.yaml
# Edit cameras.yaml with your feeds

# Run
GEOMIND_CAM_CONFIG_PATH=cameras.yaml python -m src.geomind.main

πŸ“‘ API Reference

Location Intelligence

Method Endpoint Description
GET /api/v1/location-intelligence Extract features around a point
Query params lat, lon, radius_m (optional), refresh (optional) WGS84 coords, radius in meters

Camera Pipeline

Method Endpoint Description
GET /api/v1/cameras/health All cameras status + frame counts
GET /api/v1/cameras List configured cameras
GET /api/v1/cameras/{id} Single camera status
GET /api/v1/cameras/{id}/latest Latest frame metadata
GET /api/v1/cameras/{id}/latest/image Latest frame as JPEG
POST /api/v1/cameras/{id}/fetch Trigger immediate fetch

Health & Meta

Method Endpoint Description
GET /health Liveness probe
GET /health/ready Readiness (DB + PostGIS)
GET / Service metadata

πŸ“Š Example Response

Location Intelligence:

{
  "query": { "latitude": 52.52, "longitude": 13.405, "radius_m": 500, "area_m2": 785398 },
  "features": {
    "building_density": { "value": 0.21, "building_count": 244, "footprint_area_m2": 164983 },
    "road_density": { "value": 57.3, "unit": "km/km2", "road_length_m": 44970 },
    "vegetation_coverage": { "value": 0.26, "vegetation_area_m2": 208049 },
    "water_proximity": { "nearest_distance_m": 125, "water_coverage_ratio": 0.056 },
    "elevation": { "value": 49, "min_m": 33, "max_m": 58, "mean_m": 44.2, "samples": 5 }
  },
  "provenance": {
    "sources": [
      { "name": "OpenStreetMap", "license": "ODbL-1.0" },
      { "name": "Elevation", "dataset": "srtm30m", "license": "Public domain" }
    ],
    "cache": { "hit": false, "ttl_s": 86400 }
  }
}

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                         GeoMind API                              β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  Location Intelligence       β”‚  Camera Pipeline                 β”‚
β”‚  ─────────────────────────   β”‚  ────────────────────            β”‚
β”‚  Overpass API (OSM)    ────▢ β”‚  Camera Feeds (MJPEG/JPEG)       β”‚
β”‚  OpenTopoData (SRTM)  ────▢  β”‚  ────────────────────            β”‚
β”‚  ─────────────────────────   β”‚  APScheduler ◀──── Intervals      β”‚
β”‚  PostGIS (metrics)           β”‚  ────────────────────            β”‚
β”‚  ─────────────────────────   β”‚  Fetcher (HTTP + Retry)           β”‚
β”‚  FastAPI /v1/location-intel  β”‚  ────────────────────            β”‚
β”‚                              β”‚  pHash Dedup                      β”‚
β”‚                              β”‚  ────────────────────            β”‚
β”‚                              β”‚  Files + Postgres                 β”‚
β”‚                              β”‚  ────────────────────            β”‚
β”‚                              β”‚  FastAPI /v1/cameras              β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
  • Async throughout β€” FastAPI + asyncpg + SQLAlchemy 2.0
  • PostGIS β€” spatial indexes, UTM projection for accurate metrics
  • Caching β€” 24h TTL for OSM coverage areas
  • Deduplication β€” 64-bit perceptual hash, β‰₯95% similarity skips save

βš™οΈ Configuration

All settings via environment variables (GEOMIND_ prefix) or YAML:

File Purpose
.env Runtime overrides (DB URL, API keys, log level)
cameras.yaml Camera feeds, storage, database, Redis
pyproject.toml Dependencies, tool config (ruff, mypy, pytest)

Key env vars:

GEOMIND_DATABASE_URL=postgresql+asyncpg://user:pass@host/db
GEOMIND_CAM_REDIS__URL=redis://localhost:6379/0
GEOMIND_LOG_LEVEL=INFO

πŸ§ͺ Testing

# All tests (54 passing)
make test

# Camera tests only
make test-cam

# With coverage
pytest --cov=src --cov-report=html

Test breakdown:

  • 36 unit/integration tests for Location Intelligence
  • 18 camera pipeline tests (config, storage, fetcher, DB, API, scheduler)

🐳 Docker

# docker-compose.yml services:
#   db      - postgis/postgis:16-3.4 (PostGIS 3.4)
#   redis   - redis:7-alpine (for camera caching)
#   api     - geomind:latest (FastAPI + Uvicorn)
docker-compose up -d          # Start
docker-compose logs -f api    # View logs
docker-compose down           # Stop

πŸ“ Project Structure

GeoMind/
β”œβ”€β”€ src/geomind/
β”‚   β”œβ”€β”€ cameras/              # Camera pipeline module
β”‚   β”‚   β”œβ”€β”€ config.py         # Pydantic config models
β”‚   β”‚   β”œβ”€β”€ models.py         # SQLAlchemy + Pydantic models
β”‚   β”‚   β”œβ”€β”€ storage.py        # File storage + pHash dedup
β”‚   β”‚   β”œβ”€β”€ fetcher.py        # HTTP fetcher with retries
β”‚   β”‚   β”œβ”€β”€ database.py       # Async SQLAlchemy CRUD
β”‚   β”‚   β”œβ”€β”€ scheduler.py      # APScheduler orchestration
β”‚   β”‚   β”œβ”€β”€ api.py            # FastAPI routes
β”‚   β”‚   └── README.md         # Module docs
β”‚   β”œβ”€β”€ core/                 # Config, errors, logging
β”‚   β”œβ”€β”€ db/                   # Base, session, models
β”‚   β”œβ”€β”€ providers/            # Overpass, Elevation
β”‚   β”œβ”€β”€ repositories/         # PostGIS metric queries
β”‚   β”œβ”€β”€ services/             # Ingestion, metrics, orchestration
β”‚   β”œβ”€β”€ api/                  # Health, Location Intelligence routes
β”‚   └── main.py               # FastAPI app factory
β”œβ”€β”€ tests/                    # 54 tests (unit + integration)
β”œβ”€β”€ alembic/                  # DB migrations
β”œβ”€β”€ scripts/                  # cam_health_check.py
β”œβ”€β”€ static/                   # Web viewer (index.html)
β”œβ”€β”€ cameras.yaml              # Camera config (gitignored)
β”œβ”€β”€ cameras.yaml.example      # Template
β”œβ”€β”€ docker-compose.yml
β”œβ”€β”€ Dockerfile
β”œβ”€β”€ Makefile
β”œβ”€β”€ pyproject.toml
β”œβ”€β”€ requirements.txt
β”œβ”€β”€ CHANGELOG.md
└── LICENSE (MIT)

🀝 Contributing

# Format & lint
make format
make lint

# Run tests
make test

# Submit PR

Code style: ruff (line-length 100), type hints required (mypy strict).


πŸ“„ License

MIT License β€” see LICENSE.


πŸ™‹β€β™‚οΈ Author

Varun Gore β€” @VarunGore36


Built with FastAPI, PostGIS, and open geospatial data.

About

AI-powered geospatial intelligence API that converts satellite imagery and geographic datasets into structured, actionable intelligence.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages