Skip to content

async_geotiff.GeoTIFF

async_geotiff.GeoTIFF dataclass

Bases: FetchTileMixin, TransformMixin

A class representing a GeoTIFF image.

block_shapes property

block_shapes: list[tuple[int, int]]

An ordered list of block shapes for each bands.

Shapes are tuples and have the same ordering as the dataset's shape:

  • (count of image rows, count of image columns).

bounds cached property

bounds: tuple[float, float, float, float]

Return the bounds of the dataset in the units of its CRS.

Returns:

colorinterp property

colorinterp: list[str]

The color interpretation of each band in index order.

compression property

compression: Compression

The compression algorithm used for the dataset.

count property

count: int

The number of raster bands in the full image.

crs property

crs: CRS

The dataset's coordinate reference system.

dtypes property

dtypes: list[str]

The data types of each band in index order.

height property

height: int

The height (number of rows) of the full image.

interleaving property

interleaving: Interleaving

The interleaving scheme of the dataset.

is_tiled property

is_tiled: bool

Check if the dataset is tiled.

nodata property

nodata: float | None

The dataset's single nodata value.

overviews property

overviews: list[Overview]

A list of overview levels for the dataset.

photometric property

photometric: PhotometricInterpretation | None

The photometric interpretation of the dataset.

res property

res: tuple[float, float]

Return the (width, height) of pixels in the units of its CRS.

shape property

shape: tuple[int, int]

Get the shape (height, width) of the full image.

tile_height property

tile_height: int

The height in pixels per tile of the image.

tile_width property

tile_width: int

The width in pixels per tile of the image.

transform property

transform: Affine

Return the dataset's georeferencing transformation matrix.

This transform maps pixel row/column coordinates to coordinates in the dataset's CRS.

width property

width: int

The width (number of columns) of the full image.

__init__

__init__(tiff: TIFF) -> None

Create a GeoTIFF from an existing TIFF instance.

block_size

block_size(bidx: int, i: int, j: int) -> int

Return the size in bytes of a particular block.

Parameters:

  • bidx (int) –

    Band index, starting with 1.

  • i (int) –

    Row index of the block, starting with 0.

  • j (int) –

    Column index of the block, starting with 0.

colormap

colormap(bidx: int) -> dict[int, tuple[int, int, int]]

Return a dict containing the colormap for a band.

Parameters:

  • bidx (int) –

    The 1-based index of the band whose colormap will be returned.

Returns:

Raises:

  • ValueError

    If no colormap is found for the specified band (NULL color table).

  • IndexError

    If no band exists for the provided index.

fetch_tiles async

fetch_tiles(xs: list[int], ys: list[int]) -> list[Array]

Fetch multiple tiles from this overview.

Parameters:

  • xs (list[int]) –

    The x coordinates of the tiles.

  • ys (list[int]) –

    The y coordinates of the tiles.

index

index(
    x: float, y: float, op: Callable[[float], int] = floor
) -> tuple[int, int]

Get the (row, col) index of the pixel containing (x, y).

Parameters:

  • x (float) –

    x value in coordinate reference system.

  • y (float) –

    y value in coordinate reference system.

  • op (Callable[[float], int], default: floor ) –

    Function to convert fractional pixels to whole numbers (floor, ceiling, round). Defaults to math.floor.

Returns:

indexes

indexes() -> list[int]

Return the 1-based indexes of each band in the dataset.

For a 3-band dataset, this property will be [1, 2, 3].

open async classmethod

open(
    path: str,
    *,
    store: ObjectStore | ObspecInput,
    prefetch: int = 32768,
    multiplier: float = 2.0
) -> Self

Open a new GeoTIFF.

Parameters:

  • path (str) –

    The path within the store to read from.

  • store (ObjectStore | ObspecInput) –

    The backend to use for data fetching.

  • prefetch (int, default: 32768 ) –

    The number of initial bytes to read up front.

  • multiplier (float, default: 2.0 ) –

    The multiplier to use for readahead size growth. Must be greater than 1.0. For example, for a value of 2.0, the first metadata read will be of size prefetch, and then the next read will be of size prefetch * 2.

Returns:

  • Self

    A TIFF instance.

xy

xy(
    row: int,
    col: int,
    offset: Literal["center", "ul", "ur", "ll", "lr"] = "center",
) -> tuple[float, float]

Get the coordinates (x, y) of a pixel at (row, col).

The pixel's center is returned by default, but a corner can be returned by setting offset to one of "ul", "ur", "ll", "lr".

Parameters:

  • row (int) –

    Pixel row.

  • col (int) –

    Pixel column.

  • offset (Literal['center', 'ul', 'ur', 'll', 'lr'], default: 'center' ) –

    Determines if the returned coordinates are for the center of the pixel or for a corner.

Returns: