def test_window_shape_negative(self): self.assertEqual( rasterio.window_shape(((-10, None), (-10, None)), 100, 90), (10, 10)) self.assertEqual( rasterio.window_shape(((~0, None), (~0, None)), 100, 90), (1, 1)) self.assertEqual( rasterio.window_shape(((None, ~0), (None, ~0)), 100, 90), (99, 89))
def test_compute_window_mask(worker): """Get an all-valid mask for one window""" in_window = ((0, 100), (0, 100)) out_window, data = compute_window_mask((in_window, 0, {})) assert in_window == out_window assert (numpy.fromstring(zlib.decompress(data), 'uint8').reshape( rasterio.window_shape(out_window)) == 255).all()
def test_read_window(self): with rasterio.open('tests/data/RGB.byte.tif') as s: windows = s.block_windows(1) ji, first_window = next(windows) first_block = s.read(1, window=first_window) self.assertEqual(first_block.dtype, rasterio.ubyte) self.assertEqual(first_block.shape, rasterio.window_shape(first_window))
def test_read_window(self): with rasterio.open('tests/data/RGB.byte.tif') as s: windows = s.block_windows(1) ji, first_window = next(windows) first_block = s.read(1, window=first_window) self.assertEqual(first_block.dtype, rasterio.ubyte) self.assertEqual( first_block.shape, rasterio.window_shape(first_window))
def mask(self, windows, **kwargs): """Iterate over windows and compute mask arrays. The keyword arguments will be passed as keyword arguments to the manager's mask algorithm function. Yields window, ndarray pairs. """ iterargs = izip(windows, repeat(self.nodata), repeat(kwargs)) for out_window, data in self.pool.imap_unordered( compute_window_mask, iterargs): yield out_window, numpy.fromstring( zlib.decompress(data), self.dtype).reshape(rasterio.window_shape(out_window))
def test_window_shape_positive(self): self.assertEqual( rasterio.window_shape(((0, 4), (1, 102))), (4, 101))
def test_window_shape_None_stop(self): self.assertEqual( rasterio.window_shape(((10, None), (10, None)), 100, 90), (90, 80))
def test_window_shape_None_start(self): self.assertEqual( rasterio.window_shape(((None, 4), (None, 102))), (4, 102))
def test_window_shape_positive(self): self.assertEqual(rasterio.window_shape(((0, 4), (1, 102))), (4, 101))
def test_window_shape_None_start(self): self.assertEqual(rasterio.window_shape(((None, 4), (None, 102))), (4, 102))