mapchete.tile module

Mapchtete handling tiles.

class mapchete.tile.BufferedTile(*args: Any, **kwargs: Any)

Bases: Tile

A special tile with fixed pixelbuffer.

Parameters:
tileTile
pixelbufferinteger

tile buffer in pixels

Attributes:
heightinteger

tile height in pixels

widthinteger

tile width in pixels

shapetuple

tile width and height in pixels

affineAffine

Affine object describing tile extent and pixel size

boundstuple

left, bottom, right, top values of tile boundaries

bboxshapely.geometry

tile bounding box as shapely geometry

pixelbufferinteger

pixelbuffer used to create tile

profiledictionary

rasterio metadata profile

property affine

Return buffered Affine.

property bbox

Return buffered bounding box.

property bottom
property bounds

Return buffered bounds.

get_children()

Get tile children (intersecting tiles in next zoom level).

Returns:
childrenlist

a list of BufferedTiles

get_neighbors(connectedness=8)

Return tile neighbors.

Tile neighbors are unique, i.e. in some edge cases, where both the left and right neighbor wrapped around the antimeridian is the same. Also, neighbors ouside the northern and southern TilePyramid boundaries are excluded, because they are invalid.

# ————- # | 8 | 1 | 5 | # ————- # | 4 | x | 2 | # ————- # | 7 | 3 | 6 | # ————-

Parameters:
connectednessint

[4 or 8] return four direct neighbors or all eight.

Returns:
list of BufferedTiles
get_parent()

Get tile parent (intersecting tile in previous zoom level).

Returns:
parentBufferedTile
property height

Return buffered height.

is_on_edge()

Determine whether tile touches or goes over pyramid edge.

property left
property right
property shape

Return buffered shape.

property top
property transform

Return buffered Affine.

property width

Return buffered width.

class mapchete.tile.BufferedTilePyramid(*args: Any, **kwargs: Any)

Bases: TilePyramid

A special tile pyramid with fixed pixelbuffer and metatiling.

Parameters:
pyramid_typestring

pyramid projection type (geodetic or mercator)

metatilinginteger

metatile size (default: 1)

pixelbufferinteger

buffer around tiles in pixel (default: 0)

Attributes:
tile_pyramidTilePyramid

underlying TilePyramid

metatilinginteger

metatile size

pixelbufferinteger

tile buffer size in pixels

static from_dict(config_dict)

Initialize TilePyramid from configuration dictionary.

intersecting(tile)

Return all BufferedTiles intersecting with tile.

Parameters:
tileBufferedTile

another tile

matrix_affine(zoom)

Return Affine object for zoom level assuming tiles are cells.

Parameters:
zoominteger

zoom level

tile(zoom, row, col)

Return BufferedTile object of this BufferedTilePyramid.

Parameters:
zoominteger

zoom level

rowinteger

tile matrix row

colinteger

tile matrix column

Returns:
buffered tileBufferedTile
tiles_from_bbox(geometry, zoom=None, batch_by=None)

All metatiles intersecting with given bounding box.

Parameters:
geometryshapely.geometry
zoominteger

zoom level

Yields:
intersecting tilesgenerator

generates BufferedTiles

tiles_from_bounds(bounds=None, zoom=None, batch_by=None)

Return all tiles intersecting with bounds.

Bounds values will be cleaned if they cross the antimeridian or are outside of the Northern or Southern tile pyramid bounds.

Parameters:
boundstuple

(left, bottom, right, top) bounding values in tile pyramid CRS

zoominteger

zoom level

Yields:
intersecting tilesgenerator

generates BufferedTiles

tiles_from_geom(geometry, zoom=None, batch_by=None, exact=False)

Return all tiles intersecting with input geometry.

Parameters:
geometryshapely.geometry
zoominteger

zoom level

Yields:
intersecting tilesBufferedTile
to_dict()

Return dictionary representation of pyramid parameters.

without_pixelbuffer() BufferedTilePyramid
mapchete.tile.count_tiles(geometry, pyramid, minzoom, maxzoom, init_zoom=0, rasterize_threshold=0)

Count number of tiles intersecting with geometry.

Parameters:
geometryshapely geometry
pyramidTilePyramid
minzoomint
maxzoomint
init_zoomint
Returns:
number of tiles
mapchete.tile.snap_geometry_to_tiles(geometry=None, pyramid=None, zoom=None)