### Server Installation and Setup Source: https://context7.com/ajnisbet/opentopodata/llms.txt Instructions for cloning the repository, building the Docker image, and running the Open Topo Data server. ```APIDOC ## Installation and Server Setup Cloning the repository and building the Docker image is required to set up an Open Topo Data server. ```bash # Clone the repository git clone https://github.com/ajnisbet/opentopodata.git cd opentopodata # Build and run the server (Linux/macOS) make build make run # For Apple Silicon Macs (M1/M2) make build-m1 make run # For Windows (without make) docker build --tag opentopodata --file docker/Dockerfile . docker run --rm -it --volume C:/path/to/opentopodata/data:/app/data:ro -p 5000:5000 opentopodata sh -c "/usr/bin/supervisord -c /app/docker/supervisord.conf" # Test the installation curl http://localhost:5000/v1/test-dataset?locations=56,123 # Expected response: # { # "results": [{ # "elevation": 815.0, # "location": {"lat": 56.0, "lng": 123.0}, # "dataset": "test-dataset" # }], # "status": "OK" # } ``` ``` -------------------------------- ### Install Memcached and UWSGI Source: https://github.com/ajnisbet/opentopodata/blob/master/docs/notes/running-without-docker.md Installs memcached for caching and uwsgi for running the application in production. These are required for the full installation. ```bash apt install memcached pip3 install regex uwsgi ``` -------------------------------- ### Server Configuration Example (config.yaml) Source: https://context7.com/ajnisbet/opentopodata/llms.txt Example configuration file for Open Topo Data server. Defines request limits, CORS settings, and dataset configurations including paths, projection, and bounds. ```yaml max_locations_per_request: 100 access_control_allow_origin: "*" datasets: - name: etopo1 path: data/etopo1/ - name: srtm90m path: data/srtm-90m-v3/ filename_epsg: 4326 filename_tile_size: 1 - name: nzdem8m path: data/nzdem8m/ filename_tile_size: 65536 filename_epsg: 2193 wgs84_bounds: left: 165 right: 180 bottom: -48 top: -33 - name: nz-global child_datasets: - nzdem8m - mapzen ``` -------------------------------- ### Install System Dependencies Source: https://github.com/ajnisbet/opentopodata/blob/master/docs/notes/running-without-docker.md Installs necessary system packages including GCC, Python development headers, and pip. Ensure the Python version matches your system's installation. ```bash apt install gcc python3.7-dev python3-pip ``` -------------------------------- ### GET /v1/ (GeoJSON Example) Source: https://github.com/ajnisbet/opentopodata/blob/master/docs/api.md Example of retrieving elevation data in GeoJSON format for specified locations. ```APIDOC ## GET /v1/ ### Description Retrieves elevation data for specified locations in GeoJSON format. ### Method GET ### Endpoint /v1/ ### Query Parameters - **locations** (string) - Required - Comma-separated latitude,longitude pairs. - **interpolation** (string) - Optional - Type of interpolation to use (e.g., cubic). - **format** (string) - Optional - Desired output format (e.g., geojson). ### Response Example ```json { "features": [ { "geometry": { "coordinates": [ 172.5, -43.5, 45 ], "type": "Point" }, "properties": { "dataset": "srtm90m" }, "type": "Feature" }, { "geometry": { "coordinates": [ 1.98, 27.6, 402 ], "type": "Point" }, "properties": { "dataset": "srtm90m" }, "type": "Feature" } ], "type": "FeatureCollection" } ``` ``` -------------------------------- ### Manage Open Topo Data Service Source: https://github.com/ajnisbet/opentopodata/blob/master/docs/notes/running-without-docker.md Commands to reload the systemd daemon, enable the Open Topo Data service to start on boot, and start the service. ```bash systemctl daemon-reload systemctl enable opentopodata.service systemctl start opentopodata.service ``` -------------------------------- ### Install Remaining Python Packages Source: https://github.com/ajnisbet/opentopodata/blob/master/docs/notes/running-without-docker.md Installs all other Python dependencies listed in the requirements.txt file. ```bash pip3 install -r requirements.txt ``` -------------------------------- ### Test UWSGI Configuration Source: https://github.com/ajnisbet/opentopodata/blob/master/docs/notes/running-without-docker.md Runs the uWSGI server with the specified configuration file to test its setup before creating a systemd service. ```bash /usr/local/bin/uwsgi --ini /home/opentopodata/uwsgi.ini --processes 10s ``` -------------------------------- ### Build and Run Server (Linux/macOS) Source: https://context7.com/ajnisbet/opentopodata/llms.txt Clone the repository, build the Docker image, and run the Open Topo Data server using make commands. Ensure Docker is installed. ```bash git clone https://github.com/ajnisbet/opentopodata.git cd opentopodata make build make run ``` -------------------------------- ### Open Topo Data Configuration Example Source: https://github.com/ajnisbet/opentopodata/blob/master/docs/server.md A sample `config.yaml` file showing how to configure datasets, including paths and filename conventions. Modifying this file triggers a server restart. ```yaml max_locations_per_request: 100 access_control_allow_origin: '*' datasets: - name: etopo1 path: data/etopo1/ - name: srtm90m path: data/srtm-90m-v3/ filename_epsg: 4326 filename_tile_size: 1 ``` -------------------------------- ### Public API Response Example Source: https://github.com/ajnisbet/opentopodata/blob/master/docs/datasets/nzdem.md Example JSON response from the Open Topo Data public API for an elevation query. ```json { "results": [ { "elevation": 705.4374389648438, "location": { "lat": -37.86118, "lng": 174.79974 }, "dataset": "nzdem8m" } ], "status": "OK" } ``` -------------------------------- ### Public API Response Example Source: https://github.com/ajnisbet/opentopodata/blob/master/docs/datasets/emod2018.md Example JSON response from querying the EMODnet dataset via the public API. ```json { "results": [ { "elevation": -81.94999694824219, "location": { "lat": 55.884323, "lng": 2.528276 }, "dataset": "emod2018" } ], "status": "OK" } ``` -------------------------------- ### Example config.yaml for MultiDataset Source: https://github.com/ajnisbet/opentopodata/blob/master/docs/notes/multiple-datasets.md This YAML configuration defines two datasets, `nzdem8m` and `mapzen`, and then creates a `nz-global` MultiDataset that prioritizes `nzdem8m` and falls back to `mapzen`. ```yaml # Hi-res New Zealand. - name: nzdem8m path: data/nzdem8m/ filename_tile_size: 65536 filename_epsg: 2193 # Mapzen global. - name: mapzen path: data/mapzen/ # NZ with mapzen fallback. - name: nz-global child_datasets: - nzdem8m - mapzen ``` -------------------------------- ### Install Specific Pyproj Version Source: https://github.com/ajnisbet/opentopodata/blob/master/docs/notes/running-without-docker.md Installs a specific version of the pyproj library to avoid conflicts with the system's PROJ library. Check requirements.txt for the exact version needed. ```bash cat requirements.txt | grep pyproj ``` ```bash pip3 install pyproj==3.4.1 ``` -------------------------------- ### Public API Response Example Source: https://github.com/ajnisbet/opentopodata/blob/master/docs/datasets/aster.md Example JSON response from the Open Topo Data public API when querying ASTER GDEM 30m data. ```json { "results": [ { "elevation": 45.0, "location": { "lat": 57.688709, "lng": 11.976404 }, "dataset": "aster30m" } ], "status": "OK" } ``` -------------------------------- ### Query Local Test Dataset Source: https://github.com/ajnisbet/opentopodata/blob/master/README.md Example of querying a local Open Topo Data server for elevation data using a test dataset. Ensure the server is running on http://localhost:5000. ```bash curl http://localhost:5000/v1/test-dataset?locations=56,123 ``` -------------------------------- ### Query Local EU-DEM Instance Source: https://github.com/ajnisbet/opentopodata/blob/master/docs/datasets/eudem.md Example of how to query a locally running Open Topo Data instance for elevation data using the EU-DEM dataset. This is useful for testing after adding the dataset. ```bash http://localhost:5000/v1/eudem25m?locations=51.575,-3.220 ``` -------------------------------- ### Run Open Topo Data with Flask Source: https://github.com/ajnisbet/opentopodata/blob/master/docs/notes/running-without-docker.md Starts the Open Topo Data API using the Flask development server. This is suitable for development or small datasets. Ensure FLASK_APP and DISABLE_MEMCACHE are set correctly. ```bash FLASK_APP=opentopodata/api.py DISABLE_MEMCACHE=1 flask run --port 5000 ``` -------------------------------- ### Download and Prepare ETOPO1 Data Source: https://github.com/ajnisbet/opentopodata/blob/master/docs/datasets/etopo1.md Use these bash commands to download the ETOPO1 GeoTIFF, unzip it, and remove the original zip file. Ensure you have `wget` and `unzip` installed. ```bash mkdir ./data/etopo1 wget -P ./data/etopo1 https://www.ngdc.noaa.gov/mgg/global/relief/ETOPO1/data/ice_surface/grid_registered/georeferenced_tiff/ETOPO1_Ice_g_geotiff.zip unzip ./data/etopo1/ETOPO1_Ice_g_geotiff.zip rm ./data/etopo1/ETOPO1_Ice_g_geotiff.zip ``` -------------------------------- ### Local Test Dataset Response Source: https://github.com/ajnisbet/opentopodata/blob/master/README.md Example JSON response from a local Open Topo Data server query for elevation data. ```json { "results": [{ "elevation": 815.0, "location": { "lat": 56.0, "lng": 123.0 }, "dataset": "test-dataset" }], "status": "OK" } ``` -------------------------------- ### Query EMODnet Dataset via Public API Source: https://github.com/ajnisbet/opentopodata/blob/master/docs/datasets/emod2018.md Example of how to query the EMODnet 2018 dataset using the Open Topo Data public API. ```bash curl https://api.opentopodata.org/v1/emod2018?locations=55.884323,2.528276 ``` -------------------------------- ### Error Handling - Unknown Dataset Source: https://context7.com/ajnisbet/opentopodata/llms.txt Example of requesting data from an unknown dataset. The API returns a 400 status code and an error indicating the dataset is not configured. ```bash # Invalid request (400) - unknown dataset curl "https://api.opentopodata.org/v1/unknown-dataset?locations=0,0" ``` -------------------------------- ### Mapzen API Response Example Source: https://github.com/ajnisbet/opentopodata/blob/master/docs/datasets/mapzen.md A sample JSON response from the Open Topo Data public API when querying the Mapzen dataset, showing elevation and location details. ```json { "results": [ { "elevation": 55.0, "location": { "lat": 57.688709, "lng": 11.976404 }, "dataset": "mapzen" } ], "status": "OK" } ``` -------------------------------- ### Python POST Request with Form Data Source: https://context7.com/ajnisbet/opentopodata/llms.txt This example demonstrates sending elevation data requests using form data in the request body. The 'requests' library is required. ```python import requests url = "https://api.opentopodata.org/v1/srtm90m" data = { "locations": "-43.5,172.5|27.6,1.98", "interpolation": "cubic" } response = requests.post(url, data=data) print(response.json()) ``` -------------------------------- ### Download Mapzen Tiles from AWS Source: https://github.com/ajnisbet/opentopodata/blob/master/docs/datasets/mapzen.md Download terrain tiles from the specified AWS S3 bucket using the AWS CLI. Ensure you have the AWS CLI installed and configured. ```bash aws s3 cp --no-sign-request --recursive s3://elevation-tiles-prod/skadi ./data/mapzen ``` -------------------------------- ### SRTM vs ASTER vs EU-DEM Elevation Comparison Source: https://github.com/ajnisbet/opentopodata/blob/master/docs/datasets/eudem.md This example demonstrates querying different elevation datasets (SRTM, ASTER, EU-DEM) for the same location to compare their elevation values. Note the different API endpoints used. ```bash https://api.opentopodata.org/v1/srtm30m?locations=46.242557,206.175588 ``` ```bash https://api.opentopodata.org/v1/aster30m?locations=46.242557,206.175588 ``` ```bash https://api.opentopodata.org/v1/eudem25m?locations=46.242557,206.175588 ``` -------------------------------- ### Query EU-DEM Public API Source: https://github.com/ajnisbet/opentopodata/blob/master/docs/datasets/eudem.md Example of how to query the Open Topo Data public API for elevation data using the EU-DEM dataset. Replace the location coordinates as needed. ```bash curl https://api.opentopodata.org/v1/eudem25m?locations=57.688709,11.976404 ``` -------------------------------- ### EU-DEM API Response Example Source: https://github.com/ajnisbet/opentopodata/blob/master/docs/datasets/eudem.md A sample JSON response from the Open Topo Data public API when querying the EU-DEM dataset. It includes elevation, location, and dataset information. ```json { "results": [ { "elevation": 54.576168060302734, "location": { "lat": 57.688709, "lng": 11.976404 }, "dataset": "eudem25m" } ], "status": "OK" } ``` -------------------------------- ### Get CPU Core Count with Docker Source: https://github.com/ajnisbet/opentopodata/blob/master/docs/notes/performance-optimisation.md Use this command to find the number of CPU cores Open Topo Data is utilizing, which is helpful for determining optimal request batching. ```bash docker logs {NAME_OF_CONTAINER} 2>&1 | grep "CPU cores" ``` -------------------------------- ### Slice VRT into Buffered Tiles with Python Source: https://github.com/ajnisbet/opentopodata/blob/master/docs/notes/buffering-tiles.md This Python script slices a VRT file into individual tiles with a specified buffer. It uses rasterio to get tile bounds and subprocess to run gdal_translate for the transformation. Ensure GDAL command-line tools are installed. ```python import os from glob import glob import subprocess import rasterio # Prepare paths. input_pattern = 'data/eudem/*.TIF' input_paths = sorted(glob(input_pattern)) assert input_paths vrt_path = 'data/eudem-vrt/eudem.vrt' output_dir = 'data/eudem-buffered/' os.makedirs(output_dir, exist_ok=True) # EU-DEM specific options. tile_size = 1_000_000 buffer_size = 25 for input_path in input_paths: # Get tile bounds. with rasterio.open(input_path) as f: bottom = int(f.bounds.bottom) left = int(f.bounds.left) # For EU-DEM only: round this partial tile down to the nearest tile_size. if left == 943750: left = 0 # New tile name in SRTM format. output_name = 'N' + str(bottom).zfill(7) + 'E' + str(left).zfill(7) + '.TIF' output_path = os.path.join(output_dir, output_name) # New bounds. xmin = left - buffer_size xmax = left + tile_size + buffer_size ymin = bottom - buffer_size ymax = bottom + tile_size + buffer_size # EU-DEM tiles don't cover negative locations. xmin = max(0, xmin) ymin = max(0, ymin) # Do the transformation. cmd = [ 'gdal_translate', '-a_srs', 'EPSG:3035', # EU-DEM crs. '-co', 'NUM_THREADS=ALL_CPUS', '-co', 'COMPRESS=DEFLATE', '-co', 'BIGTIFF=YES', '--config', 'GDAL_CACHEMAX','512', '-projwin', str(xmin), str(ymax), str(xmax), str(ymin), vrt_path, output_path, ] r = subprocess.run(cmd) r.check_returncode() ``` -------------------------------- ### Example API Response for ETOPO1 Source: https://github.com/ajnisbet/opentopodata/blob/master/docs/datasets/etopo1.md This JSON object shows the expected response format when querying the ETOPO1 dataset via the Open Topo Data public API. It includes elevation, location details, and the dataset name. ```json { "results": [ { "elevation": 1596.0, "location": { "lat": 39.747114, "lng": -104.996334 }, "dataset": "etopo1" } ], "status": "OK" } ``` -------------------------------- ### Troubleshooting Config File Not Found Error Source: https://github.com/ajnisbet/opentopodata/blob/master/docs/notes/windows-support.md Errors related to not finding the supervisord configuration file typically indicate an issue with the Docker setup or the use of 'make' instead of direct Docker commands. Ensure you are using a recent version (v1.3.1+) of Open Topo Data. ```text process_begin: CreateProcess(NULL, pwd, ...) failed. Makefile:8: pipe: No such file or directory Error: could not find config file /app/docker/supervisord.conf For help, use /usr/bin/supervisord -h make: *** [Makefile:8: run] Error 2 ``` ```text docker: Error response from daemon: OCI runtime create failed: container_linux.go:349: starting container process caused "exec: \"exec /usr/bin/supervisord -c /app/docker/supervisord.conf\": stat exec /usr/bin/supervisord -c /app/docker/supervisord.conf: no such file or directory": unknown. ``` -------------------------------- ### Build and Run Server (Windows) Source: https://context7.com/ajnisbet/opentopodata/llms.txt Build the Docker image and run the Open Topo Data server on Windows using Docker commands. Mount the data directory and map the port. ```bash docker build --tag opentopodata --file docker/Dockerfile . docker run --rm -it --volume C:/path/to/opentopodata/data:/app/data:ro -p 5000:5000 opentopodata sh -c "/usr/bin/supervisord -c /app/docker/supervisord.conf" ``` -------------------------------- ### Build and Run Open Topo Data Locally Source: https://github.com/ajnisbet/opentopodata/blob/master/README.md Instructions to clone the repository, build the Docker image, and run the Open Topo Data server locally. Requires Docker and Git. ```bash git clone https://github.com/ajnisbet/opentopodata.git cd opentopodata make build make run ``` -------------------------------- ### Build and Run Server (Apple Silicon M1/M2) Source: https://context7.com/ajnisbet/opentopodata/llms.txt Specific make commands for building and running the Open Topo Data server on Apple Silicon Macs. ```bash make build-m1 make run ``` -------------------------------- ### Build and Run Open Topo Data on M1 Macs Source: https://github.com/ajnisbet/opentopodata/blob/master/docs/server.md For M1/Apple Silicon Macs, use the alternate Dockerfile to build the image and then run the server. This avoids the need for Rosetta. ```bash git clone https://github.com/ajnisbet/opentopodata.git cd opentopodata make build-m1 make run ``` -------------------------------- ### Test Throughput with ApacheBench (ab) Source: https://github.com/ajnisbet/opentopodata/blob/master/docs/notes/performance-optimisation.md This command-line tool can be used to test the performance and throughput of your Open Topo Data instance. Adjust the number of requests (-n) and concurrent users (-c) as needed for your testing scenario. ```bash ab -n 500 -c 8 http://localhost:5000/v1/test-dataset?locations=56,123 ``` -------------------------------- ### Build and Run Open Topo Data on Windows Source: https://github.com/ajnisbet/opentopodata/blob/master/docs/server.md On Windows, build the Docker image using `docker build` and run the container using `docker run`, specifying volume mounts for data and port mapping. ```bash git clone https://github.com/ajnisbet/opentopodata.git cd opentopodata docker build --tag opentopodata --file docker/Dockerfile . docker run --rm -it --volume C:/path/to/opentopodata/data:/app/data:ro -p 5000:5000 opentopodata sh -c "/usr/bin/supervisord -c /app/docker/supervisord.conf" ``` -------------------------------- ### GET /datasets Source: https://github.com/ajnisbet/opentopodata/blob/master/docs/api.md Retrieves information about the available datasets on the OpenTopoData server. ```APIDOC ## GET /datasets ### Description Provides details on the datasets available on the server. ### Method GET ### Endpoint /datasets ### Response #### Success Response (200) - **datasets** (array) - A list of available datasets. - **name** (string) - The name of the dataset, used in elevation query URLs. - **child_datasets** (array) - If the dataset is a MultiDataset, lists the names of its child datasets. Otherwise, an empty list. - **status** (string) - Indicates the server status (`OK` if running and config loaded, `SERVER_ERROR` otherwise). #### Response Example ```json { "results": [ { "child_datasets": [], "name": "test-dataset" } ], "status": "OK" } ``` ``` -------------------------------- ### Create Data Directory Source: https://github.com/ajnisbet/opentopodata/blob/master/docs/datasets/aster.md Create a new directory to store the ASTER GDEM dataset files. ```bash mkdir ./data/aster30m ``` -------------------------------- ### Upgrade Pip Source: https://github.com/ajnisbet/opentopodata/blob/master/docs/notes/running-without-docker.md Updates pip to the latest version to ensure compatibility with installing Python wheels. ```bash pip3 install --upgrade pip ``` -------------------------------- ### GET /health Source: https://github.com/ajnisbet/opentopodata/blob/master/docs/api.md A healthcheck endpoint useful for load balancing and monitoring to verify server status. ```APIDOC ## GET /health ### Description Healthcheck endpoint for monitoring and load balancing. ### Method GET ### Endpoint /health ### Response #### Success Response (200) - **status** (string) - Will be `OK` for a successful request. #### Response Example ```json { "status": "OK" } ``` ``` -------------------------------- ### Build and Run Open Topo Data Source: https://github.com/ajnisbet/opentopodata/blob/master/docs/datasets/aster.md Rebuild the Open Topo Data project and run it to enable the newly added ASTER GDEM dataset. ```bash make build && make run ``` -------------------------------- ### GET /datasets - List Available Datasets Source: https://context7.com/ajnisbet/opentopodata/llms.txt Retrieves a list of all available elevation datasets, including custom MultiDataset configurations. ```APIDOC ## GET /datasets - List Available Datasets ### Description Returns information about all datasets configured on the server, including MultiDataset configurations. ### Method GET ### Endpoint /datasets ### Response #### Success Response (200) - **results** (array) - A list of available datasets. - **name** (string) - The name of the dataset. - **child_datasets** (array) - For MultiDatasets, a list of datasets included in the configuration. - **status** (string) - The status of the request (e.g., "OK"). #### Response Example ```json { "results": [ {"name": "aster30m", "child_datasets": []}, {"name": "etopo1", "child_datasets": []}, {"name": "mapzen", "child_datasets": []}, {"name": "nz-global", "child_datasets": ["nzdem8m", "mapzen"]}, {"name": "srtm30m", "child_datasets": []}, {"name": "srtm90m", "child_datasets": []} ], "status": "OK" } ``` ``` -------------------------------- ### GET /v1/ Source: https://github.com/ajnisbet/opentopodata/blob/master/docs/api.md Reads the elevation from a given dataset. Multiple datasets can be queried, and locations are expected in EPSG:4326 format. ```APIDOC ## GET /v1/ ### Description Reads the elevation from a given dataset. The dataset name must match one of the options in `config.yaml`. Multiple datasets can be provided separated by commas. ### Method GET ### Endpoint `/v1/` ### Query Parameters - **locations** (string) - Required - Either `latitutde,longitude` pairs, each separated by a pipe character `|`, or Google polyline format. - **samples** (integer) - Optional - Query elevation for `sample` equally-spaced points along the path specified by `locations`. - **interpolation** (string) - Optional - How to interpolate between the points in the dataset. Options: `nearest`, `bilinear`, `cubic`. Default: `bilinear`. - **nodata_value** (string) - Optional - What elevation to return if the dataset has a NODATA value at the requested location. Options: `null`, `nan`, or an integer like `-9999`. Default: `null`. - **format** (string) - Optional - Either `json` or `geojson`. Default: `json`. ### Response #### Success Response (200) - **status** (string) - OK for a successful request. - **results** (array) - List of elevations for each location. - **results[].elevation** (number) - Elevation, using units and datum from the dataset. Will be `null` if the given location is outside the dataset bounds or a NODATA value. - **results[].location** (object) - Location object. - **results[].location.lat** (number) - Latitude as parsed by Open Topo Data. - **results[].location.lng** (number) - Longitude as parsed by Open Topo Data. - **results[].dataset** (string) - The name of the dataset which the returned elevation is from. #### Response Example ```json { "results": [ { "dataset": "srtm90m", "elevation": 45, "location": { "lat": -43.5, "lng": 172.5 } }, { "dataset": "srtm90m", "elevation": 402, "location": { "lat": 27.6, "lng": 1.98 } } ], "status": "OK" } ``` ### GeoJSON Response Example If `format=geojson` is passed, a `FeatureCollection` of `Point` geometries is returned. Each feature has its elevation as the `z` coordinate, and a `dataset` property specifying the source. ``` -------------------------------- ### Create Dataset Directory Source: https://github.com/ajnisbet/opentopodata/blob/master/docs/datasets/swisstopo.md Creates a new directory to store the Swisstopo dataset tiles. Ensure this path matches your Open Topo Data configuration. ```bash mkdir ./data/swisstopo-2m ``` -------------------------------- ### Add Custom Dataset - Rebuild and Restart Server Source: https://context7.com/ajnisbet/opentopodata/llms.txt After adding custom data and updating configuration, rebuild the project and restart the server to apply the changes. ```bash # Rebuild and restart make build && make run ``` -------------------------------- ### Configure Mapzen Dataset Source: https://github.com/ajnisbet/opentopodata/blob/master/docs/datasets/mapzen.md Create a `config.yaml` file to specify the name and path of the Mapzen dataset for Open Topo Data. ```yaml datasets: - name: mapzen path: data/mapzen/ ``` -------------------------------- ### Query Public API with Specific Coordinates Source: https://github.com/ajnisbet/opentopodata/blob/master/docs/index.md Example using curl to query the public API for elevation at a specific latitude and longitude. ```bash curl https://api.opentopodata.org/v1/test-dataset?locations=56.35,123.90 ``` -------------------------------- ### Public API SRTM30m Response Source: https://github.com/ajnisbet/opentopodata/blob/master/README.md Example JSON response from the public Open Topo Data API query for elevation data. ```json { "results": [ { "elevation": 55.0, "location": { "lat": 57.688709, "lng": 11.976404 }, "dataset": "srtm30m" } ], "status": "OK" } ``` -------------------------------- ### Example JSON Response for Elevation Data Source: https://github.com/ajnisbet/opentopodata/blob/master/docs/api.md This is a standard JSON response for a successful elevation data query, showing results for multiple locations. ```json { "results": [ { "dataset": "srtm90m", "elevation": 45, "location": { "lat": -43.5, "lng": 172.5 } }, { "dataset": "srtm90m", "elevation": 402, "location": { "lat": 27.6, "lng": 1.98 } } ], "status": "OK" } ``` -------------------------------- ### GEBCO 2020 API Response Source: https://github.com/ajnisbet/opentopodata/blob/master/docs/datasets/gebco2020.md Example JSON response from the Open Topo Data public API when querying the GEBCO 2020 dataset. ```json { "results": [ { "elevation": 3405.0, "location": { "lat": 37.6535, "lng": -119.4105 }, "dataset": "gebco2020" } ], "status": "OK" } ``` -------------------------------- ### cURL Example with JSON Payload Source: https://context7.com/ajnisbet/opentopodata/llms.txt Use cURL to make a POST request with a JSON payload to query elevation data. This is useful for command-line operations. ```bash curl -X POST https://api.opentopodata.org/v1/srtm90m \ -H "Content-Type: application/json" \ -d '{"locations": "-43.5,172.5|27.6,1.98", "interpolation": "cubic"}' ``` -------------------------------- ### Run Open Topo Data Server with Docker Source: https://github.com/ajnisbet/opentopodata/blob/master/docs/notes/windows-support.md Run the Open Topo Data server using Docker. Modify the volume path to your data directory and adjust the number of threads based on your CPU cores. This command mounts the data directory as read-only. ```bash docker run --rm -it --volume "C:/path/to/opentopodata/data:/app/data:ro" -p 5000:5000 -e N_UWSGI_THREADS=8 opentopodata sh -c "/usr/bin/supervisord -c /app/docker/supervisord.conf" ``` -------------------------------- ### Query NZ DEM Public API Source: https://github.com/ajnisbet/opentopodata/blob/master/docs/datasets/nzdem.md Example of how to query the Open Topo Data public API for elevation data from the NZ DEM dataset. ```curl curl https://api.opentopodata.org/v1/nzdem8m?locations=-37.86118,174.79974 ``` -------------------------------- ### Create Data Directory Source: https://github.com/ajnisbet/opentopodata/blob/master/docs/datasets/emod2018.md Create a new directory to store the EMODnet bathymetry dataset. ```bash mkdir ./data/emod2018 ``` -------------------------------- ### Create Data Directory for BKG 200m DTM Source: https://github.com/ajnisbet/opentopodata/blob/master/docs/datasets/bkg.md Use this command to create a new directory for storing the BKG 200m DTM dataset. ```bash mkdir ./data/bkg200m ``` -------------------------------- ### Error Handling - Missing Locations Source: https://context7.com/ajnisbet/opentopodata/llms.txt Example of an invalid request due to missing 'locations' parameter. The API returns a 400 status code and an error message. ```bash # Invalid request (400) - missing locations curl "https://api.opentopodata.org/v1/srtm90m" ``` -------------------------------- ### Configure Open Topo Data for ETOPO1 Source: https://github.com/ajnisbet/opentopodata/blob/master/docs/datasets/etopo1.md Create a `config.yaml` file to specify the dataset name and its local path for Open Topo Data. This enables the dataset for local use. ```yaml datasets: - name: etopo1 path: data/etopo1/ ``` -------------------------------- ### Configure EU-DEM Dataset Source: https://github.com/ajnisbet/opentopodata/blob/master/docs/datasets/eudem.md Create a configuration file to specify the EU-DEM dataset's name, path, and filename projection details. This allows Open Topo Data to recognize and use the dataset. ```yaml datasets: - name: eudem25m path: data/eudem filename_epsg: 3035 filename_tile_size: 1000000 ``` -------------------------------- ### GET /v1/{dataset_name} - Query Elevation Source: https://context7.com/ajnisbet/opentopodata/llms.txt The primary endpoint for querying elevation data at one or more geographic locations. Supports various query parameters for customization. ```APIDOC ## GET /v1/{dataset_name} - Query Elevation The primary endpoint for querying elevation data at one or more geographic locations. Returns elevation in the units and datum of the underlying dataset. ### Method GET ### Endpoint `/v1/{dataset_name}` ### Query Parameters - **locations** (string) - Required - One or more geographic locations. Can be comma-separated coordinates (lat,lng) or pipe-separated for multiple locations. Can also be Google Polyline encoded. - **interpolation** (string) - Optional - Interpolation method to use (e.g., `nearest`, `bilinear`, `cubic`). Defaults to the dataset's configured method. - **samples** (integer) - Optional - Number of equally-spaced sample points along a path defined by `locations`. - **nodata_value** (string) - Optional - How to handle NODATA values. Can be `null`, `nan`, or an integer (e.g., `-9999`). - **format** (string) - Optional - Response format. Supported values include `json` (default) and `geojson`. ### Request Example ```bash # Single location query curl "https://api.opentopodata.org/v1/srtm90m?locations=-43.5,172.5" # Multiple locations (pipe-separated) curl "https://api.opentopodata.org/v1/srtm90m?locations=-43.5,172.5|27.6,1.98" # With interpolation method (nearest, bilinear, cubic) curl "https://api.opentopodata.org/v1/srtm90m?locations=-43.5,172.5&interpolation=cubic" # Google Polyline encoded locations curl "https://api.opentopodata.org/v1/srtm90m?locations=gfo}EtohhU" # Sample points along a path (e.g., 5 equally-spaced points) curl "https://api.opentopodata.org/v1/srtm90m?locations=-43.5,172.5|-43.6,172.6&samples=5" # Custom NODATA value handling (null, nan, or integer like -9999) curl "https://api.opentopodata.org/v1/srtm90m?locations=-43.5,172.5&nodata_value=-9999" # GeoJSON format response curl "https://api.opentopodata.org/v1/srtm90m?locations=-43.5,172.5|27.6,1.98&format=geojson" ``` ### Response #### Success Response (200) - **results** (array) - An array of elevation data for each queried location. - **elevation** (number) - The elevation value in the units of the dataset. - **location** (object) - The geographic coordinates of the location. - **lat** (number) - Latitude. - **lng** (number) - Longitude. - **dataset** (string) - The name of the dataset used for the query. - **status** (string) - The status of the request (e.g., "OK"). #### GeoJSON Response Example ```json { "type": "FeatureCollection", "features": [ { "type": "Feature", "geometry": {"type": "Point", "coordinates": [172.5, -43.5, 45]}, "properties": {"dataset": "srtm90m"} }, { "type": "Feature", "geometry": {"type": "Point", "coordinates": [1.98, 27.6, 402]}, "properties": {"dataset": "srtm90m"} } ] } ``` ``` -------------------------------- ### Create Data Directory Source: https://github.com/ajnisbet/opentopodata/blob/master/docs/datasets/gebco2020.md Creates a new directory to store the GEBCO 2020 dataset. ```bash mkdir ./data/gebco2020 ``` -------------------------------- ### Configure Open Topo Data Source: https://github.com/ajnisbet/opentopodata/blob/master/docs/datasets/aster.md Create a `config.yaml` file to specify the path to the ASTER GDEM dataset for Open Topo Data. ```yaml datasets: - name: aster30m path: data/aster30m/ ``` -------------------------------- ### Create Mapzen Data Directory Source: https://github.com/ajnisbet/opentopodata/blob/master/docs/datasets/mapzen.md Use this command to create a new directory for storing Mapzen terrain tiles. ```bash mkdir ./data/mapzen ``` -------------------------------- ### Build Docker Image for Open Topo Data Source: https://github.com/ajnisbet/opentopodata/blob/master/docs/notes/windows-support.md Build the Docker image for Open Topo Data using the provided Dockerfile. Ensure you are in the repository's root directory. ```bash docker build --tag opentopodata --file docker/Dockerfile . ``` -------------------------------- ### SRTM 90m API Response Source: https://github.com/ajnisbet/opentopodata/blob/master/docs/datasets/srtm.md Example JSON response from querying the SRTM 90m dataset via the public API. Includes elevation, location, and dataset information. ```json { "results": [ { "elevation": 55.0, "location": { "lat": 57.688709, "lng": 11.976404 }, "dataset": "srtm90m" } ], "status": "OK" } ``` -------------------------------- ### SRTM 30m API Response Source: https://github.com/ajnisbet/opentopodata/blob/master/docs/datasets/srtm.md Example JSON response from querying the SRTM 30m dataset via the public API. Includes elevation, location, and dataset information. ```json { "results": [ { "elevation": 55.0, "location": { "lat": 57.688709, "lng": 11.976404 }, "dataset": "srtm30m" } ], "status": "OK" } ``` -------------------------------- ### Configure Open Topo Data Source: https://github.com/ajnisbet/opentopodata/blob/master/docs/datasets/emod2018.md Create a `config.yaml` file to specify the path to the EMODnet VRT dataset for Open Topo Data. ```yaml datasets: - name: emod2018 path: data/emod2018-vrt/ ``` -------------------------------- ### Create Data Directory Source: https://github.com/ajnisbet/opentopodata/blob/master/docs/datasets/nzdem.md Creates a directory to store the NZ DEM data files. ```bash mkdir ./data/nzdem8m ``` -------------------------------- ### Create NED Data Directory Source: https://github.com/ajnisbet/opentopodata/blob/master/docs/datasets/ned.md Creates a directory to store the NED 10m dataset files. ```bash mkdir ./data/ned10m ``` -------------------------------- ### Query Public Mapzen API Source: https://github.com/ajnisbet/opentopodata/blob/master/docs/datasets/mapzen.md Example of how to query the Open Topo Data public API for elevation data from the Mapzen dataset using a specific latitude and longitude. ```curl curl https://api.opentopodata.org/v1/mapzen?locations=57.688709,11.976404 ``` -------------------------------- ### Create EU-DEM Data Directory Source: https://github.com/ajnisbet/opentopodata/blob/master/docs/datasets/eudem.md Create a directory to store the unzipped EU-DEM dataset files. This is a prerequisite for configuring the dataset. ```bash mkdir ./data/eudem ``` -------------------------------- ### Query Elevation (Single Location) Source: https://context7.com/ajnisbet/opentopodata/llms.txt Use curl to query elevation for a single geographic location using the GET /v1/{dataset_name} endpoint. Specify latitude and longitude. ```bash curl "https://api.opentopodata.org/v1/srtm90m?locations=-43.5,172.5" ``` -------------------------------- ### Python POST Request with JSON Data Source: https://context7.com/ajnisbet/opentopodata/llms.txt Use this method to send elevation data requests using JSON format in the request body. Ensure the 'requests' library is installed. ```python import requests url = "https://api.opentopodata.org/v1/srtm90m" data = { "locations": "-43.5,172.5|27.6,1.98|51.5,-0.1|40.7,-74.0", "interpolation": "bilinear", "format": "json" } response = requests.post(url, json=data) print(response.json()) ``` -------------------------------- ### Configure Open Topo Data for BKG 200m DTM Source: https://github.com/ajnisbet/opentopodata/blob/master/docs/datasets/bkg.md Add the BKG 200m DTM dataset configuration to your `config.yaml` file. Ensure the `path` points to the directory where you extracted the dataset files. ```yaml - name: bkg200m path: data/bkg200m ``` -------------------------------- ### Configure GEBCO 2020 Dataset Source: https://github.com/ajnisbet/opentopodata/blob/master/docs/datasets/gebco2020.md Creates a `config.yaml` file to specify the path and tile size for the GEBCO 2020 dataset. ```yaml datasets: - name: gebco2020 path: data/gebco2020/ filename_tile_size: 90 ``` -------------------------------- ### Run Docker with Cloud Credentials Source: https://github.com/ajnisbet/opentopodata/blob/master/docs/notes/cloud-storage.md Run the Open Topo Data Docker container, passing cloud storage credentials as environment variables. This is necessary when accessing cloud storage directly via VRT files. ```bash docker run -it -v /home/XXX/opentopodata/data:/app/data:ro -p 5000:5000 -e GS_SECRET_ACCESS_KEY=XXX -e GS_ACCESS_KEY_ID=XXX opentopodata ``` -------------------------------- ### Query GEBCO 2020 Public API Source: https://github.com/ajnisbet/opentopodata/blob/master/docs/datasets/gebco2020.md Example of how to query the Open Topo Data public API for GEBCO 2020 elevation data using a specific latitude and longitude. ```bash curl https://api.opentopodata.org/v1/gebco2020?locations=37.6535,-119.4105 ``` -------------------------------- ### Run Docker with Mounted Volume Source: https://github.com/ajnisbet/opentopodata/blob/master/docs/notes/cloud-storage.md Run the Open Topo Data Docker container, mounting the cloud dataset directory into the container. The ':ro' flag ensures the data is mounted read-only. ```bash docker run --rm -it --volume /mnt/otd-cloud-datasets/:/app/data:ro -p 5000:5000 opentopodata ``` -------------------------------- ### Query Elevation with Path Samples Source: https://context7.com/ajnisbet/opentopodata/llms.txt Request a specified number of sample points along a path defined by two locations using the 'samples' parameter. ```bash curl "https://api.opentopodata.org/v1/srtm90m?locations=-43.5,172.5|-43.6,172.6&samples=5" ``` -------------------------------- ### Public API Response for NED 10m Source: https://github.com/ajnisbet/opentopodata/blob/master/docs/datasets/ned.md Example JSON response from the Open Topo Data public API, showing elevation data for the queried location from the 'ned10m' dataset. ```json { "results": [ { "elevation": 3498.298583984375, "location": { "lat": 37.6535, "lng": -119.4105 }, "dataset": "ned10m" } ], "status": "OK" } ``` -------------------------------- ### Add Custom Dataset - Create Directory and Copy Files Source: https://context7.com/ajnisbet/opentopodata/llms.txt Steps to add a custom elevation dataset. This involves creating a directory for the dataset and copying raster files into it. Supported formats include .tiff, .hgt, and .jp2. ```bash # Create directory for new dataset mkdir ./data/my-dem # Copy your raster files (supports .tiff, .hgt, .jp2, etc.) cp /path/to/elevation-data/*.tif ./data/my-dem/ ``` -------------------------------- ### Query Public API for SRTM30m Data Source: https://github.com/ajnisbet/opentopodata/blob/master/README.md Example of querying the public Open Topo Data API for elevation data from the SRTM30m dataset. The public API is hosted at api.opentopodata.org. ```bash curl https://api.opentopodata.org/v1/srtm30m?locations=57.688709,11.976404 ```