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
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.
- Define grid system
import morecantile
from rasterio.crs import CRS
# Use default TMS
tms = morecantile.tms.get("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)
- 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.tms.get("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.tms.get("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.tms.get("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.tms.get("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
Release history Release notifications | RSS feed
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.1.tar.gz
(5.0 kB
view details)
File details
Details for the file rio-tiler-crs-1.0.1.tar.gz
.
File metadata
- Download URL: rio-tiler-crs-1.0.1.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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 66ca26de5690bf4b0c3edc596f9e06d497273192d5d4a15ce00e191f60d18177 |
|
MD5 | ee3b929e705be3995055e43749411e64 |
|
BLAKE2b-256 | 0839b2e208a56d136badcb01e7510f0714c0cb878c681129cd92120d388e1d51 |