File tree Expand file tree Collapse file tree 2 files changed +13
-11
lines changed
Expand file tree Collapse file tree 2 files changed +13
-11
lines changed Original file line number Diff line number Diff line change 11from __future__ import annotations
22
3- import math
43from dataclasses import dataclass , field
54from functools import cached_property
65from typing import TYPE_CHECKING , Self
@@ -351,16 +350,6 @@ def photometric(self) -> PhotometricInterpretation | None: # noqa: PLR0911
351350
352351 return None
353352
354- @property
355- def res (self ) -> tuple [float , float ]:
356- """Return the (width, height) of pixels in the units of its CRS."""
357- transform = self .transform
358- # For rotated images, resolution is the magnitude of the pixel size
359- # calculated from the transform matrix components
360- res_x = math .sqrt (transform .a ** 2 + transform .d ** 2 )
361- res_y = math .sqrt (transform .b ** 2 + transform .e ** 2 )
362- return (res_x , res_y )
363-
364353 @property
365354 def shape (self ) -> tuple [int , int ]:
366355 """Get the shape (height, width) of the full image."""
Original file line number Diff line number Diff line change 22
33from __future__ import annotations
44
5+ import math
56from math import floor
67from typing import TYPE_CHECKING , Literal , Protocol
78
@@ -48,6 +49,18 @@ def index(
4849
4950 return (op (row_frac ), op (col_frac ))
5051
52+ @property
53+ def res (self : HasTransform ) -> tuple [float , float ]:
54+ """Return the (width, height) of pixels in the units of its CRS."""
55+ transform = self .transform
56+
57+ # For rotated images, resolution is the magnitude of the pixel size
58+ # calculated from the transform matrix components
59+ res_x = math .sqrt (transform .a ** 2 + transform .d ** 2 )
60+ res_y = math .sqrt (transform .b ** 2 + transform .e ** 2 )
61+
62+ return (res_x , res_y )
63+
5164 def xy (
5265 self : HasTransform ,
5366 row : int ,
You can’t perform that action at this time.
0 commit comments