diff --git a/yirgacheffe/layers/area.py b/yirgacheffe/layers/area.py index 5d1f7c9..23d8ed4 100644 --- a/yirgacheffe/layers/area.py +++ b/yirgacheffe/layers/area.py @@ -65,10 +65,13 @@ def __init__(self, dataset, name: Optional[str] = None, band: int = 1): transform = dataset.GetGeoTransform() + pixel_scale = self.pixel_scale + assert pixel_scale # from raster we should always have one + self._underlying_area = Area( - floor(-180 / self.pixel_scale.xstep) * self.pixel_scale.xstep, + floor(-180 / pixel_scale.xstep) * pixel_scale.xstep, self.area.top, - ceil(180 / self.pixel_scale.xstep) * self.pixel_scale.xstep, + ceil(180 / pixel_scale.xstep) * pixel_scale.xstep, self.area.bottom ) self._active_area = self._underlying_area diff --git a/yirgacheffe/layers/group.py b/yirgacheffe/layers/group.py index ecec231..86aae8e 100644 --- a/yirgacheffe/layers/group.py +++ b/yirgacheffe/layers/group.py @@ -41,7 +41,7 @@ def layer_from_files(cls, filenames: List[str], name: Optional[str] = None) -> G rasters = [RasterLayer.layer_from_file(x) for x in filenames] return cls(rasters, name) - def __init__(self, layers: List[YirgacheffeLayer], name: Optional[str] = None) -> GroupLayerT: + def __init__(self, layers: List[YirgacheffeLayer], name: Optional[str] = None) -> None: if not layers: raise GroupLayerEmpty("Expected one or more layers") if not are_pixel_scales_equal_enough([x.pixel_scale for x in layers]): diff --git a/yirgacheffe/layers/rasters.py b/yirgacheffe/layers/rasters.py index 1e2d3e0..13e31b5 100644 --- a/yirgacheffe/layers/rasters.py +++ b/yirgacheffe/layers/rasters.py @@ -279,11 +279,14 @@ def _unpark(self): def datatype(self) -> int: if self._dataset is None: self._unpark() + assert self._dataset return self._dataset.GetRasterBand(1).DataType def read_array(self, xoffset, yoffset, xsize, ysize) -> Any: if self._dataset is None: self._unpark() + assert self._dataset + if (xsize <= 0) or (ysize <= 0): raise ValueError("Request dimensions must be positive and non-zero") diff --git a/yirgacheffe/layers/rescaled.py b/yirgacheffe/layers/rescaled.py index 480b526..610f5e6 100644 --- a/yirgacheffe/layers/rescaled.py +++ b/yirgacheffe/layers/rescaled.py @@ -39,8 +39,11 @@ def __init__( self._src = src self._nearest_neighbour = nearest_neighbour - self._x_scale = src._pixel_scale.xstep / pixel_scale.xstep - self._y_scale = src._pixel_scale.ystep / pixel_scale.ystep + src_pixel_scale = src.pixel_scale + assert src_pixel_scale # from raster we should always have one + + self._x_scale = src_pixel_scale.xstep / pixel_scale.xstep + self._y_scale = src_pixel_scale.ystep / pixel_scale.ystep def close(self): self._src.close()