How to use the hydrafloods.decorators.carryMetadata function in hydrafloods

To help you get started, we’ve selected a few hydrafloods examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Servir-Mekong / hydra-floods / hydrafloods / thresholding.py View on Github external
    @decorators.carryMetadata
    def applyBmax(img):

        def constuctGrid(i):
            def contructXGrid(j):
                j = ee.Number(j)
                box = ee.Feature(ee.Geometry.Rectangle(j,i,j.add(gridSize),i.add(gridSize)))
                out = ee.Algorithms.If(geom.contains(box.geometry(),maxError=1),box,None)
                return ee.Feature(out)
            i = ee.Number(i)
            out = ee.List.sequence(west,east.subtract(gridSize),gridSize).map(contructXGrid)
            return out


        def calcBmax(feature):
            segment = img#.clip(feature)
            initial = segment.lt(initialThreshold)
github Servir-Mekong / hydra-floods / hydrafloods / geeutils.py View on Github external
@decorators.carryMetadata
def powerToDb(img):
    return ee.Image(10).multiply(img.log10())
github Servir-Mekong / hydra-floods / hydrafloods / filtering.py View on Github external
    @decorators.carryMetadata
    def applyFilter(image):
        def filter(b):
            img = power.select([b])

            # img must be in natural units, i.e. not in dB!
            # Set up 3x3 kernels
            weights3 = ee.List.repeat(ee.List.repeat(1, 3), 3)
            kernel3 = ee.Kernel.fixed(3, 3, weights3, 1, 1, False)

            mean3 = img.reduceNeighborhood(ee.Reducer.mean(), kernel3)
            variance3 = img.reduceNeighborhood(ee.Reducer.variance(), kernel3)

            # Use a sample of the 3x3 windows inside a 7x7 windows to determine gradients and directions
            sample_weights = ee.List([[0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0], [
                                     0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0]])
github Servir-Mekong / hydra-floods / hydrafloods / geeutils.py View on Github external
@decorators.carryMetadata
def dbToPower(img):
    return ee.Image(10).pow(img.divide(10))