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


Python ee.Projection方法代码示例

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


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

示例1: __init__

# 需要导入模块: import ee [as 别名]
# 或者: from ee import Projection [as 别名]
def __init__(self, season, range=(0, 0), colgroup=None, scores=None,
                 masks=None, filters=None, target_collection=None, brdf=False,
                 harmonize=True, projection=None, **kwargs):
        self.range = range
        self.scores = scores
        self.masks = masks or ()
        self.filters = filters or ()
        self.season = season
        self.colgroup = colgroup
        self.brdf = brdf
        self.harmonize = harmonize
        self.projection = projection or ee.Projection('EPSG:3857')

        if target_collection is None:
            target_collection = collection.Landsat8SR()
        self.target_collection = target_collection

        self.score_name = kwargs.get('score_name', 'score')

        # Band names in case user needs different names
        self.bandname_col_id = kwargs.get('bandname_col_id', 'col_id')
        self.bandname_date = kwargs.get('bandname_date', 'date') 
开发者ID:fitoprincipe,项目名称:geebap,代码行数:24,代码来源:bap.py

示例2: testDynamicConstructorCasting

# 需要导入模块: import ee [as 别名]
# 或者: from ee import Projection [as 别名]
def testDynamicConstructorCasting(self):
    """Test the behavior of casting with dynamic classes."""
    self.InitializeApi()
    result = ee.Geometry.Rectangle(1, 1, 2, 2).bounds(0, 'EPSG:4326')
    expected = (ee.Geometry.Polygon([[1, 2], [1, 1], [2, 1], [2, 2]])
                .bounds(ee.ErrorMargin(0), ee.Projection('EPSG:4326')))
    self.assertEquals(expected, result) 
开发者ID:mortcanty,项目名称:earthengine,代码行数:9,代码来源:ee_test.py

示例3: centerObject

# 需要导入模块: import ee [as 别名]
# 或者: from ee import Projection [as 别名]
def centerObject(feature, zoom=None):
    """
        Centers the map view on a given object.

        https://developers.google.com/earth-engine/api_docs#map.centerobject

        Uses:
            >>> from ee_plugin import Map
            >>> Map.centerObject(feature)
    """


    feature = ee.Feature(feature)

    if not zoom:
        # make sure our geometry is in geo
        rect = feature.geometry().transform(ee.Projection('EPSG:4326'), 1)

        # get coordinates
        coords = rect.bounds().getInfo()['coordinates'][0]
        xmin = coords[0][0]
        ymin = coords[0][1]
        xmax = coords[2][0]
        ymax = coords[2][1]

        # construct QGIS geometry
        rect = QgsRectangle(xmin, ymin, xmax, ymax)

        # transform rect to a crs used by current project
        crs_src = QgsCoordinateReferenceSystem(4326)
        crs_dst = QgsCoordinateReferenceSystem(QgsProject.instance().crs())
        geo2proj = QgsCoordinateTransform(crs_src, crs_dst, QgsProject.instance())
        rect_proj = geo2proj.transform(rect)

        # center geometry
        iface.mapCanvas().zoomToFeatureExtent(rect_proj)
    else:
        # set map center to feature centroid at a specified zoom
        center = feature.geometry().centroid().coordinates().getInfo()
        setCenter(center[0], center[1], zoom) 
开发者ID:gee-community,项目名称:qgis-earthengine-plugin,代码行数:42,代码来源:Map.py

示例4: fromGeoJSON

# 需要导入模块: import ee [as 别名]
# 或者: from ee import Projection [as 别名]
def fromGeoJSON(filename=None, data=None, crs=None):
    """ Create a list of Features from a GeoJSON file. Return a python tuple
    with ee.Feature inside. This is due to failing when attempting to create a
    FeatureCollection (Broken Pipe ERROR) out of the list. You can try creating
    it yourself casting the result of this function to a ee.List or using it
    directly as a FeatureCollection argument.

    :param filename: the name of the file to load
    :type filename: str
    :param crs: a coordinate reference system in EPSG format. If not specified
        it will try to get it from the geoJSON, and if not there it will rise
        an error
    :type: crs: str
    :return: a tuple of features.
    """
    if filename:
        with open(filename, 'r') as geoj:
            content = geoj.read()
            geodict = json.loads(content)
    else:
        geodict = data

    features = []
    # Get crs from GeoJSON
    if not crs:
        filecrs = geodict.get('crs')
        if filecrs:
            name = filecrs.get('properties').get('name')
            splitcrs = name.split(':')
            cleancrs = [part for part in splitcrs if part]
            try:
                if cleancrs[-1] == 'CRS84':
                    crs = 'EPSG:4326'
                elif cleancrs[-2] == 'EPSG':
                    crs = '{}:{}'.format(cleancrs[-2], cleancrs[-1])
                else:
                    raise ValueError('{} not recognized'.format(name))
            except IndexError:
                raise ValueError('{} not recognized'.format(name))
        else:
            crs = 'EPSG:4326'

    for n, feat in enumerate(geodict.get('features')):
        properties = feat.get('properties')
        geom = feat.get('geometry')
        ty = geom.get('type')
        coords = geom.get('coordinates')
        if ty == 'GeometryCollection':
            ee_geom = utils.GEOMETRY_TYPES.get(ty)(geom, opt_proj=crs)
        else:
            if ty == 'Polygon':
                coords = utils.removeZ(coords) if utils.hasZ(coords) else coords
            ee_geom = utils.GEOMETRY_TYPES.get(ty)(coords, proj=ee.Projection(crs))
        ee_feat = ee.feature.Feature(ee_geom, properties)
        features.append(ee_feat)

    return tuple(features) 
开发者ID:gee-community,项目名称:gee_tools,代码行数:59,代码来源:featurecollection.py


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