tile

class gridkit.tile.Tile(grid: BaseGrid, start_id: Tuple[int, int] | GridIndex, nx: int, ny: int)[source]

Bases: object

A Tile describes a set of cells defined by the start_id, which is the cell that defines the bottom-left corner of the tile, and nx and ny, which are the number of cells in the x and y directions, respectively.

Each tile is associated with a particular grid and the Tile refers to a selection of grid indices on that grid. The associated grid can be accessed using the .grid property.

Note

nx and ny can be seen as ‘right’ and ‘up’, respectively, when the rotation of the grid is zero. If the grid is rotated, the tile rotates with it (naturally). This means that for a grid that is rotated 90 degrees, nx refers to the number of cells up, and ny refers to the number of cells to the left.

Init parameters

grid: BaseGrid

The TriGrid, RectGrid or HexGrid the tile is associated with

start_id: Union[Tuple[int, int], GridIndex]

The starting cell of the Tile. The starting cell defines the bottom-left corner of the Tile if the associated grid is not rotated.

nx: int

The number of cells in x direction, starting from the start_id

ny: int

The number of cells in y direction, starting from the start_id

property start_id

The starting cell of the Tile. The starting cell defines the bottom-left corner of the Tile if the associated grid is not rotated.

property nx

The number of cells in x direction, starting from the start_id

property ny

The number of cells in y direction, starting from the start_id

corner_ids()[source]

The ids at the corners of the Tile

Returns:

The GridIndex that contains the ids of the cells at the corners of the Tile in order: top-left, top-right, bottom-right, bottom-left (assuming the assicaited grid is not rotated)

Return type:

GridIndex

corners()[source]

The coordinates at the corners of the Tile

Returns:

A two-dimensional array that contais the x and y coordinates of the corners in order: top-left, top-right, bottom-right, bottom-left (assuming the assicaited grid is not rotated)

Return type:

numpy.ndarray

property indices

The ids of all cells in the Tile.

Returns:

The GridIndex that contains the indices in the Tile

Return type:

GridIndex

property bounds: Tuple[float, float, float, float]

The bounding box of the Tile in (xmin, ymin, xmax, ymax). If the associated grid is rotated, the this represents the bounding box that fully encapsulates the Tile and will contain more area than is covered by the rotated Tile.

Returns:

The bounding box in (xmin, ymin, xmax, ymax)

Return type:

Tuple[float, float, float, float]