Spatial Awareness - Spatial Data Platform Backend Spatial Awareness is a geospatial data platform built using FastAPI and PostGIS, designed to handle point and polygon spatial data. It provides powerful REST APIs to perform spatial operations such as containment and proximity queries.
π Features CRUD APIs for:
Multiple Points (e.g., farm plots, sensors, dealers)
Multiple Polygons (e.g., geofences, zones)
Spatial queries:
β Get all points within a polygon
β Get all polygons containing a point
β Get all points within a radius (proximity search)
Swagger documentation for easy testing
Dockerized setup with persistent PostGIS database
π Real-World Scenarios Demonstrated π‘οΈ HAL Zone Defense Check Polygon: HAL Zone (Defense area)
Points: 3 farm plots
Objective: Check whether any farm encroaches on the restricted zone using ST_Contains
πͺ Jayanagar 4th Block Market Optimization Polygon: Market zone
Points: 4 vegetable bulk dealers
Objective: Help vendors choose the nearest dealer using ST_DWithin and visualize dealer locations inside the market boundary
π§ Tech Stack Python 3.10
FastAPI
PostgreSQL + PostGIS
SQLAlchemy + GeoAlchemy2
Docker & Docker Compose
π§ͺ API Endpoints π Points POST /points/ β Create point
GET /points/ β List all points
GET /points/{id} β Get point by ID
PUT /points/{id} β Update point
DELETE /points/wipe β Delete all (dev-only)
GET /points/within-polygon/{polygon_id} β Points inside polygon
GET /points/nearby?lat=...&lng=...&radius=... β Points within radius
π¦ Polygons POST /polygons/ β Create polygon
GET /polygons/ β List all polygons
GET /polygons/{id} β Get polygon by ID
PUT /polygons/{id} β Update polygon
DELETE /polygons/wipe β Delete all (dev-only)
GET /polygons/contains-point/{point_id} β Polygons containing point
π οΈ Setup (Docker) Clone this repository
Run:
docker-compose up --build
Create tables (run inside container):
docker exec -it spatial_awareness_web_1 bash python
from app.db import Base, engine import app.models.point, app.models.polygon Base.metadata.create_all(bind=engine) exit()
Visit Swagger: http://localhost:8000/docs
π½οΈ Demo A product video demo has been recorded to walk through the features and real-world use cases clearly. You are encouraged to watch the demo to get full context.