Skip to main content

MEMDEM

Make use of open global elevation data from Terrain Tiles to create digital elevation models (DEM) on the fly.

The memdem project credits the data source providers. Any use of memdem for redistribution, resale, presentation or publication of the data available from the Terrain Tiles dataset is required to make a similar attribution. See here for more information.

Installation

memdem depends on

  • rasterio[s3]
  • morecantile

Linux / OSX

pip install memdem

Windows

note: Rasterio does not provide official windows wheels, ensure GDAL is installed in order to install rasterio dependency.

Unofficial wheels

Unofficial rasterio wheels (includes GDAL).

Conda

conda create -yn memdem python=3.9
conda activate memdem
conda install -c conda-forge gdal

Once GDAL is installed, the environment variable GDAL_VERSION may need to be set in order to install rasterio dependency.

pip install memdem

Quickstart

import rasterio
from rasterio.crs. import CRS

import memdem

# define a bounding box
bounds = (-123.61735447008346, 48.91185687803928, -122.74734074899379, 49.52797572603976)

# create an instance of DEMTiles
demtiles = memdem.DEMTiles(
    bounds,
    zoom=10
)

# behold, a DEM created on the fly
with demtiles.open() as dem:
    lon, lat = (-123.17911189115098, 49.26435101976154)
    point_xy = rasterio.warp.transform(CRS.from_epsg(4326), dem.crs, [lon], [lat])
    print(next(dem.sample(zip(*point_xy))))  # 20


# save DEM to file for later use
demtiles.to_file("path/to/dem.vrt")

Notes

Coordinate Reference System

Terrain Tiles are referenced to the EPSG:3857 aka Web Mercator projection. However the vertical datum (what reference is used for elevation values e.g. WGS84 ellipsoid) may vary depending on the source data. For accurate elevation results, it may be required to use source data with a well-defined vertical datum. For example, SRTM data has vertical datum EGM96.

AWS credentials

The Terrain Tiles dataset is avaiable freely and does not require aws credentials to access. Rasterio uses signed requests by default and may result in an error if it cannot locate your aws credentials. By default, memdem wraps the the DEMTiles.open context in a rasterio.Env(aws_unsigned=True) context. For operations requiring dataset reads outside of the DEMTiles.open context (e.g. when opening a previously saved VRT) ensure you do so within a rasterio.Env(aws_unsigned=True) block.

Release files for memdem 0.1.0.post1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for memdem 0.1.0.post1
File Size Uploaded
memdem-0.1.0.post1.tar.gz 12.9 kB Details

Release files / memdem-0.1.0.post1.tar.gz

Download URL memdem-0.1.0.post1.tar.gz
Size 12.9 kB
Tags Source
SHA-256 checksum
How to use checksums
e1a43bb74c8b67eb7d32affa7b3e7a6ba6b719f931b7d921539a2f8351e3e124
BLAKE2b-256 checksum
How to use checksums
fa1a5577085b4f6101527b82cd58fefb22b6f05638a901dd4508b8d4f09b39a1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.6

Release history Release notifications | RSS feed

This release

0.1.0.post1 This release

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page