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


Python ee.Geometry方法代码示例

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


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

示例1: geometry

# 需要导入模块: import ee [as 别名]
# 或者: from ee import Geometry [as 别名]
def geometry(info):
    """ Dispatch a ee.Geometry """
    coords = info.get('coordinates')
    typee = info.get('type')
    widget = Accordion()

    if typee in ['MultiPoint', 'MultiPolygon', 'MultiLineString']:
        inner_children = []
        for coord in coords:
            inner_children.append(Label(str(coord)))
        inner_acc = Accordion(inner_children)
        inner_acc.selected_index = None # this will unselect all
        for i, _ in enumerate(coords):
            inner_acc.set_title(i, str(i))
        children = [inner_acc]
    else:
        children = [Label(str(coords))]

    widget.children = children
    widget.set_title(0, 'coordinates')
    widget.selected_index = None
    return widget 
开发者ID:fitoprincipe,项目名称:ipygee,代码行数:24,代码来源:dispatcher.py

示例2: getBounds

# 需要导入模块: import ee [as 别名]
# 或者: from ee import Geometry [as 别名]
def getBounds(eeObject):
    if isinstance(eeObject, list):
        bounds = eeObject
    else:
        # Make a buffer if object is a Point
        if isinstance(eeObject, ee.Geometry):
            t = eeObject.type().getInfo()
            if t == 'Point':
                eeObject = eeObject.buffer(1000)

        bounds = tools.geometry.getRegion(eeObject, True)

    # Catch unbounded images
    unbounded = [[[-180.0, -90.0], [180.0, -90.0],
                  [180.0, 90.0], [-180.0, 90.0],
                  [-180.0, -90.0]]]

    if bounds == unbounded:
        print("can't center object because it is unbounded")
        return None

    bounds = inverseCoordinates(bounds)
    return bounds 
开发者ID:fitoprincipe,项目名称:ipygee,代码行数:25,代码来源:maptools.py

示例3: addMarker

# 需要导入模块: import ee [as 别名]
# 或者: from ee import Geometry [as 别名]
def addMarker(self, marker, visParams=None, name=None, show=True,
                  opacity=None, replace=True,
                  inspect={'data':None, 'reducer':None, 'scale':None}):
        """ General method to add Geometries, Features or FeatureCollections
        as Markers """

        if isinstance(marker, ee.Geometry):
            self.addGeometry(marker, visParams, name, show, opacity, replace,
                             inspect)

        elif isinstance(marker, ee.Feature):
            self.addFeature(marker, visParams, name, show, opacity, replace,
                            inspect)

        elif isinstance(marker, ee.FeatureCollection):
            geometry = marker.geometry()
            self.addGeometry(marker, visParams, name, show, opacity, replace,
                             inspect) 
开发者ID:fitoprincipe,项目名称:ipygee,代码行数:20,代码来源:map.py

示例4: centerObject

# 需要导入模块: import ee [as 别名]
# 或者: from ee import Geometry [as 别名]
def centerObject(self, eeObject, zoom=None, method=1):
        """ Center an eeObject

        :param eeObject:
        :param zoom:
        :param method: experimetal methods to estimate zoom for fitting bounds
            Currently: 1 or 2
        :type: int
        """
        bounds = getBounds(eeObject)
        if bounds:
            try:
                inverse = inverseCoordinates(bounds)
                centroid = ee.Geometry.Polygon(inverse) \
                    .centroid().getInfo()['coordinates']
            except:
                centroid = [0, 0]

            self.center = inverseCoordinates(centroid)
            if zoom:
                self.zoom = zoom
            else:
                self.zoom = getZoom(bounds, method) 
开发者ID:fitoprincipe,项目名称:ipygee,代码行数:25,代码来源:map.py

示例5: assertInvalid

# 需要导入模块: import ee [as 别名]
# 或者: from ee import Geometry [as 别名]
def assertInvalid(self, ctor, msg, *coords):
    """Verifies that geometry is invalid.

    Calls the given constructor with whatever arguments have been passed,
    and verifies that the given error message is thrown.

    Args:
      ctor: The geometry constructor function, e.g. ee.Geometry.MultiPoint.
      msg: The expected error message in the thrown exception.
      *coords: The coordinates of the geometry.
    """
    try:
      ctor(*coords)
    except ee.EEException as e:
      self.assertTrue(msg in str(e))
    else:
      self.fail('Expected an exception.') 
开发者ID:mortcanty,项目名称:earthengine,代码行数:19,代码来源:geometry_test.py

示例6: map

# 需要导入模块: import ee [as 别名]
# 或者: from ee import Geometry [as 别名]
def map(self, collection, **kwargs):
        """ Map the score over a collection

        :param col: collection
        :type col: satcol.Collection
        :param geom: boundaries geometry
        :type geom: ee.Geometry or ee.Feature
        """
        col = kwargs.get('col')
        geom = kwargs.get('geom')
        minscale = min([band.scale for band in col.bands])
        def wrap(img):
            score = self.compute(img, geometry=geom, scale=minscale,
                                 count_zeros=self.count_zeros)
            prop = score.get(self.name)
            return img.addBands(score).set(self.name, prop)

        return collection.map(wrap) 
开发者ID:fitoprincipe,项目名称:geebap,代码行数:20,代码来源:scores.py

示例7: test_Collection_init_cloud_cover_exception

# 需要导入模块: import ee [as 别名]
# 或者: from ee import Geometry [as 别名]
def test_Collection_init_cloud_cover_exception():
    """Test if Exception is raised for an invalid cloud_cover_max"""
    with pytest.raises(TypeError):
        default_coll_obj(cloud_cover_max='A')
    with pytest.raises(ValueError):
        default_coll_obj(cloud_cover_max=-1)
    with pytest.raises(ValueError):
        default_coll_obj(cloud_cover_max=101)


# # TODO: Test for Error if geometry is not ee.Geometry
# def test_Collection_init_geometry_exception():
#     """Test if Exception is raised for an invalid geometry"""
#     args = default_coll_args()
#     args['geometry'] = 'DEADBEEF'
#     s = ssebop.Collection(**args)
#     assert utils.getinfo(s.geometry) ==


# TODO: Test if a geojson string can be passed for the geometry
# def test_Collection_init_geometry_geojson():
#     assert False 
开发者ID:Open-ET,项目名称:openet-ssebop-beta,代码行数:24,代码来源:test_d_collection.py

示例8: feature

# 需要导入模块: import ee [as 别名]
# 或者: from ee import Geometry [as 别名]
def feature(info):
    """ Dispatch a ee.Feature """
    geom = info.get('geometry')
    geomtype = geom.get('type')
    props = info.get('properties')

    # Contruct an accordion with the geometries
    acc = geometry(geom)
    children = list(acc.children)

    # Properties
    if props:
        # dispatch properties
        prop_acc = dispatch(props)
    else:
        prop_acc = dispatch('Feature has no properties')

    # Append properties as a child
    children.append(prop_acc.widget)
    acc.set_title(1, 'properties')
    acc.children = children
    acc.selected_index = None

    # Geometry Type
    typewid = dispatch(geomtype)


    return acc 
开发者ID:fitoprincipe,项目名称:ipygee,代码行数:30,代码来源:dispatcher.py

示例9: getGeojsonTile

# 需要导入模块: import ee [as 别名]
# 或者: from ee import Geometry [as 别名]
def getGeojsonTile(geometry, name=None,
                   inspect={'data':None, 'reducer':None, 'scale':None}):
    ''' Get a GeoJson giving a ee.Geometry or ee.Feature '''

    if isinstance(geometry, ee.Feature):
        feat = geometry
        geometry = feat.geometry()
    else:
        feat = None

    info = geometry.getInfo()
    type = info['type']

    gjson_types = ['Polygon', 'LineString', 'MultiPolygon',
                   'LinearRing', 'MultiLineString', 'MultiPoint',
                   'Point', 'Polygon', 'Rectangle',
                   'GeometryCollection']

    # newname = name if name else "{} {}".format(type, map.added_geometries)

    if type in gjson_types:
        data = inspect['data']
        if feat:
            default_popup = featurePropertiesOutput(feat)
        else:
            default_popup = type
        red = inspect.get('reducer','first')
        sca = inspect.get('scale', None)
        popval = getData(geometry, data, red, sca, name) if data else default_popup
        geojson = geometry.getInfo()

        return {'geojson':geojson,
                'pop': popval}
        # 'name': newname}
    else:
        print('unrecognized object type to add to map') 
开发者ID:fitoprincipe,项目名称:ipygee,代码行数:38,代码来源:maptools.py

示例10: getData

# 需要导入模块: import ee [as 别名]
# 或者: from ee import Geometry [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

示例11: addedGeometries

# 需要导入模块: import ee [as 别名]
# 或者: from ee import Geometry [as 别名]
def addedGeometries(self):
        return sum(
            [1 for val in self.EELayers.values() if val['type'] == 'Geometry']) 
开发者ID:fitoprincipe,项目名称:ipygee,代码行数:5,代码来源:map.py

示例12: addGeometry

# 需要导入模块: import ee [as 别名]
# 或者: from ee import Geometry [as 别名]
def addGeometry(self, geometry, visParams=None, name=None, show=True,
                    opacity=None, replace=True,
                    inspect={'data':None, 'reducer':None, 'scale':None}):
        """ Add a Geometry to the Map

        :param geometry: the Geometry to add to Map
        :type geometry: ee.Geometry
        :param visParams:
        :type visParams: dict
        :param name: name for the layer
        :type name: str
        :param inspect: when adding a geometry or a feature you can pop up data
            from a desired layer. Params are:
            :data: the EEObject where to get the data from
            :reducer: the reducer to use
            :scale: the scale to reduce
        :type inspect: dict
        :return: the name of the added layer
        :rtype: str
        """
        thename = name if name else 'Geometry {}'.format(self.addedGeometries)

        # Check if layer exists
        if thename in self.EELayers.keys():
            if not replace:
                print("Layer with name '{}' exists already, please choose another name".format(thename))
                return
            else:
                self.removeLayer(thename)

        params = getGeojsonTile(geometry, thename, inspect)
        layer = ipyleaflet.GeoJSON(data=params['geojson'],
                                   name=thename,
                                   popup=HTML(params['pop']))

        self._add_EELayer(thename, {'type': 'Geometry',
                                    'object': geometry,
                                    'visParams':None,
                                    'layer': layer})
        return thename 
开发者ID:fitoprincipe,项目名称:ipygee,代码行数:42,代码来源:map.py

示例13: getCenter

# 需要导入模块: import ee [as 别名]
# 或者: from ee import Geometry [as 别名]
def getCenter(self):
        """ Returns the coordinates at the center of the map.

        No arguments.
        Returns: Geometry.Point

        :return:
        """
        center = self.center
        coords = inverseCoordinates(center)
        return ee.Geometry.Point(coords) 
开发者ID:fitoprincipe,项目名称:ipygee,代码行数:13,代码来源:map.py

示例14: anglestats

# 需要导入模块: import ee [as 别名]
# 或者: from ee import Geometry [as 别名]
def anglestats(current,prev):
    ''' get dictionary of incident angle statistics of current image and append to list '''
    prev = ee.Dictionary(prev)
    rect = ee.Geometry(prev.get('rect'))
    stats = ee.List(prev.get('stats'))
    current = ee.Image(current).select('angle')
    meana = current.reduceRegion(ee.Reducer.mean(),geometry=rect,maxPixels= 1e9).get('angle')
    mina = current.reduceRegion(ee.Reducer.min(),geometry=rect,maxPixels= 1e9).get('angle')
    maxa = current.reduceRegion(ee.Reducer.max(),geometry=rect,maxPixels= 1e9).get('angle')
    stats = stats.add(ee.Dictionary({'mina':mina,'meana':meana,'maxa':maxa}))
    return ee.Dictionary({'stats':stats,'rect':rect}) 
开发者ID:mortcanty,项目名称:earthengine,代码行数:13,代码来源:app.py

示例15: testValid_Point

# 需要导入模块: import ee [as 别名]
# 或者: from ee import Geometry [as 别名]
def testValid_Point(self):
    """Verifies Point constructor behavior with valid arguments."""
    self.assertValid(1, ee.Geometry.Point, [1, 2])
    self.assertValid(1, ee.Geometry.Point, 1, 2) 
开发者ID:mortcanty,项目名称:earthengine,代码行数:6,代码来源:geometry_test.py


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