meintile package

Module contents

class meintile.Bounds

Bases: tuple

Bounds coordinates in CRS units.

Attributes:
left : float

Alias for field number 0

bottom : float

Alias for field number 1

right : float

Alias for field number 2

top : float

Alias for field number 3

bottom

Alias for field number 1

left

Alias for field number 0

right

Alias for field number 2

top

Alias for field number 3

class meintile.Shape

Bases: tuple

Width and height in pixels.

Attributes:
height : int

Alias for field number 0

width : int

Alias for field number 1

height

Alias for field number 0

width

Alias for field number 1

class meintile.Tile(tile_matrix=None, row=None, col=None)

Bases: object

A Tile is a square somewhere on Earth.

Each Tile can be identified with the zoom, row, column index in a TilePyramid.

Some tile functions can accept a tile buffer in pixels (pixelbuffer). A pixelbuffer value of e.g. 1 will extend the tile boundaries by 1 pixel.

Attributes:
tile_pyramid, tp : meintile.TilePyramid

Parent Tile Pyramid of parent Tile Matrix.

tile_matrix, tm : meintile.TileMatrix

Parent Tile Matrix.

zoom : int

Zoom level / parent Tile Matrix identifier.

row : int

Row within parent Tile Matrix.

col : int

Column within Tile Matrix.

index, id : meintile.TileIndex

Unique tile index.

pixel_x_size : float

Pixel size alongside x axis.

pixel_y_size : float

Pixel size alongside y axis.

bounds : meintile.Bounds

Bounding coordinates of tile

bbox : shapely.geometry.Polygon

Polygon geometry of tile.

left : float

Left coordinate of tile.

bottom : float

Bottom coordinate of tile.

right : float

Right coordinate of tile.

top : float

Top coordinate of tile.

x_size : float

Tile width in CRS units.

y_size : float

Tile height in CRS units.

shape : meintile.Shape

Tile shape in pixels.

height : int

Tile height in pixels.

width : int

Tile width in pixels.

affine : affine.Affine

Affine object to locate tile using rasterio.

get_children(self)

Return tiles from next zoom level.

Returns:
children : list of meintile.Tile
get_neighbors(self, 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:
connectedness : int, (4 or 8)

Return the four direct neighbors or all eight.

Returns:
neighbors : list of meintile.Tile
get_parent(self)

Return tile from previous zoom level.

Returns:
parent : meintile.Tile or None

If no parent is available, None is returned.

class meintile.TileIndex

Bases: tuple

Unique Tile index.

Attributes:
zoom : int

Alias for field number 0

row : int

Alias for field number 1

col : int

Alias for field number 2

col

Alias for field number 2

row

Alias for field number 1

zoom

Alias for field number 0

class meintile.TileMatrix(identifier=None, crs=None, scale_denominator=None, top_left_corner=None, tile_width=None, tile_height=None, matrix_width=None, matrix_height=None, bounds=None, tile_pyramid=None)

Bases: object

A TileMatrix object contains Tiles organized in rows and columns.

Attributes:
identifier : int

Tile matrix identifier.

crs : str or rasterio.crs.CRS

CRS object or reference to one coordinate reference system. (e.g. an OGC URI)

scale_denominator : float

Scale denominator level of this tile matrix. The pixel size of the tile can be obtained from the scaleDenominator by multiplying the later by 0.28 10^-3 / metersPerUnit. If the CRS uses meters as units of measure for the horizontal dimensions, then metersPerUnit=1; if it has degrees, then metersPerUnit=2pa/360 (a is the Earth maximum radius of the ellipsoid).

top_left_corner : tuple or list

Position in CRS coordinates of the top-left corner of this tile matrix.

tile_width : int

Width of each tile of this tile matrix in pixels.

tile_height : int

Height of each tile of this tile matrix in pixels.

width : int

Width of the matrix (number of tiles in width).

height : int

Height of the matrix (number of tiles in height).

pixel_x_size : float

Pixel size alongside x axis.

pixel_y_size : float

Pixel size alongside y axis.

matrix_bounds : meintile.Bounds

Bounding coordinates calculated between given top left corner, matrix shape and tile size. Can extend over CRS bounds.

left : float

Left coordinate of matrix bounds.

bottom : float

Bottom coordinate of matrix bounds.

right : float

Right coordinate of matrix bounds.

top : float

Top coordinate of matrix bounds.

bounds : meintile.Bounds

Minimum bounding rectangle surrounding the tile matrix set, provided while initializing.

tile(self, row=None, col=None)

Return Tile object of this TileMatrix.

Parameters:
row : int

TileMatrix row

col : int

TileMatrix column

Returns:
tile : meintile.Tile
to_dict(self)

Dump configuration ready to be encoded as JSON.

Returns:
dict
class meintile.TileMatrixSet(crs=None, tile_matrix_params=None, is_global=False, identifier=None, title=None, abstract=None, keywords=None, well_known_scale_set=None, bounding_box=None, **kwargs)

Bases: object

A Tile Matrix Set contains TileMatrix objects.

Attributes:
crs : rasterio.crs.CRS

Coordinate reference system used by TileMatrixSet.

tile_matrices : OrderedDict

Keys are TileMatrix identifiers, values are TileMatrix objects.

bounds : meintile.Bounds or None

Bounding box values if bounding_box parameter was provided.

classmethod from_wkss(wkss)

Construct a Tile Matrix Set using a predefined well-known scale set.

Parameters:
wkss : str or dict

Either a WKSS identifier or a WKSS dictionary. Currently available scale sets:

  • EuropeanETRS89_LAEAQuad: Lambert Azimuthal Equal Area ETRS89 for Europe
  • WebMercatorQuad: Google Maps Compatible for the World
  • WorldCRS84Quad: CRS84 for the World
  • WorldMercatorWGS84Quad: World Mercator WGS84 (ellipsoid)
Returns:
TileMatrixSet
items(self)

Return a list of tuples with TileMatrix IDs and TileMatrix objects.

keys(self)

Return TileMatrix identifiers.

matrix_height(self, zoom=None)

Return TileMatrix height (number of rows) at zoom level.

Parameters:
zoom : int

zoom level / TileMatrix identifier

Returns:
matrix height : int
matrix_width(self, zoom=None)

Return TileMatrix height (number of rows) at zoom level.

Parameters:
zoom : int

zoom level / TileMatrix identifier

Returns:
matrix width : int
pixel_x_size(self, zoom)

Return pixel size at the x-axis at zoom level in CRS units.

Parameters:
zoom : int

zoom level / TileMatrix identifier

Returns:
pixel_x_size : float
pixel_y_size(self, zoom)

Return pixel size at the y-axis at zoom level in CRS units.

Parameters:
zoom : int

zoom level / TileMatrix identifier

Returns:
pixel_y_size : float
tile(self, zoom=None, row=None, col=None)

Return Tile object of this TilePyramid.

Parameters:
zoom : int

zoom level / TileMatrix identifier

row : int

TileMatrix row

col : int

TileMatrix column

Returns:
tile : meintile.Tile
to_dict(self)

Dump configuration ready to be encoded as JSON.

Returns:
dict
values(self)

Return TileMatrix objects.

class meintile.TilePyramid(**kwargs)

Bases: meintile._tilepyramid.TileMatrixSet

A Tile Pyramid is a subset of a Tile Matrix Set.

Tile Matrix Sets consist of Tile Matrices with arbitrary properties. In a Tile Pyramid the Tile Matrices are ordered, and their shape and pixel sizes increase by a factor of 2. Tile Pyramids resemble the image pyramid structure used by many image formats.

Attributes:
crs : rasterio.crs.CRS

Coordinate reference system used by TileMatrixSet.

tile_matrices : OrderedDict

Keys are TileMatrix identifiers, values are TileMatrix objects.

bounds : meintile.Bounds or None

Bounding box values if bounding_box parameter was provided.

classmethod from_wkss(wkss)

Construct a Tile Pyramid using a predefined well-known scale set.

Parameters:
wkss : str or dict

Either a WKSS identifier or a WKSS dictionary. Currently available scale sets:

  • EuropeanETRS89_LAEAQuad: Lambert Azimuthal Equal Area ETRS89 for Europe
  • WebMercatorQuad: Google Maps Compatible for the World
  • WorldCRS84Quad: CRS84 for the World
  • WorldMercatorWGS84Quad: World Mercator WGS84 (ellipsoid)
Returns:
TilePyramid