在 Colab 启动地球引擎项目

问题描述 投票:0回答:2

我无法再使用 Python 在 Google

colab
上初始化我自己的地球引擎项目。

我尝试使用 Colab 上的

ee.Initialize()
方法进行初始化,用于提供一个链接,该链接将为我的项目生成令牌,但我收到此错误:

WARNING:googleapiclient.http:Encountered 403 Forbidden with reason "PERMISSION_DENIED"
---------------------------------------------------------------------------
HttpError                                 Traceback (most recent call last)
/usr/local/lib/python3.10/dist-packages/ee/data.py in _execute_cloud_call(call, num_retries)
    382   try:
--> 383     return call.execute(num_retries=num_retries)
    384   except googleapiclient.errors.HttpError as e:

7 frames
HttpError: <HttpError 403 when requesting https://earthengine.googleapis.com/v1/projects/earthengine-legacy/algorithms?prettyPrint=false&alt=json returned "Google Earth Engine API has not been used in project 522309567947 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/earthengine.googleapis.com/overview?project=522309567947 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.". Details: "[{'@type': 'type.googleapis.com/google.rpc.Help', 'links': [{'description': 'Google developers console API activation', 'url': 'https://console.developers.google.com/apis/api/earthengine.googleapis.com/overview?project=522309567947'}]}, {'@type': 'type.googleapis.com/google.rpc.ErrorInfo', 'reason': 'SERVICE_DISABLED', 'domain': 'googleapis.com', 'metadata': {'service': 'earthengine.googleapis.com', 'consumer': 'projects/522309567947'}}]">

During handling of the above exception, another exception occurred:

EEException                               Traceback (most recent call last)
/usr/local/lib/python3.10/dist-packages/ee/data.py in _execute_cloud_call(call, num_retries)
    383     return call.execute(num_retries=num_retries)
    384   except googleapiclient.errors.HttpError as e:
--> 385     raise _translate_cloud_exception(e)  # pylint: disable=raise-missing-from
    386 
    387 

EEException: Google Earth Engine API has not been used in project 522309567947 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/earthengine.googleapis.com/overview?project=522309567947 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry

.

python google-colaboratory google-earth-engine
2个回答
2
投票

他们缺乏有关此更改的文档,这令人非常沮丧,但幸运的是,这是一个非常简单的修复(或者至少对我来说)。

如果您转到 Earth 引擎代码编辑器并单击“资产”选项卡,然后复制您要访问的所有 EE 资产的项目名称。see linked image here:

然后,在 Colab 脚本的初始化步骤中,将 'ee.Initialize()' 替换为 'ee.Initiliaze(project='NameofYourEarthEngineProject')

希望这有帮助。


0
投票

还提供了解决方案这里

它涉及进入您的 Google Cloud 帐户并显式激活 GEE api,然后创建一个新项目,您最终在调用 ee.Initialize() 时指定该项目。这样做的好处是,当您从 Colab 调用 GEE 时,您不再需要通过一系列复杂的点击和链接来获取令牌,它只是运行并激活。一开始会令人沮丧,但从长远来看,这可以节省时间。

© www.soinside.com 2019 - 2024. All rights reserved.