当前位置: 首页>>代码示例>>Python>>正文


Python ee.Image方法代码示例

本文整理汇总了Python中ee.Image方法的典型用法代码示例。如果您正苦于以下问题:Python ee.Image方法的具体用法?Python ee.Image怎么用?Python ee.Image使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ee的用法示例。


在下文中一共展示了ee.Image方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: iterate

# 需要导入模块: import ee [as 别名]
# 或者: from ee import Image [as 别名]
def iterate(image1,image2,niter,first):
#   simulated iteration of MAD for debugging          
#   result = iterate(image1,image2,niter,first)   
    for i in range(1,niter+1):
        result = ee.Dictionary(imad(i,first))
        allrhos = ee.List(result.get('allrhos'))
        chi2 = ee.Image(result.get('chi2'))
        MAD = ee.Image(result.get('MAD'))
        first = ee.Dictionary({'image':image1.addBands(image2),
                               'allrhos':allrhos,
                               'chi2':chi2,
                               'MAD':MAD})
    return result


#------------------
# helper functions
#------------------ 
开发者ID:mortcanty,项目名称:earthengine,代码行数:20,代码来源:app.py

示例2: testPromotion

# 需要导入模块: import ee [as 别名]
# 或者: from ee import Image [as 别名]
def testPromotion(self):
    """Verifies object promotion rules."""
    self.InitializeApi()

    # Features and Images are both already Elements.
    self.assertTrue(isinstance(ee._Promote(ee.Feature(None), 'Element'),
                               ee.Feature))
    self.assertTrue(isinstance(ee._Promote(ee.Image(0), 'Element'), ee.Image))

    # Promote an untyped object to an Element.
    untyped = ee.ComputedObject('foo', {})
    self.assertTrue(isinstance(ee._Promote(untyped, 'Element'), ee.Element))

    # Promote an untyped variable to an Element.
    untyped = ee.ComputedObject(None, None, 'foo')
    self.assertTrue(isinstance(ee._Promote(untyped, 'Element'), ee.Element))
    self.assertEquals('foo', ee._Promote(untyped, 'Element').varName) 
开发者ID:mortcanty,项目名称:earthengine,代码行数:19,代码来源:ee_test.py

示例3: testExpression

# 需要导入模块: import ee [as 别名]
# 或者: from ee import Image [as 别名]
def testExpression(self):
    """Verifies the behavior of ee.Image.expression()."""
    image = ee.Image([1, 2]).expression('a', {'b': 'c'})
    expression_func = image.func

    # The call is buried in a one-time override of .encode so we have to call
    # it rather than comparing the object structure.
    def dummy_encoder(x):
      if isinstance(x, ee.encodable.Encodable):
        return x.encode(dummy_encoder)
      else:
        return x

    self.assertEquals(
        {
            'type': 'Invocation',
            'functionName': 'Image.parseExpression',
            'arguments': {
                'expression': 'a',
                'argName': 'DEFAULT_EXPRESSION_IMAGE',
                'vars': ['DEFAULT_EXPRESSION_IMAGE', 'b']
            }
        },
        dummy_encoder(expression_func)) 
开发者ID:mortcanty,项目名称:earthengine,代码行数:26,代码来源:image_test.py

示例4: testMapping

# 需要导入模块: import ee [as 别名]
# 或者: from ee import Image [as 别名]
def testMapping(self):
    """Verifies the behavior of the map() method."""
    collection = ee.ImageCollection('foo')
    algorithm = lambda img: img.select('bar')
    mapped = collection.map(algorithm)

    self.assertTrue(isinstance(mapped, ee.ImageCollection))
    self.assertEquals(ee.ApiFunction.lookup('Collection.map'), mapped.func)
    self.assertEquals(collection, mapped.args['collection'])

    # Need to do a serialized comparison for the function body because
    # variables returned from CustomFunction.variable() do not implement
    # __eq__.
    sig = {
        'returns': 'Image',
        'args': [{'name': '_MAPPING_VAR_0_0', 'type': 'Image'}]
    }
    expected_function = ee.CustomFunction(sig, algorithm)
    self.assertEquals(expected_function.serialize(),
                      mapped.args['baseAlgorithm'].serialize()) 
开发者ID:mortcanty,项目名称:earthengine,代码行数:22,代码来源:collection_test.py

示例5: testIteration

# 需要导入模块: import ee [as 别名]
# 或者: from ee import Image [as 别名]
def testIteration(self):
    """Verifies the behavior of the iterate() method."""
    collection = ee.ImageCollection('foo')
    first = ee.Image(0)
    algorithm = lambda img, prev: img.addBands(ee.Image(prev))
    result = collection.iterate(algorithm, first)

    self.assertEquals(ee.ApiFunction.lookup('Collection.iterate'), result.func)
    self.assertEquals(collection, result.args['collection'])
    self.assertEquals(first, result.args['first'])

    # Need to do a serialized comparison for the function body because
    # variables returned from CustomFunction.variable() do not implement
    # __eq__.
    sig = {
        'returns': 'Object',
        'args': [
            {'name': '_MAPPING_VAR_0_0', 'type': 'Image'},
            {'name': '_MAPPING_VAR_0_1', 'type': 'Object'}
        ]
    }
    expected_function = ee.CustomFunction(sig, algorithm)
    self.assertEquals(expected_function.serialize(),
                      result.args['function'].serialize()) 
开发者ID:mortcanty,项目名称:earthengine,代码行数:26,代码来源:collection_test.py

示例6: testExportImageToCloudStorage

# 需要导入模块: import ee [as 别名]
# 或者: from ee import Image [as 别名]
def testExportImageToCloudStorage(self):
    """Verifies the Cloud Storge export task created by Export.image()."""
    region = ee.Geometry.Rectangle(1, 2, 3, 4)
    config = dict(region=region['coordinates'], maxPixels=10**10,
                  outputBucket='test-bucket')
    task = ee.batch.Export.image.toCloudStorage(
        ee.Image(1), 'TestDescription',
        config['outputBucket'], None, None,
        config['region'], None, None, None, config['maxPixels'])
    self.assertEquals('TESTTASKID', task.id)
    self.assertEquals(
        {
            'type': 'EXPORT_IMAGE',
            'state': 'UNSUBMITTED',
            'json': ee.Image(1).serialize(),
            'description': 'TestDescription',
            'region': '[[[1, 4], [1, 2], [3, 2], [3, 4]]]',
            'outputBucket': 'test-bucket',
            'maxPixels': 10**10,
        },
        task.config) 
开发者ID:mortcanty,项目名称:earthengine,代码行数:23,代码来源:batch_test.py

示例7: pv

# 需要导入模块: import ee [as 别名]
# 或者: from ee import Image [as 别名]
def pv(imList,p,median,j):
    ''' calculate -2log(R_ell,j) and return P-value '''
    imList = ee.List(imList)
    p = ee.Number(p)
    j = ee.Number(j)
    f = p
    one = ee.Number(1.0)
# 1 - (1. + 1./(j*(j-1)))/(6.*p*n)    
    rhoj = one.subtract(one.add(one.divide(j.multiply(j.subtract(one)))).divide(6*ENL))
# -(f/4.)*(1.-1./rhoj)**2'    
    omega2j = one.subtract(one.divide(rhoj)).pow(2.0).multiply(f.divide(-4.0))
    Z = ee.Image(ee.Image(log_det_sum(imList,j.subtract(1)))).multiply(j.subtract(1)) \
                 .add(log_det(imList,j))  \
                 .add(p.multiply(j).multiply(ee.Number(j).log())) \
                 .subtract(p.multiply(j.subtract(1)).multiply(j.subtract(1).log())) \
                 .subtract(ee.Image(log_det_sum(imList,j)).multiply(j)) \
                 .multiply(rhoj) \
                 .multiply(-2*ENL)
# (1.-omega2j)*stats.chi2.cdf(Z,[f])+omega2j*stats.chi2.cdf(Z,[f+4])                 
    P = ee.Image( chi2cdf(Z,f).multiply(one.subtract(omega2j)).add(chi2cdf(Z,f.add(4)).multiply(omega2j))  )
# 3x3 median filter    
    return ee.Algorithms.If(median, P.focal_median(), P) 
开发者ID:mortcanty,项目名称:earthengine,代码行数:24,代码来源:eeWishart.py

示例8: filter_j

# 需要导入模块: import ee [as 别名]
# 或者: from ee import Image [as 别名]
def filter_j(current,prev):
    P = ee.Image(current)
    prev = ee.Dictionary(prev)
    ell = ee.Number(prev.get('ell'))
    cmap = ee.Image(prev.get('cmap'))
    smap = ee.Image(prev.get('smap'))
    fmap = ee.Image(prev.get('fmap'))
    bmap = ee.Image(prev.get('bmap'))
    threshold = ee.Image(prev.get('threshold'))
    j = ee.Number(prev.get('j'))
    cmapj = cmap.multiply(0).add(ell.add(j).subtract(1))
    cmap1 = cmap.multiply(0).add(1)
    tst = P.gt(threshold).And(cmap.eq(ell.subtract(1)))
    cmap = cmap.where(tst,cmapj)
    fmap = fmap.where(tst,fmap.add(1))
    smap = ee.Algorithms.If(ell.eq(1),smap.where(tst,cmapj),smap)
    idx = ell.add(j).subtract(2)
    tmp = bmap.select(idx)
    bname = bmap.bandNames().get(idx)
    tmp = tmp.where(tst,cmap1)
    tmp = tmp.rename([bname])    
    bmap = bmap.addBands(tmp,[bname],True)    
    return ee.Dictionary({'ell':ell,'j':j.add(1),'threshold':threshold,'cmap':cmap,'smap':smap,'fmap':fmap,'bmap':bmap}) 
开发者ID:mortcanty,项目名称:earthengine,代码行数:25,代码来源:eeWishart.py

示例9: omnibus

# 需要导入模块: import ee [as 别名]
# 或者: from ee import Image [as 别名]
def omnibus(imList,significance=0.0001,median=False):
    '''return change maps for sequential omnibus change algorithm'''    
    imList = ee.List(imList).map(multbyenl)    
    p = ee.Image(imList.get(0)).bandNames().length()
    k = imList.length() 
#  pre-calculate p-value array    
    ells = ee.List.sequence(1,k.subtract(1))
    first = ee.Dictionary({'k':k,'p':p,'median':median,'imList':imList,'pv_arr':ee.List([])})
    pv_arr = ee.List(ee.Dictionary(ells.iterate(ells_iter,first)).get('pv_arr'))      
#  filter p-values to generate cmap, smap, fmap and bmap
    cmap = ee.Image(imList.get(0)).select(0).multiply(0.0)
    smap = ee.Image(imList.get(0)).select(0).multiply(0.0)
    fmap = ee.Image(imList.get(0)).select(0).multiply(0.0)   
    bmap = ee.Image.constant(ee.List.repeat(0,k.subtract(1)))    
    threshold = ee.Image.constant(1-significance)
    first = ee.Dictionary({'ell':1,'threshold':threshold,'cmap':cmap,'smap':smap,'fmap':fmap,'bmap':bmap})
    return ee.Dictionary(pv_arr.iterate(filter_ell,first)) 
开发者ID:mortcanty,项目名称:earthengine,代码行数:19,代码来源:eeWishart.py

示例10: covw

# 需要导入模块: import ee [as 别名]
# 或者: from ee import Image [as 别名]
def covw(centeredImage, weights=None, maxPixels=1e9):
    '''Return the (weighted) covariance matrix of a centered image''' 
    if weights==None:
        weights = centeredImage.multiply(0).add(ee.Image.constant(1))           
    B1 = centeredImage.bandNames().get(0)       
    b1 = weights.bandNames().get(0)     
    sumWeights = ee.Number(weights.reduceRegion(ee.Reducer.sum(), maxPixels=maxPixels).get(b1))  
    nPixels = ee.Number(centeredImage.reduceRegion(ee.Reducer.count(), maxPixels=maxPixels).get(B1))   
#    arr = dataArray(centeredImage.multiply(weights.sqrt()))
#    return arr.matrixTranspose().matrixMultiply(arr).divide(sumWeights)
    covW = centeredImage \
        .multiply(weights.sqrt()) \
        .toArray() \
        .reduceRegion(ee.Reducer.centeredCovariance(), maxPixels=1e9) \
        .get('array')
    return ee.Array(covW).multiply(nPixels.divide(sumWeights)) 
开发者ID:mortcanty,项目名称:earthengine,代码行数:18,代码来源:eeMad_old.py

示例11: simonf

# 需要导入模块: import ee [as 别名]
# 或者: from ee import Image [as 别名]
def simonf(path):
    
    def sel(image):
        return ee.Image(image).select(['VV','VH'])
        
    images = ee.List(  
       [ee.Image(path+'S1A_IW_GRDH_1SDV_20160305T171543_20160305T171608_010237_00F1FA_49DC'),
        ee.Image(path+'S1A_IW_GRDH_1SDV_20160329T171543_20160329T171608_010587_00FBF9_B4DE'),
        ee.Image(path+'S1A_IW_GRDH_1SDV_20160410T171538_20160410T171603_010762_010122_CEF6'),
        ee.Image(path+'S1A_IW_GRDH_1SDV_20160422T171539_20160422T171604_010937_010677_03F6'),
        ee.Image(path+'S1A_IW_GRDH_1SDV_20160504T171539_20160504T171604_011112_010BED_80AF'),
        ee.Image(path+'S1A_IW_GRDH_1SDV_20160516T171540_20160516T171605_011287_011198_FC21'),
        ee.Image(path+'S1A_IW_GRDH_1SDV_20160528T171603_20160528T171628_011462_011752_F570'),
        ee.Image(path+'S1A_IW_GRDH_1SDV_20160609T171604_20160609T171629_011637_011CD1_C2F5'), 
        ee.Image(path+'S1A_IW_GRDH_1SDV_20160715T171605_20160715T171630_012162_012DA2_95A1'), 
        ee.Image(path+'S1A_IW_GRDH_1SDV_20160727T171606_20160727T171631_012337_013359_29A6'),
        ee.Image(path+'S1A_IW_GRDH_1SDV_20160808T171607_20160808T171632_012512_01392E_44C4'),
        ee.Image(path+'S1A_IW_GRDH_1SDV_20160901T171608_20160901T171633_012862_0144E3_30E5'),
        ee.Image(path+'S1A_IW_GRDH_1SDV_20160925T171609_20160925T171634_013212_015050_8FDB'),
        ee.Image(path+'S1B_IW_GRDH_1SDV_20161001T171508_20161001T171533_002316_003E9D_D195'), 
        ee.Image(path+'S1A_IW_GRDH_1SDV_20161007T171609_20161007T171634_013387_0155CD_F513'), 
        ee.Image(path+'S1A_IW_GRDH_1SDV_20161019T171609_20161019T171634_013562_015B60_27FF'),
        ee.Image(path+'S1A_IW_GRDH_1SDV_20161031T171609_20161031T171634_013737_0160BD_4FAE') ] )
    
    return ee.ImageCollection(images.map(sel)) 
开发者ID:mortcanty,项目名称:earthengine,代码行数:27,代码来源:app_sav.py

示例12: covarw

# 需要导入模块: import ee [as 别名]
# 或者: from ee import Image [as 别名]
def covarw(image, weights, maxPixels=1e9):
    '''Return the weighted centered image and its weighted covariance matrix'''  
    geometry = image.geometry()
    bandNames = image.bandNames()
    N = bandNames.length()
    scale = image.select(0).projection().nominalScale()
    weightsImage = image.multiply(ee.Image.constant(0)).add(weights)
    means = image.addBands(weightsImage) \
                 .reduceRegion(ee.Reducer.mean().repeat(N).splitWeights(), scale=scale,maxPixels=maxPixels) \
                 .toArray() \
                 .project([1])
    centered = image.toArray().subtract(means) 
    B1 = centered.bandNames().get(0)       
    b1 = weights.bandNames().get(0)     
    nPixels = ee.Number(centered.reduceRegion(ee.Reducer.count(), scale=scale, maxPixels=maxPixels).get(B1)) 
    sumWeights = ee.Number(weights.reduceRegion(ee.Reducer.sum(),geometry=geometry, scale=scale, maxPixels=maxPixels).get(b1))
    covw = centered.multiply(weights.sqrt()) \
                   .toArray() \
                   .reduceRegion(ee.Reducer.centeredCovariance(), geometry=geometry, scale=scale, maxPixels=maxPixels) \
                   .get('array')
    covw = ee.Array(covw).multiply(nPixels).divide(sumWeights)
    return (centered.arrayFlatten([bandNames]), covw) 
开发者ID:mortcanty,项目名称:earthengine,代码行数:24,代码来源:eeMad.py

示例13: check_imageCollection

# 需要导入模块: import ee [as 别名]
# 或者: from ee import Image [as 别名]
def check_imageCollection(imageCollection):
        if not isinstance(imageCollection, ee.ImageCollection):
            msg = 'first parameter of Image.doySeries must be an ' \
                  'ImageCollection, found {}'
            raise ValueError(msg.format(type(imageCollection))) 
开发者ID:fitoprincipe,项目名称:ipygee,代码行数:7,代码来源:chart.py

示例14: getData

# 需要导入模块: import ee [as 别名]
# 或者: from ee import Image [as 别名]
def getData(geometry, obj, reducer='first', scale=None, name=None):
    ''' Get data from an ee.ComputedObject using a giving ee.Geometry '''
    accepted = (ee.Image, ee.ImageCollection, ee.Feature, ee.FeatureCollection)

    reducers = {'first': ee.Reducer.first(),
                'mean': ee.Reducer.mean(),
                'median': ee.Reducer.median(),
                'sum':ee.Reducer.sum()}

    if not isinstance(obj, accepted):
        return "Can't get data from that Object"
    elif isinstance(obj, ee.Image):
        t = geometry.type().getInfo()
        # Try to get the image scale
        scale = obj.select([0]).projection().nominalScale().getInfo() \
            if not scale else scale

        # Reduce if computed scale is too big
        scale = 1 if scale > 500 else scale
        if t == 'Point':
            values = tools.image.getValue(obj, geometry, scale, 'client')
            val_str = '<h3>Data from {}'.format(name)
            for key, val in values.items():
                val_str += '<b>{}:</b> {}</br>'.format(key, val)
            return val_str
        elif t == 'Polygon':
            red = reducer if reducer in reducers.keys() else 'first'
            values = obj.reduceRegion(reducers[red], geometry, scale, maxPixels=1e13).getInfo()
            val_str = '<h3>{}:</h3>\n'.format(red)
            for key, val in values.items():
                val_str += '<b>{}:</b> {}</br>'.format(key, val)
            return val_str 
开发者ID:fitoprincipe,项目名称:ipygee,代码行数:34,代码来源:maptools.py

示例15: paint

# 需要导入模块: import ee [as 别名]
# 或者: from ee import Image [as 别名]
def paint(geometry, outline_color='black', fill_color=None, outline=2):
    """ Paint a Geometry, Feature or FeatureCollection """

    def overlap(image_back, image_front):
        mask_back = image_back.mask()
        mask_front = image_front.mask()
        entire_mask = mask_back.add(mask_front)
        mask = mask_back.Not()
        masked = image_front.updateMask(mask).unmask()

        return masked.add(image_back.unmask()).updateMask(entire_mask)

    if isinstance(geometry, ee.Feature) or isinstance(geometry, ee.FeatureCollection):
        geometry = geometry.geometry()

    if fill_color:
        fill = ee.Image().paint(geometry, 1).visualize(palette=[fill_color])

    if outline_color:
        out = ee.Image().paint(geometry, 1, outline).visualize(palette=[outline_color])

    if fill_color and outline_color:
        rgbVector = overlap(out, fill)
    elif fill_color:
        rgbVector = fill
    else:
        rgbVector = out

    return rgbVector 
开发者ID:fitoprincipe,项目名称:ipygee,代码行数:31,代码来源:maptools.py


注:本文中的ee.Image方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。