• Stars
    star
    673
  • Rank 66,593 (Top 2 %)
  • Language
    Python
  • License
    MIT License
  • Created over 6 years ago
  • Updated about 1 month ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A light-weight, versatile XYZ tile server, built with Flask and Rasterio ๐ŸŒ

Tests Documentation Status codecov GitHub release PyPI release License Python versions

Logo

Terracotta is a pure Python tile server that runs as a WSGI app on a dedicated webserver or as a serverless app on AWS Lambda. It is built on a modern Python stack, powered by awesome open-source software such as Flask, Zappa, and Rasterio.

Read the docs | Explore the API | Satlas, powered by Terracotta

Why Terracotta?

  • It is trivial to get going. Got a folder full of cloud-optimized GeoTiffs in different projections you want to have a look at in your browser? terracotta serve -r {name}.tif and terracotta connect localhost:5000 get you there.
  • We make minimal assumptions about your data, so you stay in charge. Keep using the tools you know and love to create and organize your data, Terracotta serves it exactly as it is.
  • Serverless deployment is a first-priority use case, so you donโ€™t have to worry about maintaining or scaling your architecture.
  • Terracotta instances are self-documenting. Everything the frontend needs to know about your data is accessible from only a handful of API endpoints.

The Terracotta workflow

1. Optimize raster files

$ ls -lh
total 1.4G
-rw-r--r-- 1 dimh 1049089 231M Aug 29 16:45 S2A_20160724_135032_27XVB_B02.tif
-rw-r--r-- 1 dimh 1049089 231M Aug 29 16:45 S2A_20160724_135032_27XVB_B03.tif
-rw-r--r-- 1 dimh 1049089 231M Aug 29 16:46 S2A_20160724_135032_27XVB_B04.tif
-rw-r--r-- 1 dimh 1049089 231M Aug 29 16:56 S2A_20170831_171901_25XEL_B02.tif
-rw-r--r-- 1 dimh 1049089 231M Aug 29 16:57 S2A_20170831_171901_25XEL_B03.tif
-rw-r--r-- 1 dimh 1049089 231M Aug 29 16:57 S2A_20170831_171901_25XEL_B04.tif

$ terracotta optimize-rasters *.tif -o optimized/

Optimizing rasters: 100%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ| [05:16<00:00, file=S2A_20170831_...25XEL_B04.tif]

2. Create a database from file name pattern

$ terracotta ingest optimized/S2A_{date}_{}_{tile}_{band}.tif -o greenland.sqlite
Ingesting raster files: 100%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ| 6/6 [00:49<00:00,  8.54s/it]

3. Serve it up

$ terracotta serve -d greenland.sqlite
 * Serving Flask app "terracotta.server" (lazy loading)
 * Environment: production
   WARNING: Do not use the development server in a production environment.
   Use a production WSGI server instead.
 * Debug mode: off
 * Running on http://localhost:5000/ (Press CTRL+C to quit)

4. Explore the running server

Manually

You can use any HTTP-capable client, such as curl.

$ curl localhost:5000/datasets?tile=25XEL
{"page":0,"limit":100,"datasets":[{"date":"20170831","tile":"25XEL","band":"B02"},{"date":"20170831","tile":"25XEL","band":"B03"},{"date":"20170831","tile":"25XEL","band":"B04"}]}

Modern browsers (e.g. Chrome or Firefox) will render the JSON as a tree.

Interactively

Terracotta also includes a web client. You can start the client (assuming the server is running at http://localhost:5000) using

$ terracotta connect localhost:5000
 * Serving Flask app "terracotta.client" (lazy loading)
 * Environment: production
   WARNING: Do not use the development server in a production environment.
   Use a production WSGI server instead.
 * Debug mode: off
 * Running on http://127.0.0.1:5100/ (Press CTRL+C to quit)

Then open the client page (http://127.0.0.1:5100/ in this case) in your browser.

preview

Development

We gladly accept bug reports and pull requests via GitHub. For your code to be useful, make sure that it is covered by tests and that it satisfies our linting practices (via mypy and flake8).

To run the tests, just install the necessary dependencies via

$ pip install -e .[test]

Then, you can run

$ pytest

from the root of the repository.

More Repositories

1

tsod

Anomaly Detection for time series data
Python
157
star
2

mikeio

Read, write and manipulate dfs0, dfs1, dfs2, dfs3, dfsu and mesh files.
Python
136
star
3

modelskill

Compare results from MIKE and other simulations with measurements
Python
29
star
4

mikeio1d

Read res1d and xns11 files.
Python
24
star
5

DHI-MATLAB-Toolbox

DHI MATLAB Toolbox containing MATLAB scripts for working with DHI files
MATLAB
20
star
6

ifm

Documentation for FEFLOW IFM API (Python Interface)
Jupyter Notebook
17
star
7

datatalks

๐Ÿง‘โ€๐ŸซNotebooks and scripts associated with Data Talks ๐Ÿ“
HTML
11
star
8

Mike1D-SDK-examples

MIKE 1D SDK examples
C#
9
star
9

react-components

This is a share library of react components
TypeScript
9
star
10

MIKECore-Examples

MIKE Core Examples: dfs, pfs, projections.
Batchfile
8
star
11

netcdf-client

This program converts structured grid NetCDF and GRIB2 files with CF convention (http://cfconventions.org) to MIKE DFS files and vice versa.
C#
7
star
12

MIKE-OPERATIONS

Python
7
star
13

mikepluspy

MIKE+Py is the official python interface for MIKE+
Jupyter Notebook
7
star
14

python-package-development

Improving water modelling efficiency with Python package development
Jupyter Notebook
6
star
15

mikecore-python

MIKE Core in Python
Python
5
star
16

Intro_ML_course

Course material for "Introduction to Machine Learning for Water Professionals"
Jupyter Notebook
5
star
17

qgis-res1d-plugin

Python
5
star
18

Arsenal

Shared components & guides monorepo. See the page below for demos.
TypeScript
5
star
19

mikeio-examples

Examples of using MIKE IO
Jupyter Notebook
3
star
20

DHI.Mesh

Library supporting various operations on flexible meshes
C#
3
star
21

book-learn-mikeio-modelskill

Course material for: Python for marine modelers using MIKE IO and ModelSkill
Jupyter Notebook
3
star
22

fmdap

Pre- and post-processing for MIKE FM Data Assimilation
Python
3
star
23

DomainServicesCourse

Course materials for a DHI Domain Services course
C#
3
star
24

matplotlib-styles

Matplotlib Styles for DHI Office Report Template
Jupyter Notebook
2
star
25

jupyter-training-course

Files for the Jupyter Training Course on DHI Campus
Jupyter Notebook
2
star
26

watobs

WatObs - access water observation data
Jupyter Notebook
2
star
27

getting-started-with-mikeio

Course material for: Getting started with dfs files in Python using MIKE IO
Jupyter Notebook
2
star
28

webinars

Notebooks and scripts associated with DHI webinars
Jupyter Notebook
2
star
29

res1d-reader

Reads and resamples multiple Mike1D result files (.res1d)
C#
1
star
30

wgrib

WGRIB is a program to manipulate, inventory and decode GRIB files
C
1
star
31

DomainServicesSample

Sample Domain Services Web API project extended with a custom controller
HTML
1
star
32

jupyter-training

Jupyter Notebooks for training purposes
Jupyter Notebook
1
star
33

pfs2yaml

Convert DHI pfs files to Yaml
Jupyter Notebook
1
star
34

anomalydetection_app

Dash app to explore anomaly detection methods available from the anomalydetection package.
Python
1
star
35

MikeShe

Python code samples using the MIKE SHE API
Python
1
star
36

html-import-updater

๐Ÿ“ฆ CLI tool that updates html imports in your web components (or even Polymer elements).
JavaScript
1
star
37

DHI-React-App

This is DHI react template generator. Built to make creating react app more efficient and faster especially when you are starting new react app project for the first time.
JavaScript
1
star
38

.github

1
star
39

feflow-monitor

A node-red based webservice to monitor the progress of FEFLOW model runs on a website.
1
star
40

mikecloudio

A Python wrapper to access the MIKE Cloud Live REST API
Python
1
star
41

template-python-library

Template for Python library
Python
1
star