Ejemplo n.º 1
0
def generate(path, count=5, size=(64, 64), indexes=1):

    sdg = SpatialDataGenerator('data/small.tif', indexes=indexes)
    sdg.source = 'data/small.tif'
    df = sdg.random_grid(*size, count=count, units='pixels')

    return fc.flow_to_numpy(sdg, df, *size, path=path)
Ejemplo n.º 2
0
def test_flow_to_numpy():

    size = (64, 64)
    sdg = SpatialDataGenerator('data/small.tif', indexes=1)
    sdg.source = 'data/small.tif'
    df = sdg.random_grid(*size, count=5, units='pixels')

    with TemporaryDirectory() as td:
        tmpdir = Path(td)
        filenames = fc.flow_to_numpy(sdg, df, *size, path=tmpdir)
        assert isinstance(filenames, pd.Series)

        for fname in filenames:
            filepath = tmpdir / fname
            assert filepath.exists()
            arr = np.load(filepath)
            assert len(arr.shape) == 4
            assert arr.shape[0] == 1
            assert arr.shape[1] == 1
            assert arr.shape[2] == size[1] and arr.shape[3] == size[0]
Ejemplo n.º 3
0
def test_random_grid():
    dg = SpatialDataGenerator()
    dg.source = 'data/small.tif'
    df = dg.random_grid(64, 64, 100)
    assert len(df) == 100
Ejemplo n.º 4
0
def test_random_grid():
    dg = SpatialDataGenerator()
    dg.source = 'data/small.tif'
    dg.width, dg.height = 64, 64
    df = dg.random_grid(100)
    assert len(df) == 100