gray rock formation

Generate COGs from AWS Terrain Tiles

With the ever-increasing volume of open data out there, we’re always looking for ways to make it more accessible and useful. The AWS Terrain Tiles dataset is an amazing open data resource created by Mapzen. According to its creators, it “consists of thousands of digital elevation model (DEM) data sources at various resolutions from around the globe, merged together and split into billions of map tiles”. Terrain tiles are available on AWS S3 for anyone to access.

DEM data has a huge variety of applications. These include topographic mapping (think contour lines and hillshading), 3D visualization, flood and drainage modeling, hazard mapping, or extracting geomorphic attributes like slope and aspect.

Obtaining DEM data in the past would require you to identify a source covering your area of interest. Then there would be a clunky download process, often involving several files which would then be followed by a manual merge and clip process to get the data to match your area of interest.

AWS Terrain Tiles have global coverage so they can provide a solution to this issue. But there’s a lack of simple tools for accessing the data. As part of a hack day at Sparkgeo we decided to build a tool to solve this problem.

The result is Terradactile. Please note Terradactile is currently in its alpha phase and is a work in progress. Let us know if you experience any issues.

Terradactile is a web map application which generates DEM and hillshade COGs (Cloud Optimized GeoTIFFs) based on AWS Terrain Tile data.

Our goal with this app was to make it as simple as possible for the user to go from drawing an area of interest to displaying and/or downloading elevation data.

1. Draw an area of interest

2. Fetch and process the elevation tiles

When the user clicks the “Generate DEM and hillshade” button, a request is sent to the Terradactile API, which triggers an AWS Lamba function. The function is able to make use of spatial Python modules that are normally too large to be included in Lambdas, by leveraging two GeoLambda layers, found here. The lambda function has several responsibilities, including:

  • listing and fetching necessary elevation tiles
  • mosaicking tiles into a continuous DEM
  • clipping the tiles to the area of interest
  • computing a hillshade layer from the DEM
  • converting both the DEM and hillshade to COG format
  • creating an 8-bit DEM for display in the browser
  • saving these layers to AWS S3 storage.

The response from the API is simply a path to the S3 storage folder, containing three outputs:

  • mosaic.tif: the DEM, containing real elevation values
  • mosaic_display.tif: the DEM, fit into 8-bit values (0-255)
  • hillshade.tif: the hillshade layer. You can find the code for the Lambda function and full serverless deployment in our repo here.

3. Display the result within Terradactile

Because the layers are stored in COG format, we can use a dynamic tiler to fetch and display only the necessary imagery tiles, directly from S3 storage. We make use of titiler in this application.

4. Download the DEM and/or hillshade

We’d love to hear how you’re using Terradactile.

If you like the app we’ve built here, want to utilize more open data, or want to work with COGs, Sparkgeo can help.

A big thanks to the Terradactile hack team! Darren Wiens, Parm Thind and Mike Connor. Special thanks to Darren for his technical skills and contributing a large portion of this post.

You can find Terradactile here

Sharing options

Experiments • Chloe Papalazarou

Geospatial Technology for Flood Monitoring

Time-lapse of the November 14 atmospheric river event, acquired by the GOES-17 satellite On November 14, southern British Columbia experienced the devastating effects of an “atmospheric river” –…

green pine trees near body of water during daytime

Experiments • James Banting

Splendour without diminishment

We’ve been thinking a lot about risk at Sparkgeo and how geospatial technology can support risk assessment. Context is everything when planning out investments, and geography is very…

selective photography of green leaf plant

Experiments • James Banting

COP26 and ESG

COP26 and ESG goals require the same geographic data. Understanding the context is essential to selecting the right data.

Need a geospatial partner?

Our team complements organizations like yours—by providing on-tap access to geospatial, analytics, and mapping expertise.

Let’s talk

Join our team?

We’re always looking for skilled technologists to help us build the future of geospatial. Got a minute to find out more about us?

Working Here

Sharing options