Exemplo n.º 1
0
def alpha(ctx, src_path, dst_path, ndv, creation_options, workers):
    """Adds/replaced an alpha band to your RGB or RGBA image

    If you don't supply ndv, the alpha mask will be infered.
    """
    with rio.open(src_path) as src:
        band_count = src.count

    if ndv:
        ndv = _parse_ndv(ndv, band_count)

    add_alpha(src_path, dst_path, ndv, creation_options, workers)
Exemplo n.º 2
0
def islossy(input, ndv):
    """
    Determine if there are >= 10 nodata regions in an image
    If true, returns the string `--lossy lossy`.
    """
    with rio.open(input, "r") as src:
        img = src.read()

    ndv = _parse_ndv(ndv, 3)

    if count_ndv_regions(img, ndv) >= 10:
        click.echo("True")
    else:
        click.echo("False")
Exemplo n.º 3
0
def test_parse_ndv_fail_bands(ndv):
    with pytest.raises(ValueError) as excinfo:
        _parse_ndv(str(ndv), 3)
    assert "does not match band count of" in str(excinfo.value)
Exemplo n.º 4
0
def test_parse_ndv(ndv):
    ndvals = _parse_ndv(str(ndv), len(ndv))
    assert [float(n) for n in ndv] == ndvals
    assert isinstance(ndvals[0], float)