Open Topo Data Documentation

repository·master·Indexed 19 days ago

https://github.com/ajnisbet/opentopodata

A REST API server for elevation data that can be self-hosted using various raster file formats or accessed via a free public API. Designed to be largely compatible with the Google Maps Elevation API, it supports point queries for single or multiple locations in EPSG:4326 (WGS-84) format, including support for Google Polyline and GeoJSON responses. Documentation covers installation via Docker, API endpoint usage (GET/POST), and guides for adding datasets such as ASTER 30m, BKG 200m, and EMODnet 2018 Bathymetry.

Tokens
20.3K
Snippets
79
Records
95
Agent score
65%

What's inside Open Topo Data

  1. Overview of NED (National Elevation Dataset) resolutions

    master

    The National Elevation Dataset (NED) provides Digital Elevation Models (DEMs) for the USA at various resolutions and coverage areas:

    • 1 arcsecond (30m): Covers North America and Mexico.
    • 1/3 arcsecond (10m): Covers CONUS, HI, PR, and parts of AK. This is the version used in the Open Topo Data public API.
    • 1/9 arcsecond (3m): Partial coverage focused on urban areas.
    • 1 meter: Partial coverage focused on urban areas.
    • Alaska specific:
      • 2 arcsecond (60m) full coverage.
      • 5m full coverage.
  2. EU-DEM Dataset Characteristics: Coverage, Accuracy, and Coastlines

    master

    Coverage

    EU-DEM covers European Environment Agency member states and some eastern countries, extending into parts of Northern Africa. It includes Scandinavian regions north of 60°, which are often missing from SRTM.

    Accuracy

    The vertical accuracy is approximately ± 7m RMSE.

    Coastline Behavior

    EU-DEM uses NODATA values for elevations over seas and oceans.

    • Advantage: You can use the dataset without needing to clip to a coastline shapefile.
    • Limitation: Open Topo Data cannot interpolate elevations very close to the coast; it will return NaN in areas where SRTM or ASTER might return 0m or 1m.
  3. Supported Dataset Formats

    master

    Open Topo Data supports any georeferenced raster format supported by GDAL (e.g., .tiff, .hgt, .jp2).

    Datasets can be structured in two ways:

    1. A single raster file: A single file containing the elevation data.
    2. A collection of square raster tiles: Tiles following the SRTM naming convention (e.g., N30W120.tiff spans 30° to 31° N and -120° to -119° W).

    Note on non-grid files: If your files do not follow a perfect grid, you can create a .vrt file to treat them as a single-file dataset.

  4. Add the 30m ASTER dataset to Open Topo Data

    master

    To include the ASTER 30m dataset in your local Open Topo Data instance, follow these steps:

    1. Create a data directory: Create a folder named ./data/aster30m.
    2. Download and prepare files: Download the ASTER files from USGS into the ./data/aster30m directory. Extract the zip archives, ensuring you keep the _dem.tif files and remove the _num.tif files.
    3. Configure the dataset: Create a config.yaml file in your project root to register the new dataset.
    4. Rebuild the project: Run the build and run commands to enable the dataset at the v1/aster30m endpoint.
    # 1. Create directory
    mkdir ./data/aster30m
    
    # 2. (Download files from USGS and extract _dem.tif files into ./data/aster30m)
    
    # 3. Create config.yaml (see configuration record)
    
    # 4. Rebuild
    make build && make run
  5. Query elevation data using the point query endpoint

    master

    Open Topo Data provides a single endpoint for point queries. You can request the elevation for a single point or a series of points by providing coordinates in the locations parameter. The API supports multiple locations in one request and can also accept locations in Google Polyline format. The interpolation algorithm can be configured via request parameters.

    When self-hosting, the endpoint follows the pattern http://localhost:5000/v1/<dataset>?locations=<lat>,<lng>.

    curl http://localhost:5000/v1/test-dataset?locations=56,123
  6. Add 30m SRTM to Open Topo Data

    master

    To include the 30m SRTM dataset in your local Open Topo Data instance:

    1. Create a config.yaml file with the following entry:
    datasets:
    - name: srtm30m
      path: data/srtm30m/
    1. Rebuild and run the project:
    make build && make run

    Once running, the dataset will be available at http://localhost:5000/v1/srtm30m.

  7. Add new datasets to Open Topo Data

    master

    To add a new dataset, follow these two steps:

    1. Place the dataset files in the data directory.
    2. Add the path to the dataset in config.yaml under the datasets list.

    Specific instructions for common datasets (ASTER, ETOPO1, SRTM, etc.) can be found in their respective documentation files within the repository.

  8. Add GEBCO 2020 Bathymetry to Open Topo Data

    master

    To include the GEBCO 2020 dataset in a local Open Topo Data instance, follow these steps:

    1. Prepare Directory: Create a folder for the dataset.
      mkdir ./data/gebco2020
    2. Download and Extract: Download the GEBCO_2020 Grid in Data GeoTiff format from GEBCO. Extract the raster tiles into the ./data/gebco2020 folder so that it contains exactly 8 .tif files.
    3. Rename Tiles: Rename the 90-degree tiles to match the SRTM NxxSxx format required by Open Topo Data.
    4. Configure: Create a config.yaml file to register the dataset.
    5. Build and Run: Rebuild the project to enable the new endpoint.

    Note: The GEBCO tiles do not overlap and cover slightly less than a 90° x 90° square. To avoid null results at tile edges (e.g., coordinates 0,0), it is recommended to apply a 5px buffer to each tile using GDAL.

    mkdir ./data/gebco2020
    
    # Rename tiles to SRTM format
    mv gebco_2020_n0.0_s-90.0_w0.0_e90.0.tif     S90E000.tif
    mv gebco_2020_n0.0_s-90.0_w-180.0_e-90.0.tif S90W180.tif
    mv gebco_2020_n0.0_s-90.0_w-90.0_e0.0.tif    S90W090.tif
    mv gebco_2020_n0.0_s-90.0_w90.0_e180.0.tif   S90E090.tif
    mv gebco_2020_n90.0_s0.0_w0.0_e90.0.tif      N00E000.tif
    mv gebco_2020_n90.0_s0.0_w-180.0_e-90.0.tif  N00W180.tif
    mv gebco_2020_n90.0_s0.0_w-90.0_e0.0.tif     N00W090.tif
    mv gebco_2020_n90.0_s0.0_w90.0_e180.0.tif    N00E090.tif
    
    # Build and run
    make build && make run
  9. Add the ETOPO1 dataset to Open Topo Data

    master

    To add the ETOPO1 dataset to your local Open Topo Data instance, follow these steps:

    1. Download and extract the data: Create a directory in ./data/etopo1, download the grid-registered .tif file from NOAA, and unzip it.
    2. Assign projection: The raw .tif file lacks projection information. Use gdal_translate to assign the EPSG:4326 (WGS84) spatial reference system.
    3. Configure the dataset: Create or update a config.yaml file to include the new dataset path.
    4. Rebuild: Run the build and run commands to make the dataset available via the API.

    Note: ETOPO1 is a global elevation dataset that includes bathymetry (water depth) with a resolution of approximately 1.8km at the equator.

    ```bash
    # 1. Download and unzip
    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
    
    # 2. Add projection using GDAL
    gdal_translate -a_srs EPSG:4326 ./data/etopo1/ETOPO1_Ice_g_geotiff.tif ./data/etopo1/ETOPO1.tif
    rm ./data/etopo1/ETOPO1_Ice_g_geotiff.tif
    
    # 3. Configure (create config.yaml)
    # datasets:
    # - name: etopo1
    #   path: data/etopo1/
    
    # 4. Rebuild
    make build && make run
    ```埋め込み
  10. Add the 200m BKG Digital Terrain Model to Open Topo Data

    master

    To include the free 200m BKG resolution dataset in your local Open Topo Data instance, follow these steps:

    1. Create a data directory: Create a new folder for the dataset.
    2. Download and prepare files: Download the UTM referenced dataset in .asc format. Extract the zip file and move only the .asc and .prj files into your new directory.
    3. Configure the dataset: Add the dataset entry to your config.yaml file.
    4. Rebuild and run: Rebuild the project to enable the new endpoint.

    The resulting endpoint will follow the pattern localhost:5000/v1/bkg200m?locations=lat,lng.

    # 1. Create directory
    mkdir ./data/bkg200m
    
    # (Download and extract dgm200_utm32s.asc and dgm200_utm32s.prj into ./data/bkg200m)
    
    # 2. Add to config.yaml
    # - name: bkg200m
    #   path: data/bkg200m
    
    # 3. Rebuild and run
    make build && make run