rio-tiler

User friendly Rasterio plugin to read raster datasets.

rio-tiler was initialy designed to create slippy map
tiles
from large raster data
sources and render these tiles dynamically on a web map. With rio-tiler v2.0 we added many more helper methods to read
data and metadata from any raster source supported by Rasterio/GDAL.
This includes local files and via HTTP, AWS S3, Google Cloud Storage,
etc.

At the low level, rio-tiler is just a wrapper around the rasterio.vrt.WarpedVRT class, which can be useful for doing reprojection and/or property overriding (e.g nodata value).

Features

  • Read any dataset supported by GDAL/Rasterio

    from rio_tiler.io import COGReader
    
    with COGReader("my.tif") as image:
        print(image.dataset)  # rasterio opened dataset
        img = image.read()    # similar to rasterio.open("my.tif").read() but returns a rio_tiler.models.ImageData object
    
  • User friendly tile, part, feature, point reading methods

    from rio_tiler.io import COGReader
    
    with COGReader("my.tif") as image:
        img = image.tile(x, y, z)            # read mercator tile z-x-y
        img = image.part(bbox)               # read the data intersecting a bounding box
        img = image.feature(geojson_feature) # read the data intersecting a geojson feature
        img = image.point(lon,lat)           # get pixel values for a lon/lat coordinates
    
  • Enable property assignement (e.g nodata) on data reading

    from rio_tiler.io import COGReader
    
    with COGReader("my.tif") as image:
        img = image.tile(x, y, z, nodata=-9999) # read mercator tile z-x-y
    
  • STAC support

    from rio_tiler.io import STACReader
    
    with STACReader("item.json") as stac:
        print(stac.assets)  # available asset
        img = stac.tile(x, y, z, assets="asset1", indexes=(1, 2, 3))  # read tile for asset1 and indexes 1,2,3
        img = stac.tile(x, y, z, assets=("asset1", "asset2", "asset3",), indexes=(1,))  # create an image from assets 1,2,3 using their first band
    
  • Mosaic (merging or stacking)

    from rio_tiler.io import COGReader
    from rio_tiler.mosaic import mosaic_reader
    
    def reader(file, x, y, z, **kwargs):
        with COGReader("my.tif") as image:
            return image.tile(x, y, z, **kwargs)
    
    img, assets = mosaic_reader(["image1.tif", "image2.tif"], reader, x, y, z)
    
  • Native support for multiple TileMatrixSet via morecantile

    import morecantile
    from rio_tiler.io import COGReader
    
    # Use EPSG:4326 (WGS84) grid
    wgs84_grid = morecantile.tms.get("WorldCRS84Quad")
    with COGReader("my.tif", tms=wgs84_grid) as cog:
        img = cog.tile(1, 1, 1)
    

GitHub

https://github.com/cogeotiff/rio-tiler