Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/api/geotiff.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# GeoTIFF

::: async_geotiff.GeoTIFF
::: async_geotiff.Store
3 changes: 2 additions & 1 deletion src/async_geotiff/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from . import exceptions, utils
from ._array import RasterArray
from ._gdal_metadata import BandStatistics
from ._geotiff import GeoTIFF
from ._geotiff import GeoTIFF, Store
from ._overview import Overview
from ._tile import Tile
from ._transform import BoundingBox
Expand All @@ -19,6 +19,7 @@
"GeoTIFF",
"Overview",
"RasterArray",
"Store",
"Tile",
"Window",
"__version__",
Expand Down
17 changes: 13 additions & 4 deletions src/async_geotiff/_geotiff.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import warnings
from dataclasses import dataclass, field
from types import MappingProxyType
from typing import TYPE_CHECKING, Self
from typing import TYPE_CHECKING, Protocol, Self

import numpy as np
from async_tiff import TIFF
Expand All @@ -15,6 +15,7 @@
PlanarConfiguration,
SampleFormat,
)
from obspec import GetRangeAsync, GetRangesAsync

from async_geotiff._colorinterp import infer_color_interpretation
from async_geotiff._crs import crs_from_geo_keys
Expand All @@ -40,10 +41,18 @@
from collections.abc import Mapping

from affine import Affine
from async_tiff import GeoKeyDirectory, ImageFileDirectory, ObspecInput
from async_tiff import GeoKeyDirectory, ImageFileDirectory
from pyproj.crs import CRS


class Store(GetRangeAsync, GetRangesAsync, Protocol):
"""Supported input to `store` param of `GeoTIFF.open`.

Anything that implements [GetRangeAsync][obspec.GetRangeAsync] and
[GetRangesAsync][obspec.GetRangesAsync] can be used as an input to the TIFF reader.
"""


@dataclass(frozen=True, init=False, kw_only=True, repr=False)
class GeoTIFF(ReadMixin, FetchTileMixin, TiledMixin, TransformMixin):
"""A class representing a GeoTIFF image."""
Expand Down Expand Up @@ -199,7 +208,7 @@ async def open(
cls,
path: str,
*,
store: ObspecInput,
store: Store,
prefetch: int = 32768,
multiplier: float = 2.0,
) -> Self:
Expand All @@ -213,7 +222,7 @@ async def open(
[`GCSStore`][obstore.store.GCSStore], or
[`AzureStore`][obstore.store.AzureStore]. However, this can be any
object that implements the interface required by
[`ObspecInput`][async_tiff.ObspecInput].
[`Store`][async_geotiff.Store].
prefetch: The number of initial bytes to read up front.
multiplier: 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
Expand Down