developmentseed / developmentseed/async-geotiff
"Rotated bounds" or "corners" attribute
- Dominant language
- Python
- Stars
- 58
- Forks
- 7
- Avg merge
- 1d 5h
- Merged PRs (30d)
- 2
Description
Right now, `GeoTIFF` and `Overview` expose a `.bounds` attribute which gives the axis aligned bounds of the raster. But in the case of a rotated transform, this is not the same as the four corners. It would probably be nice to expose a method that returns the four corners of the image.
Here's a suggestion from claude:
```py
@property
def corners(self: HasTransform) -> tuple[tuple[float, float], tuple[float, float], tuple[float, float], tuple[float, float]]:
"""Return the four corners of the image in the units of its CRS.
Unlike `bounds`, which returns the axis-aligned bounding box, this returns
the actual image corners in order: upper-left, upper-right, lower-right, lower-left.
For non-rotated images these are equivalent; for rotated images the corners
describe the true footprint.
Returns:
(ul, ur, lr, ll) as (x, y) tuples.
"""
t = self.transform
ul = t * (0, 0)
ur = t * (self.width, 0)
lr = t * (self.width, self.height)
ll = t * (0, self.height)
return (ul, ur, lr, ll)
```
Note that the ordering of the output depends on whether the raster's origin is top left or bottom left.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.