Skip to main content

tile-mate

PyPI license PyPI pyversions PyPI version Conda version Conda platforms

This library provides a tool to create continuous rasters of publicly available, global tile sets (in lat/lon) such as Pekel Occurence and ESA 10 m land cover. This is a simpler cousin of dem-stitcher without the need for basic post-processing (e.g. fractional pixel translation and vertical datum transformations).

The API can be summarized as

from tile_mate import get_raster_from_tiles

bounds = [-120.55, 34.85, -120.25, 35.15]
X, p = get_raster_from_tiles(bounds, tile_shortname='esa_world_cover_2021')

# X is an c x m x n numpy array, where c is the number of channels specified by rasterio `count` metadata
# p is a dictionary (or a rasterio profile) including relevant GIS metadata; CRS is assumed to be epsg:4326

The rasters are returned in the global lat/lon projection epsg:4326 and the API assumes that bounds are supplied in this format.

import rasterio

with rasterio.open('esa_world_cover_2021_subset.tif', 'w', **p) as ds:
   ds.write(X)

Installation

Pixi (recommended for development)

Install pixi, then:

git clone https://github.com/OPERA-Cal-Val/tile-mate.git
cd tile-mate
pixi install
pixi run python -c "import tile_mate"

pixi install creates the default environment (the newest supported python) with tile_mate already installed in editable mode.

For JupyterLab (with jupyter-collaboration for real-time collaborative editing):

pixi run jupyter lab

Common tasks:

pixi run test     # pytest tests
pixi run lint     # ruff check
pixi run format   # ruff format

The py311, py312, py313, and py314 environments exist for the CI matrix and are built on demand, e.g. pixi run -e py311 pytest tests (reclaim it afterwards with pixi clean -e py311).

Conda-forge / PyPI

You can install the released package with conda/mamba using:

mamba install tile_mate

or

pip install tile-mate

Python 3.11+ is supported.

Notebooks

We have notebooks to demonstrate common usage:

Datasets Supported

There are numerous tile sets. There are keyword arguments for many of the tiles. For example, for hansen_annual_mosaic the years 2013-2022 can be specified. The easiest way to see what is possible is to look at the Basic Demo. The datasets supported are:

In [1]: from tile_mate.stitcher import DATASET_SHORTNAMES

In [2]: DATASET_SHORTNAMES
Out[2]: 'pekel_water_occ_2021',
 'esa_world_cover_2020',
 'esa_world_cover_2021',
 'hansen_annual_mosaic',
 'hansen_lossyear',
 'hansen_gain',
 'hansen_treecover_2000',
 's1_coherence_2020',
 'radd_deforestation_alerts_2022',
 'hand',
 'glad_landcover',
 'glad_change'

More information about these datasets can be found below

See these notebooks to see how these tiles are generated and organized. Feel free to open a issue ticket or PR if there are modifications or new tilesets you would like to see.

Dateline/antimeridian support

We support a single dateline crossing (crossing +/- 180 longitude) within get_raster_from_tiles using in-memory translation of tiles (same as dem-stitcher's functionality). We "wrap" tiles across this dateline crossing. We assume that the supplied bounds/extent overlap the standard lat/lon CRS grid i.e. longitudes between -/+ 180 longitude and are within -/+ 90 latitude, where a buffer around the dateline (longitude axis or $x$-axis). Wrapping tiles around the North and South poles (i.e. at -/+ 90 latitude) is not supported (a different CRS is what's required) and an exception will be raised.

Contributing

We welcome contributions to this open-source package. To do so:

  1. Create an GitHub issue ticket desrcribing what changes you need (e.g. issue-1)
  2. Fork this repo
  3. Make your modifications in your own fork
  4. Make a pull-request (PR) in this repo with the code in your fork and tag the repo owner or a relevant contributor.

We use ruff to ensure some basic code quality (pixi run lint and pixi run format). These will be checked for each commit in a PR. Try to write tests wherever possible.

Support

  1. Create an GitHub issue ticket desrcribing what changes you would like to see or to report a bug.
  2. We will work on solving this issue (hopefully with you).

Acknowledgements

This tool was developed to support OPERA.

Metadata

Release files for tile-mate 0.0.16

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tile-mate 0.0.16
File Size Uploaded
tile_mate-0.0.16.tar.gz 6.1 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for tile-mate 0.0.16
File Interpreter ABI Platform
tile_mate-0.0.16-py3-none-any.whl Python 3 none any Details

Total release size: 10.6 MB

Release files / tile_mate-0.0.16.tar.gz

Download URL tile_mate-0.0.16.tar.gz
Size 6.1 MB
Tags Source
SHA-256 checksum
How to use checksums
7a30361c36583906330d61237139c0fa775b4367d1bfeee08ab54cad90e90d75
BLAKE2b-256 checksum
How to use checksums
f7f0b293f3dc0bf335823f04cc9167eacb4022db598683d173cb2ecb5f33c2d9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / tile_mate-0.0.16-py3-none-any.whl

Download URL tile_mate-0.0.16-py3-none-any.whl
Size 4.4 MB
Tags Python 3
SHA-256 checksum
How to use checksums
81d3c9bad973cffeb6bcf4e143dbc95d8f2e6d957980a67284920ac9e7f815a0
BLAKE2b-256 checksum
How to use checksums
242813e251ab9e272087cb0a32ead02650f93341b1b885b2d83f9c5854681cfe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release history Release notifications | RSS feed

This release

0.0.16 This release

2 release files

0.0.15

2 release files

0.0.11

2 release files

0.0.10

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page