Skip to content

Instantly share code, notes, and snippets.

@vincentsarago
Created February 1, 2021 21:21
Show Gist options
  • Save vincentsarago/a4877c281febc357259f9c2464017a67 to your computer and use it in GitHub Desktop.
Save vincentsarago/a4877c281febc357259f9c2464017a67 to your computer and use it in GitHub Desktop.
from rio_tiler.io import COGReader
with COGReader("my-tif.tif") as cog:
# get info
info = cog.info()
# get image statistics
stats = cog.stats()
# get metadata (info + image statistics)
meta = cog.metadata()
# Read data for a mercator tile
tile = cog.tile(tile_x, tile_y, tile_zoom, tilesize=256)
# Read part of a data for a given bbox (size is maxed out to 1024)
aoi = cog.part([minx, miny, maxx, maxy])
# Read data for a given geojson polygon (size is maxed out to 1024)
feat = cog.feature(geojson_feature)
# Get a preview (size is maxed out to 1024)
preview = cog.preview()
# Get pixel values for a given lon/lat coordinate
values = cog.point(lon, lat)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment