Skip to content

Commit

Permalink
chore: raise error when pixel resolution greater than 26 (#125)
Browse files Browse the repository at this point in the history
  • Loading branch information
vdelacruzb authored Dec 20, 2023
1 parent fb05e06 commit 60e3ddf
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions raster_loader/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,14 @@ def rasterio_metadata(
block_width = a_window[1].width
block_height = a_window[1].height

pixel_resolution = int(resolution + math.log(block_width * block_height, 4))
if pixel_resolution > 26:
raise ValueError(
"Input raster pixel resolution exceeds "
"the max supported resolution of 26.\n"
"Please resample the raster to a lower resolution."
)

metadata["bands"] = [
{"type": e["type"], "name": e["band_name"]} for e in bands_metadata
]
Expand All @@ -177,9 +185,7 @@ def rasterio_metadata(
metadata["block_height"] = block_height
metadata["num_blocks"] = int(width * height / block_width / block_height)
metadata["num_pixels"] = width * height
metadata["pixel_resolution"] = int(
resolution + math.log(block_width * block_height, 4)
)
metadata["pixel_resolution"] = pixel_resolution

return metadata

Expand Down

0 comments on commit 60e3ddf

Please sign in to comment.