Serverless, worldwide slope angle shading tiles generated from AWS Terrain Tiles.
NOTE: I think I currently have some z-scaling issues, because the generated
tiles indicate lesser slopes than another project (turn on
slope-angle shading) which uses precomputed tiles from gdaldem
.
One of the many great AWS Open Data datasets is terrain tiles. These are a collection of worldwide elevation products stored on AWS S3 for anyone to use. This project shows how easy, fast, and cheap it is to leverage AWS Open Data for hobby projects.
Slope-angle shading is a great overlay for many types of outdoor planning. The darker the colors, the steeper the slope, the more you need to make sure you're prepared.
This uses Caltopo's slope-angle shading color scheme by default, but it's trivial to supply a different set of RGB values to make a different color scheme.
Deployment should be easy and fast. This requires Docker, Python, and Node:
git clone https://github.com/kylebarron/serverless-slope
cd serverless-slope
make package
npm i -g serverless
sls deploy --bucket bucket-where-you-store-data --cache-control "public,max-age=4000"
Roughly ~$5.70 per 1M requests. Note this is for requests that reach Lambda. By using Cloudflare and an appropriate cache control header, this could be substantially reduced.
Lambda:
-
$0.20 per 1M requests
-
Set to 192MB and if each invocation takes .9s, per 1M requests:
$0.0000166667 GB-second / * 192 / 1024 * .9 * 1M = $2.81
API Gateway:
- $1.00 per 1M requests
Data Transfer:
20 KB * 1M / 1024 / 1024 * $0.09 = $1.70
- Use Cloudflare to cache images with a long cache control header
At zoom 15, there are 4^15 ~= 1 Billion tiles to cover the globe. At 10KB per tile, that would be 10TB of data, or $235/month just to store on S3. Obviously much of the globe is water, so you could be smarter and not store non-land tiles, but it's not going to be as cheap for low to mid-range use as serverless is.