def woffles(source, pq, dsm): """Generate a Water Observation Feature Layer from NBAR, PQ and surface elevation inputs.""" water = classifier.classify(source.to_array(dim='band')) \ | filters.eo_filter(source) \ | filters.pq_filter(pq.pqa) \ | filters.terrain_filter(dsm, source) assert water.dtype == np.uint8 return water
def woffles(nbar, pq, dsm): """Generate a Water Observation Feature Layer from NBAR, PQ and surface elevation inputs.""" water = classifier.classify(nbar.to_array(dim='band')) \ | filters.eo_filter(nbar) \ | filters.pq_filter(pq.pqa) \ | filters.terrain_filter(dsm, nbar) _fix_nodata_to_single_value(water) assert water.dtype == np.uint8 return water
def _classify(data): """ performs WOFS classification on an xarray :param xarray data: An xarray of a single granule including bands: blue, green, red, nir, swir1, swir2 :return: xarray water """ logging.info('Classifying dataset') water = classifier.classify(data).to_dataset(dim="water") logging.info('Classification complete') logging.debug(water) water.attrs['crs'] = geometry.CRS(data.attrs['crs']) logging.debug('Set CRS to: %s', data.attrs['crs']) return water
def woffles_usgs_c2(c2, dsm): """Generate a Water Observation Feature Layer from USGS Collection 2 and surface elevation inputs.""" nbar_bands = spectral_bands(c2) water = classifier.classify(nbar_bands) \ | eo_filter(c2) \ | c2_filter(c2.fmask) if dsm is not None: # terrain_filter arbitrarily expects a band named 'blue' water |= terrain_filter(dsm, c2.rename({"nbart_blue": "blue"})) _fix_nodata_to_single_value(water) assert water.dtype == np.uint8 return water
def woffles_ard(ard, dsm): """Generate a Water Observation Feature Layer from ARD (NBART and FMASK) and surface elevation inputs.""" nbar_bands = spectral_bands(ard) water = classifier.classify(nbar_bands) \ | eo_filter(ard) \ | fmask_filter(ard.fmask) if dsm is not None: # terrain_filter arbitrarily expects a band named 'blue' water |= terrain_filter(dsm, ard.rename({"nbart_blue": "blue"})) _fix_nodata_to_single_value(water) assert water.dtype == np.uint8 return water