def test_data_window_masked_file(): with rasterio.open('tests/data/RGB.byte.tif') as src: window = get_data_window(src.read(1, masked=True)) assert window == ((3, 714), (13, 770)) window = get_data_window(src.read(masked=True)) assert window == ((3, 714), (13, 770))
def test_data_window_nodata_disjunct(): data = numpy.zeros((3, 10, 10), dtype='uint8') data[0, :4, 1:4] = 1 data[1, 2:5, 2:8] = 1 data[2, 1:6, 1:6] = 1 window = get_data_window(data, nodata=0) assert window == ((0, 6), (1, 8))
def test_data_window_unmasked(data, recwarn): warnings.simplefilter('always') old = get_data_window(data) assert len(recwarn) == 1 assert recwarn.pop(DeprecationWarning) new = windows.get_data_window(data) assert len(recwarn) == 0 assert old == new
def test_data_window_nodata(data): window = get_data_window(data, nodata=0) assert window == DATA_WINDOW window = get_data_window(numpy.ones_like(data), nodata=0) assert window == ((0, data.shape[0]), (0, data.shape[1]))
def test_data_window_masked(data): data = numpy.ma.masked_array(data, data == 0) window = get_data_window(data) assert window == DATA_WINDOW
def test_data_window_unmasked(data): window = get_data_window(data) assert window == ((0, data.shape[0]), (0, data.shape[1]))
def test_data_window_empty_result(): data = numpy.zeros((3, 10, 10), dtype='uint8') window = get_data_window(data, nodata=0) assert window == ((0, 0), (0, 0))