Beispiel #1
0
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))
Beispiel #2
0
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))
Beispiel #3
0
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))
Beispiel #4
0
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
Beispiel #6
0
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
Beispiel #7
0
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]))
Beispiel #8
0
def test_data_window_masked(data):
    data = numpy.ma.masked_array(data, data == 0)
    window = get_data_window(data)
    assert window == DATA_WINDOW
Beispiel #9
0
def test_data_window_unmasked(data):
    window = get_data_window(data)
    assert window == ((0, data.shape[0]), (0, data.shape[1]))
Beispiel #10
0
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))
Beispiel #11
0
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]))
Beispiel #12
0
def test_data_window_masked(data):
    data = numpy.ma.masked_array(data, data == 0)
    window = get_data_window(data)
    assert window == DATA_WINDOW
Beispiel #13
0
def test_data_window_unmasked(data):
    window = get_data_window(data)
    assert window == ((0, data.shape[0]), (0, data.shape[1]))
Beispiel #14
0
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))