In [1]: import numpy as np
...:
...: import telluric as tl
...: from telluric.constants import WGS84_CRS
...:
...:
In [2]: roi = tl.GeoVector.from_bounds(xmin=0, ymin=0, xmax=2, ymax=2, crs=WGS84_CRS)
...: resolution = 1.0
...:
...:
In [4]: rs0 = tl.GeoRaster2.empty_from_roi(roi, resolution)
In [6]: rs0.crop(roi).image
Out[6]:
masked_array(
data=[[[--, --],
[--, --]]],
mask=[[[ True, True],
[ True, True]]],
fill_value=999999,
dtype=uint8)
In [7]: rs0.crop(roi, resolution).image
---------------------------------------------------------------------------
MemoryError Traceback (most recent call last)
<ipython-input-7-0b900c87a084> in <module>()
----> 1 rs0.crop(roi, resolution).image
~/Development/telluric/telluric/georaster.py in crop(self, vector, resolution)
773 xsize, ysize = (None, None)
774
--> 775 return self.pixel_crop(bounds, xsize, ysize, window=window)
776
777 def _vector_to_raster_bounds(self, vector, boundless=False):
~/Development/telluric/telluric/georaster.py in pixel_crop(self, bounds, xsize, ysize, window)
828 """
829 if self._image is not None:
--> 830 return self._crop(bounds, xsize=xsize, ysize=ysize)
831 else:
832 window = window or rasterio.windows.Window(bounds[0],
~/Development/telluric/telluric/georaster.py in _crop(self, bounds, xsize, ysize)
851 if xsize and ysize:
852 if not (xsize == out_raster.width and ysize == out_raster.height):
--> 853 out_raster = out_raster.resize(dest_width=xsize, dest_height=ysize)
854 return out_raster
855
~/Development/telluric/telluric/georaster.py in resize(self, ratio, ratio_x, ratio_y, dest_width, dest_height, dest_resolution, resampling)
908 ratio_x, ratio_y = ratio, ratio
909
--> 910 return self._resize(ratio_x, ratio_y, resampling)
911
912 def _resize(self, ratio_x, ratio_y, resampling):
~/Development/telluric/telluric/georaster.py in _resize(self, ratio_x, ratio_y, resampling)
915 new_height = int(np.ceil(self.height * ratio_y))
916 dest_affine = self.affine * Affine.scale(1 / ratio_x, 1 / ratio_y)
--> 917 return self.reproject(new_width, new_height, dest_affine, resampling=resampling)
918
919 def to_pillow_image(self, return_mask=False):
~/Development/telluric/telluric/georaster.py in reproject(self, new_width, new_height, dest_affine, dtype, dst_crs, resampling)
951 dtype = dtype or self.image.data.dtype
952 dest_image = np.ma.masked_array(
--> 953 data=np.empty([self.num_bands, new_height, new_width], dtype=np.float32),
954 mask=np.empty([self.num_bands, new_height, new_width], dtype=bool)
955 )
MemoryError:
In [11]: bounds, window = rs0._vector_to_raster_bounds(roi)
In [12]: bounds, window
Out[12]: ((0, 0, 2, 2), Window(col_off=0, row_off=0, width=2, height=2))
In [13]: rs0._resolution_to_output_shape(bounds, resolution)
Out[13]: (222222.0, 222222)