Skip to content

async_geotiff.Array

async_geotiff.Array dataclass

Bases: TransformMixin

An array representation of data from a GeoTIFF.

count instance-attribute

count: int

The number of bands in the array.

crs instance-attribute

crs: CRS

The coordinate reference system of the array.

data instance-attribute

data: NDArray

The array data with shape (bands, height, width).

height instance-attribute

height: int

The height of the array in pixels.

mask instance-attribute

mask: NDArray[bool_] | None

The mask array with shape (height, width), if any.

Values of True indicate valid data; False indicates no data.

transform instance-attribute

transform: Affine

The affine transform mapping pixel coordinates to geographic coordinates.

width instance-attribute

width: int

The width of the array in pixels.

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:

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: