The two base classes are TilePyramid
which defines tile matrices in various zoom levels and its members, theTile
objects. TilePyramid
TilePyramid(grid_definition, tile_size=256)
-
grid_definition
: Either one of the predefined grids (geodetic
ormercator
) or a custom grid definition in form of a dictionary. For example:{ "shape": (1, 1), "bounds": (2426378.0132, 1528101.2618, 6293974.6215, 5395697.8701), "is_global": False, "epsg": 3035 }
shape
(height, width): Indicates the number of tiles per column and row at zoom level 0.bounds
(left, bottom, right, top): Units are CRS units.
Please note that the aspect ratios of
shape
andbounds
have to be the same.- Alternatively to
epsg
, a customproj
string can be used:
"proj": """ +proj=ortho +lat_0=-90 +lon_0=0 +x_0=0 +y_0=0 +ellps=WGS84 +units=m +no_defs """
is_global
: Indicates whether the grid covers the whole globe or just a region.
-
tile_size
: Optional, specifies the target resolution of each tile (i.e. each tile will have 256x256 px). Default is256
.
type
: The projection it was initialized with (geodetic
,mercator
orcustom
).tile_size
: The pixelsize per tile it was initialized with (default256
).left
: Left boundary of tile matrix.top
: Top boundary of tile matrix.right
: Right boundary of tile matrix.bottom
: Bottom boundary of tile matrix.x_size
: Horizontal size of tile matrix in map coordinates.y_size
: Vertical size of tile matrix in map coordinates.crs
:rasterio.crs.CRS()
object.srid
: Spatial reference ID (EPSG code) if available, elseNone
.
matrix_width(zoom)
: Returns the number of columns in the current tile matrix.zoom
: Zoom level.
matrix_height(zoom)
: Returns the number of rows in the current tile matrix.zoom
: Zoom level.
tile_x_size(zoom)
: Returns a float, indicating the width of each tile at this zoom level inTilePyramid
CRS units.zoom
: Zoom level.
tile_y_size(zoom)
: Returns a floats, indicating the height of each tile at this zoom level inTilePyramid
CRS units.zoom
: Zoom level.
pixel_x_size(zoom)
: Returns a float, indicating the vertical pixel size inTilePyramid
CRS units.zoom
: Zoom level.
pixel_y_size(zoom)
: Returns a float, indicating the horizontal pixel size inTilePyramid
CRS units.zoom
: Zoom level.
top_left_tile_coords(zoom, row, col)
: Returns a tuple of two floats, indicating the top left coordinates of the given tile.zoom
: Zoom level.row
: Row inTilePyramid
.col
: Column inTilePyramid
.
tile_bounds(zoom, row, col, pixelbuffer=None)
: Returnsleft
,bottom
,right
,top
coordinates of given tile.zoom
: Zoom level.row
: Row inTilePyramid
.col
: Column inTilePyramid
.pixelbuffer
: Optional buffer around tile boundaries in pixels.
tile_bbox(zoom, row, col, pixelbuffer=None)
: Returns the bounding box for given tile as aPolygon
.zoom
: Zoom level.row
: Row inTilePyramid
.col
: Column inTilePyramid
.pixelbuffer
: Optional buffer around tile boundaries in pixels.
intersecting(tile)
: Return all tiles intersecting with tile. This helps translating between TilePyramids with different metatiling settings.tile
:Tile
object.
tiles_from_bbox(geometry, zoom)
: Returns tiles intersecting with the given bounding box at given zoom level.geometry
: Must be aPolygon
object.zoom
: Zoom level.
tiles_from_geom(geometry, zoom)
: Returns tiles intersecting with the given geometry at given zoom level.geometry
: Must be one out ofPolygon
,MultiPolygon
,LineString
,MultiLineString
,Point
,MultiPoint
.zoom
: Zoom level.
Tile(tile_pyramid, zoom, row, col)
tile_pyramid
: ATilePyramid
this Tile belongs to.zoom
: Tile zoom level.row
: Tile row.col
: Tile column.
After initializing, the object has the following properties:
tile_pyramid
ortp
:TilePyramid
this Tile belongs to.crs
:rasterio.crs.CRS()
object.srid
: Spatial reference ID (EPSG code) if available, elseNone
.zoom
: Zoom.row
: Row.col
: Col.x_size
: Horizontal size in SRID units.y_size
: Vertical size in SRID units.index
orid
: Tuple of(zoom, col, row)
pixel_x_size
: Horizontal pixel size in SRID units.pixel_y_size
: Vertical pixel size in SRID units.left
: Left coordinate.top
: Top coordinate.right
: Right coordinate.bottom
: Bottom coordinate.width
: Horizontal size in pixels.height
: Vertical size in pixels.
get_parent()
: Returns parent Tile.get_children()
: Returns children Tiles.get_neighbors(connectedness=8)
: Returns a maximum of 8 valid neighbor Tiles.connectedness
:4
or8
. Direct neighbors (up to 4) or corner neighbors (up to 8).
intersecting(TilePyramid)
: Return all tiles from other TilePyramid intersecting with tile. This helps translating between TilePyramids with different metatiling settings.tilepyramid
:TilePyramid
object.
bounds(pixelbuffer=0)
: Returns a tuple of(left, bottom, right, top)
coordinates.pixelbuffer
: Optional buffer around tile boundaries in pixels.
bbox(pixelbuffer=0)
: Returns aPolygon
geometry.pixelbuffer
: Optional buffer around tile boundaries in pixels.
affine(pixelbuffer=0)
: Returns anAffine
object.pixelbuffer
: Optional buffer around tile boundaries in pixels.
shape(pixelbuffer=0)
: Returns a tuple with(height, width)
.pixelbuffer
: Optional buffer around tile boundaries in pixels.
is_valid()
: ReturnsTrue
if tile ID is valid in this tile matrix andFalse
if it isn't.