How to use the hydrafloods.geeutils 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 / processing.py View on Github external
i = ee.Number(iteration)
            sim = geeutils.globalOtsu(self.downscaled,target_date,self.region,seed=i,**kwargs)
            return sim.And(hand.lt(30))

        tDate = ee.Date(target_date)

        if probablistic:
            iters = ee.List.sequence(0,nIters-1)

            sims = ee.ImageCollection(iters.map(_threholdWrapper))
            probs = sims.sum().divide(nIters).rename(['probability'])
            water = probs.select(['probability']).gt(probTreshold).rename('water')
            mapResult = water.addBands(probs.multiply(10000).uint16())

        else:
            mapResult = geeutils.globalOtsu(self.downscaled,target_date,self.region,**kwargs)\
                .And(hand.lt(30))

        return mapResult
github Servir-Mekong / hydra-floods / hydrafloods / collection.py View on Github external
def _threholdWrapper(iteration):
            i = ee.Number(iteration)
            sim = geeutils.globalOtsu(
                self.downscaled, target_date, self.region, seed=i, **kwargs)
            return sim.And(hand.lt(30))
github Servir-Mekong / hydra-floods / hydrafloods / collection.py View on Github external
def __init__(self, *args, assetid='MODIS/006/MOD09GA', **kwargs):
        super(Modis, self).__init__(*args, assetid=assetid, **kwargs)

        if self.useQa:
            self.collection = self.collection.map(self._qa)

        self.collection = self.collection\
            .select(BANDREMAP.get('modis'), BANDREMAP.get('new'))\
            .map(geeutils.addIndices)

        self.clipToRegion(inplace=True)

        return
github Servir-Mekong / hydra-floods / hydrafloods / processing.py View on Github external
def __init__(self,*args,**kwargs):
        super(Modis, self).__init__(*args,**kwargs)

        self.collection = self.collection.map(self._qaMask)\
            .select(BANDREMAP.get('modis'),BANDREMAP.get('new'))\
            .map(self.clip)\
            .map(geeutils.addIndices)

        return
github Servir-Mekong / hydra-floods / hydrafloods / thresholding.py View on Github external
canny = ee.Algorithms.CannyEdgeDetector(smoothed,canny_threshold,canny_sigma)

        connected = canny.mask(canny).lt(canny_lt).connectedPixelCount(connected_pixels, True)
        edges = connected.gte(edge_length)

        edgeBuffer = edges.focal_max(smooth_edges, 'square', 'meters')

        histogram_image = smoothed.mask(edgeBuffer)
        histogram = histogram_image.reduceRegion(ee.Reducer.histogram(255, 2),polygons.geometry(),reductionScale,bestEffort=True)

        threshold = ee.Number(otsu_function(histogram.get(histBand))).min(upper_threshold)
    else:
        threshold = upper_threshold

    water = smoothed.lt(threshold).clip(geeutils.LAND.geometry())

    return water.rename('water').uint8()\
        .copyProperties(img)\
        .set('system:time_start',img.get('system:time_start'))
github Servir-Mekong / hydra-floods / hydrafloods / collection.py View on Github external
def __init__(self, region, time_start, time_end, assetid='', useQa=True):
        # TODO: add exceptions to check datatypes
        self.region = region  # dtype = ee.Geometry
        self.iniTime = time_start
        self.endTime = time_end + datetime.timedelta(1)
        self.id = assetid
        self.useQa = useQa

        coll = ee.ImageCollection(self.id)\
                            .filterBounds(self.region)\
                            .filterDate(self.iniTime, self.endTime)

        if useQa:
            coll = coll.map(self._qa)

        self.collection = coll.map(geeutils.addTimeBand)

        return