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
14 changes: 6 additions & 8 deletions src/async_geotiff/_geotiff.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ def __init__(self, tiff: TIFF) -> None:
object.__setattr__(self, "_gkd", gkd)

for ifd in tiff.ifds:
if ifd.tile_height is None or ifd.tile_width is None:
raise ValueError("Only tiled GeoTIFFs are supported.")
if ifd.strip_byte_counts is not None or ifd.strip_offsets is not None:
raise ValueError("Striped GeoTIFFs are not supported.")

# Separate data IFDs and mask IFDs (skip the primary IFD at index 0)
# Data IFDs are indexed by (width, height) for matching with masks
Expand Down Expand Up @@ -334,16 +334,14 @@ def shape(self) -> tuple[int, int]:
@property
def tile_height(self) -> int:
"""The height in pixels per tile of the image."""
tile_height = self._ifd.tile_height
assert tile_height is not None, "Constructor validated that images are tiled" # noqa: S101
return tile_height
# A TIFF with a single tile can omit tile_height
return self._ifd.tile_height or self._ifd.image_height

@property
def tile_width(self) -> int:
"""The width in pixels per tile of the image."""
tile_width = self._ifd.tile_width
assert tile_width is not None, "Constructor validated that images are tiled" # noqa: S101
return tile_width
# A TIFF with a single tile can omit tile_width
return self._ifd.tile_width or self._ifd.image_width

@property
def transform(self) -> Affine:
Expand Down
2 changes: 1 addition & 1 deletion src/async_geotiff/_tile.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def width(self) -> int:
class TiledMixin:
@property
def tile_count(self: IsTiled) -> tuple[int, int]:
"""The number of tiles in the x and y directions, if the image is tiled."""
"""The number of tiles in the x and y directions."""
return (
math.ceil(self.width / self.tile_width),
math.ceil(self.height / self.tile_height),
Expand Down