Exemple #1
0
def test_testutils_iodriver(data_folder):
    fpath = str(data_folder) + '/test.tif'
    src = open_reader(fpath)
    assert src is not None
    assert src.crs is not None
    assert src.transform is not None
    assert src.crs.epsg == 4326
    assert src.shape == (2000, 4000)
    assert src.nodata == -999
    assert src.dtype == np.dtype(np.int16)
    def _read(gbox,
              resampling='nearest',
              fallback_nodata=-999,
              dst_nodata=-999):

        rdr = open_reader(mm.path, nodata=fallback_nodata)

        yy = np.full(gbox.shape, dst_nodata, dtype=rdr.dtype)
        yy_, roi = read_time_slice_v2(rdr, gbox, resampling, dst_nodata)
        yy[roi] = yy_
        return yy, roi
    def _read(gbox,
              resampling='nearest',
              fallback_nodata=-999,
              dst_nodata=-999,
              check_paste=False):

        rdr = open_reader(mm.path, nodata=fallback_nodata)
        if check_paste:
            # check that we are using paste
            paste_ok, reason = can_paste(
                compute_reproject_roi(rdr_geobox(rdr), gbox))
            assert paste_ok is True, reason

        yy = np.full(gbox.shape, dst_nodata, dtype=rdr.dtype)
        yy_, roi = read_time_slice_v2(rdr, gbox, resampling, dst_nodata)
        yy[roi] = yy_
        return yy, roi