Skip to main content

Create rasters from global tiles

Project description

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

In order to easily manage dependencies, we recommend using dedicated project environments via Anaconda/Miniconda or Python virtual environments.

You can install the package with conda/mamba using:

mamba install tile_mate

or

pip install tile-mate

Alternatively, you can clone the repository and manage the environment using the environment.yml file provided.

  1. mamba env update -f environment.yml
  2. Activate the environment conda activate tile-mate
  3. Install the library with pip via pip install tile-mate.

For development, use pip with -e (editable) mode:

python -m pip install -e .

Python 3.9+ 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 and associated linting packages to ensure some basic code quality (see the environment.yml). 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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tile_mate-0.0.15.tar.gz (6.0 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tile_mate-0.0.15-py3-none-any.whl (4.4 MB view details)

Uploaded Python 3

File details

Details for the file tile_mate-0.0.15.tar.gz.

File metadata

  • Download URL: tile_mate-0.0.15.tar.gz
  • Upload date:
  • Size: 6.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for tile_mate-0.0.15.tar.gz
Algorithm Hash digest
SHA256 88621036341f843921f96aef00dcebc690746b018351e19464156276c8a96c5a
MD5 97f16ffdcfbfa955bccf63c3e800ccff
BLAKE2b-256 9eebeaf995c08f95513638fb0f4ae32231af4cae813a279ea6b84cea14c3fda5

See more details on using hashes here.

File details

Details for the file tile_mate-0.0.15-py3-none-any.whl.

File metadata

  • Download URL: tile_mate-0.0.15-py3-none-any.whl
  • Upload date:
  • Size: 4.4 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for tile_mate-0.0.15-py3-none-any.whl
Algorithm Hash digest
SHA256 402eeea42bcc115d11d0bc771e71e6869473e4710376c2fb005836399a5f9078
MD5 4c28cbb2c9e57b6b3a575783ed1ef133
BLAKE2b-256 ac41970dc3530f7921a0413e0b1f78bcf42a97ab14161126c82985007c14c345

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page