Home

Awesome

landsat-tiler

AWS Lambda + Landsat AWS PDS = landsat-tiler

Description

Create a highly customizable serverless tile server for Amazon's Landsat Public Dataset. This project is based on rio-tiler python library.

landsat-tiler-small

Landsat data on AWS

Since 2015 Landsat 8 data is hosted on AWS and can be freely accessed. This dataset is growing over 700 scenes a day and have archive up to 2013.

AWS has made Landsat 8 data freely available on Amazon S3 so that anyone can use our on-demand computing resources to perform analysis and create new products without needing to worry about the cost of storing Landsat data or the time required to download it.

more info: https://aws.amazon.com/public-datasets/landsat/

Something important about AWS Landsat-pds is that each Landsat scene has its individual bands stored as cloud optimized GeoTIFF. While this is a critical point to work with the data, it also means that to create an RGB image and visualize it, you have to go through a lot of manual steps.

Lambda function

AWS Lambda is a service that lets you run functions in Node, Python, or Java in response to different triggers like API calls, file creation, database edits, etc. In addition to only have to provide code, an other crucial point of AWS Lambda it that you only pay for the execution of the function, you don't have to pay for a 24/24h running server. It's called serverless cause you only need to care about the code you provide.


Installation

Requirement

Create the package

Creating a python lambda package with some C (or Cython) libraries like Rasterio/GDAL has never been an easy task because you have to compile and build it on the same infrastructure where it's going to be used (Amazon linux AMI). Until recently, to create your package you had to launch an EC2 instance using the official Amazon Linux AMI and create your package on it (see perrygeo blog or Remotepixel blog).

But this was before, Late 2016, the AWS team released the Amazon Linux image on docker, so it's now possible to use it locally to compile C libraries and create complex lambda package (see Dockerfile).

Note: to stay under AWS lambda package sizes limits (100Mb zipped file / 250Mb unzipped archive) we need to use some tricks.

# Build Amazon linux AMI docker container + Install Python modules + create package
git clone https://github.com/mapbox/landsat-tiler.git
cd landsat-tiler/
make all

Deploy to AWS

One of the easiest way to Build and Deploy a Lambda function is to use Serverless toolkit. We took care of the building part with docker so we will just ask Serverless to only upload our package file to AWS S3, to setup AWS Lambda and AWS API Gateway.

#configure serverless (https://serverless.com/framework/docs/providers/aws/guide/credentials/)
npm install
sls deploy
<img width="500" alt="sls deploy" src="https://cloud.githubusercontent.com/assets/10407788/22188728/d9ffec44-e0e5-11e6-9a77-569a791ccaf2.png">

:tada: You should be all set there.


Use it: Landsat-viewer

lambda-tiler + Mapbox GL + Satellite API

The viewer/ directory contains a UI example to use with your new Lambda Landsat tiler endpoint. It combine the power of mapbox-gl and the nice developmentseed sat-api to create a simple and fast Landsat-viewer.

To be able to run it, edit those two lines in viewer/js/app.js

// viewer/js/app.js
3  mapboxgl.accessToken = '{YOUR-MAPBOX-TOKEN}';
4  const landsat_tiler_url = "{YOUR-API-GATEWAY-URL}";

Workflow

  1. One AWS λ call to get min/max percent cut value for all the bands and bounds

Path: /landsat/metdata/{landsat scene id}

Inputs:

Options:

Output: (dict)

Example: <api-gateway-url>/landsat/metadata/LC08_L1TP_016037_20170813_20170814_01_RT?pmin=5&pmax=95

  1. Parallel AWS λ calls (one per mercator tile) to retrieve corresponding Landsat data

Path: /landsat/tiles/{landsat scene id}/{z}/{x}/{y}.{ext}

Inputs:

Options:

Output:

Example:


Live Demo: https://viewer.remotepixel.ca

Infos & links