Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Initializing an earth engine project in Colab

I can no longer initailize my own earth engine project on Google colab using Python.

I tried initializing using the ee.Initialize() method on Colab with used to provide with a link that will generate a token to my project but instead i get this error:

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

.

like image 709
MohaFox Avatar asked Aug 02 '26 03:08

MohaFox


2 Answers

Their lack of documentation on this change is incredibly frustrating, but fortunately it's a very easy fix (or at least it was for me).

If you go to your earth engine code editor and click on the 'Assets' tab, then copy the name of the Project that all of your EE assets are that you're trying to access.see linked image here:

Then, at the initialization step in your colab script, you replace 'ee.Initialize()' with 'ee.Initiliaze(project='NameofYourEarthEngineProject')

Hope this helps.

like image 185
elevenson Avatar answered Aug 04 '26 15:08

elevenson


There is also a solution offered here

It involves going into your Google Cloud account and explicitely activating the GEE api, then creating a new project which you end up specifying when calling ee.Initialize(). The benefit of this is that when you call GEE from Colab, you no longer get that convoluted series of clicks and links to get a token, it just runs and activates. Frustrating at first but in the long term, it's a time saver.

like image 29
Patrice Carbonneau Avatar answered Aug 04 '26 16:08

Patrice Carbonneau



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!