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
130 changes: 130 additions & 0 deletions Multi-raster.ipynb

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "rasters"
version = "1.5.3"
version = "1.5.4"
description = "raster processing toolkit"
readme = "README.md"
authors = [
Expand Down
2 changes: 2 additions & 0 deletions rasters/multi_raster.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
from .raster import Raster

class MultiRaster(Raster):
multi = True

def __init__(
self,
array: Union[np.ndarray, Raster],
Expand Down
11 changes: 8 additions & 3 deletions rasters/raster.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
class Raster:
DEFAULT_GEOTIFF_COMPRESSION = "deflate"

multi = False

logger = logging.getLogger(__name__)

def __init__(
Expand Down Expand Up @@ -435,14 +437,17 @@ def open(
raise ValueError("invalid window")

with rasterio.open(filename, "r", **kwargs) as file:
if file.count != 1:
if file.count != 1 and not cls.multi:
raise IOError(f"raster file with {file.count} bands is not single-band: {filename}")

if nodata is None:
nodata = file.nodata

if window is None:
data = file.read(1)
if cls.multi:
data = file.read()
else:
data = file.read(1)
geometry = source_geometry
else:
data = file.read(1, window=window)
Expand All @@ -461,7 +466,7 @@ def open(
crs=CRS
)

result = Raster(data, geometry, nodata=nodata, filename=filename, cmap=cmap, **kwargs)
result = cls(data, geometry, nodata=nodata, filename=filename, cmap=cmap, **kwargs)

if isinstance(target_geometry, RasterGeometry):
result = result.to_geometry(target_geometry, resampling=resampling)
Expand Down
1 change: 1 addition & 0 deletions rasters/rasters.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,6 @@
from .local_UTM_proj4 import local_UTM_proj4
from .linear_downscale import linear_downscale
from .bias_correct import bias_correct
from .mosaic import mosaic

__author__ = "Gregory Halverson"
2 changes: 1 addition & 1 deletion rasters/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.5.3
1.5.4