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")
def test_count_ndv_regions_should_return_0(): with rasterio.open("tests/fixtures/ca_chilliwack/" "2012_30cm_594_5450.tiny.tif") as src: img = src.read() ndv = (0, 0, 0) assert count_ndv_regions(img, ndv) == 0
def test_count_ndv_regions(ndv, img): n_labels = count_ndv_regions(img, ndv) assert isinstance(n_labels, int)
def test_count_ndv_regions_should_return_results(): with rio.open('tests/fixtures/ca_chilliwack/' '2012_30cm_594_5450.tiny.tif') as src: img = src.read() ndv = (255, 255, 255) assert count_ndv_regions(img, ndv) == 14666