Home

Awesome

lambda-tiler

CircleCI codecov

AWS Lambda + rio-tiler to serve tiles from any web hosted files

image_preview

lambda-tiler is a simple serverless (AWS Lambda function) application that serves Map Tiles dynamically created from COGs hosted remotely (s3, http, ...)

Deploy

Requirement

Create the package

# Build Amazon linux AMI docker container + Install Python modules + create package
$ git clone https://github.com/vincentsarago/lambda-tiler.git
$ cd lambda-tiler/

$ docker-compose build
$ docker-compose run --rm package

# Tests
$ docker-compose run --rm tests

Note: Docker image from https://github.com/RemotePixel/amazonlinux

Deploy to AWS

#configure serverless (https://serverless.com/framework/docs/providers/aws/guide/credentials/)
npm install
sls deploy

API

Viewer

/viewer - GET

A web viewer that allows you to pan & zoom the COG.

Inputs:

Outputs:

$ curl {your-endpoint}/viewer?url=https://any-file.on/the-internet.tif

TileJSON (2.1.0)

/tilejson.json - GET

Inputs:

Outputs:

$ curl https://{endpoint-url}/tilejson.json?url=https://any-file.on/the-internet.tif

{
    "bounds": [...],      
    "center": [lon, lat], 
    "minzoom": 18,        
    "maxzoom": 22,        
    "name": "the-internet.tif",
    "tilejson": "2.1.0",  
    "tiles": [...] ,      
}

Bounds

Inputs:

Outputs:

$ curl https://{endpoint-url}/bounds?url=https://any-file.on/the-internet.tif

{
  "url": "https://any-file.on/the-internet.tif", 
  "bounds": [...]
}

Metadata

/metadata - GET

Inputs:

Outputs:

$ curl https://{endpoint-url}/metadata?url=s3://url=https://any-file.on/the-internet.tif

{
    "address": "s3://myfile.tif",
    "bbox": [...],
    "band_descriptions": [(1, "red"), (2, "green"), (3, "blue"), (4, "nir")],
    "statistics": {
        "1": {
            "pc": [38, 147],
            "min": 20,
            "max": 180,
            "std": 28.123562304138662,
            "histogram": [
                [...],
                [...]
            ]
        },
        ...
    }
}

Tiles

/tiles/{z}/{x}/{y} - GET

/tiles/{z}/{x}/{y}.{ext} - GET

/tiles/{z}/{x}/{y}@{scale}x - GET

/tiles/{z}/{x}/{y}@{scale}x.{ext} - GET

Inputs:

Outputs:

$ curl {your-endpoint}/tiles/7/10/10.png?url=https://any-file.on/the-internet.tif

Note:

Example

A web viewer that allows you to pan & zoom on a sample tiff.

Inputs: None

Outputs:

$ curl {your-endpoint}/example