Giter Site home page Giter Site logo

geonux / lambda-tiler Goto Github PK

View Code? Open in Web Editor NEW

This project forked from vincentsarago/lambda-tiler

0.0 1.0 0.0 771 KB

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

License: BSD 3-Clause "New" or "Revised" License

Makefile 0.84% Python 91.71% Dockerfile 0.45% Shell 7.00%

lambda-tiler's Introduction

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

  • AWS Account
  • Docker (+ docker-compose)
  • node + npm (serverless)

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:

  • url (required, str): mosaic id
  • kwargs (optional): Other querystring parameters will be forwarded to the tile url.

Outputs:

  • html (text/html)

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

TileJSON (2.1.0)

/tilejson.json - GET

Inputs:

  • url (required): mosaic definition url
  • tile_format (optional, str): output tile format (default: "png")
  • kwargs (in querytring): Other querystring parameters will be forwarded to the tile url

Outputs:

  • tileJSON (application/json)

$ 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:

  • url (required): mosaic definition url

Outputs:

  • metadata (application/json)

$ 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:

  • url (required, str): dataset url
  • pmin (optional, str): min percentile (default: 2).
  • pmax (optional, str): max percentile (default: 98).
  • nodata (optional, str): Custom nodata value if not preset in dataset.
  • indexes (optional, str): dataset band indexes
  • overview_level (optional, str): Select the overview level to fetch for statistic calculation
  • max_size (optional, str): Maximum size of dataset to retrieve for overview level automatic calculation
  • histogram_bins (optional, str, default:20): number of equal-width histogram bins
  • histogram_range (optional, str): histogram min/max

Outputs:

  • metadata (application/json)

$ 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:

  • z: Mercator tile zoom value
  • x: Mercator tile x value
  • y: Mercator tile y value
  • ext: image format (e.g jpg)
  • scale (optional, int): tile scale (default: 1)
  • url (required, str): dataset url
  • indexes (optional, str): dataset band indexes (default: dataset indexes)
  • expr (optional, str): dataset expression
  • nodata (optional, str): Custom nodata value if not preset in dataset (default: None)
  • rescale (optional, str): min/max for data rescaling (default: None)
  • color_formula (optional, str): rio-color formula (default: None)
  • color_map (optional, str): rio-tiler colormap (default: None)

Outputs:

  • image body (image/jpeg)

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

Note:

  • expr and indexes cannot be passed used together
  • if no ext passed, lambda-tiler will choose the best format (jpg or png) depending on mask (use png for tile with nodata)

Example

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

Inputs: None

Outputs:

  • html (text/html)

$ curl {your-endpoint}/example

lambda-tiler's People

Contributors

vincentsarago avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.