Personal R&D

Slope

Draw a line on a map and get a live elevation profile computed straight from a PostGIS raster.

Architecture

  1. Draw a line
    rlayers map
  2. API route
    Next.js · node-postgres
  3. PostGIS
    sample raster at native resolution
  4. Profile
    Plotly chart

A prototype exploring how far PostGIS can go for interactive analysis without a heavyweight backend: a Next.js map with rlayers, a single API route with raw SQL, and a Plotly chart that updates as you draw.

At a glance

  • Reads the raster's native pixel resolution and samples the drawn line at that resolution
  • Interpolates elevation values from the raster in SQL; no Python, no GDAL service
  • Parameterised queries, whitelisted table names and a bearer token on the API route
  • Next.js, React, rlayers (OpenLayers), Plotly and node-postgres

Why

Elevation profiles are a classic GIS task usually solved with a desktop tool or a processing service. I wanted to see whether the database alone could serve them interactively. It can: PostGIS raster functions handle sampling and interpolation fast enough that the profile feels live while the user is still drawing.

More projects

All projects