Skip to main content

A rio-tiler plugin to create tile for arbitraty grid

Project description

rio-tiler-crs

A rio-tiler plugin to create tiles in different projection

Packaging status CircleCI codecov

Install

$ pip install pip -U
$ pip install rio-tiler-crs

# Or using source

$ pip install git+http://github.com/cogeotiff/rio-tiler-crs

How To

rio-tiler-crs uses morecantile to define the custom tiling grid schema.

  1. Define grid system
import morecantile
from rasterio.crs import CRS

# Use default TMS
tms = morecantile.TileMatrixSet.load("WorldCRS84Quad")

# or create a custom TMS
crs = CRS.from_epsg(3031)  # Morecantile TileMatrixSet uses Rasterio CRS object
extent = [-948.75, -543592.47, 5817.41, -3333128.95]  # From https:///epsg.io/3031
tms = morecantile.TileMatrixSet(extent, crs)
  1. read tile
from rio_tiler_crs import tiler

# Read tile x=10, y=10, z=4
tile, mask = tiler.tile("myfile.tif", 10, 10, 4, tms=tms)

API

  • rio_tiler_crs.tiler.get_zoom: Get Min/Max zoom for a specific Raster in a specific TMS system
tms = morecantile.TileMatrixSet.load("WorldCRS84Quad")
with rasterio.open("myfile.tif") as src_dst:
    minzoom, maxzoom = tiler.get_zoom(src_dst, tms)
  • rio_tiler_crs.tiler.spatial_info: Return Raster spatial info for a specific TMS system
tms = morecantile.TileMatrixSet.load("WorldCRS84Quad")
tiler.spatial_info("myfile.tif", tms)
{
    "address": "myfile.tif",
    "bounds": List[float],  # raster bounds in tms's CRS
    "center": Tuple[float, float, int],  # raster center in tms's CRS
    "minzoom": int,  # raster minzoom in tms
    "maxzoom": int,  # raster maxzoom in tms

}
  • rio_tiler_crs.tiler.bounds: Return Raster bounds for a specific CRS
dst_crs = CRS.from_epsg(3031)
tiler.bounds("myfile.tif", dst_crs)

{
    "address": "myfile.tif",
    "bounds": List[float],  # raster bounds in dst_crs
}
  • rio_tiler_crs.tiler.metadata: same as rio_tiler.io.cogeo.metadata

  • rio_tiler_crs.tiler.info: Return simple metadata about the raster

tms = morecantile.TileMatrixSet.load("WorldCRS84Quad")
tiler.info("myfile.tif", tms)

{
    "address": "myfile.tif",
    "bounds": List[float],  # raster bounds in tms's CRS
    "center": Tuple[float, float, int],  # raster center in tms's CRS
    "minzoom": int,  # raster minzoom in tms
    "maxzoom": int,  # raster maxzoom in tms
    "band_metadata": List[Tulple[int, Dict]],  # List of band tags
    "band_descriptions": List[str],  # List of band names
    "dtype": str,  # raster datatype
    "colorinterp": List[str],  # List of band colorinterpretation values
    "nodata_type": str,  # raster io nodata type
    "scale": float,  # raster scaling factor
    "offset": float,  # raster offset factor
    "cmap":  Dict,  # raster internal colormap
}
  • rio_tiler_crs.tiler.tile: Return map tile from a raster
tms = morecantile.TileMatrixSet.load("WorldCRS84Quad")
tile, mask = tiler.tile("myfile.tif", 1, 2, 3, 256, tms)

Example

See /demo

Contribution & Development

Issues and pull requests are more than welcome.

dev install

$ git clone https://github.com/cogeotiff/rio-tiler-crs.git
$ cd rio-tiler-crs
$ pip install -e .[dev]

Python >=3.7 only

This repo is set to use pre-commit to run isort, flake8, pydocstring, black ("uncompromising Python code formatter") and mypy when committing new code.

$ pre-commit install

$ git add .

$ git commit -m'my change'
isort....................................................................Passed
black....................................................................Passed
Flake8...................................................................Passed
Verifying PEP257 Compliance..............................................Passed
mypy.....................................................................Passed

$ git push origin

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

rio-tiler-crs-1.0.0.tar.gz (5.0 kB view details)

Uploaded Source

File details

Details for the file rio-tiler-crs-1.0.0.tar.gz.

File metadata

  • Download URL: rio-tiler-crs-1.0.0.tar.gz
  • Upload date:
  • Size: 5.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.2

File hashes

Hashes for rio-tiler-crs-1.0.0.tar.gz
Algorithm Hash digest
SHA256 acf9f22e8e7dcb6f1252eb02ca3d330122c92593b41254c0486fb6f0d674e316
MD5 0ebfd9135980f891060cbd5612cc3a81
BLAKE2b-256 650d4e7cf1069ce982ecef8ab2a404a6fab5feabb394fbd6391c2d781e3a6ae8

See more details on using hashes here.

Supported by

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