Author: João Paulo Cardoso do Carmo Date: 2025-09-24
This project provides a REST API and a command-line interface (CLI) to query elevations from geographic coordinates using 30-meter SRTM (Shuttle Radar Topography Mission) data.
- REST API to get elevations for points (JSON with
"geometry": []). - CLI support for local processing of coordinate files.
- Flexible usage: run as CLI or enable API with a flag.
- Python 3.10+
- FastAPI
- Uvicorn
- Other dependencies as required (
rasterio,geopandas, etc.)
Install basic dependencies:
pip install requeriments.txtActivate the --api flag to start the FastAPI server:
python main.py --apiThe server will be available at:
https://srtmapi.onrender.com
POST /pyagro_elevations
Expected JSON payload:
{
"geometry": [
[-47.9292, -15.7801],
[-46.6333, -23.5505]
]
}Example response:
{
"elevations": [1160, 760]
}import requests
url = "https://srtmapi.onrender.com/pyagro_elevations"
payload = {
"geometry": [
[-47.9292, -15.7801],
[-46.6333, -23.5505]
]
}
response = requests.post(url, json=payload)
print(response.json())Without the --api flag, the script works as a CLI:
python main.py --coords_path path/to/coordinates.geojson --output_path path/to/output--coords_pathor-cp: path to a file containing coordinates in the same"geometry": []format.--output_pathor-op: path to save the output.
- Only accepts JSON with
"geometry": []. NoFeatureCollectionin API. - Works for both single and multiple points.
- Coordinates just in EPSG:4326.
- API just to Brazil.
AGRI IS TECH, AGRI IS TOP, AGRI IS PYAGRO
Instagram @pYAgro_