0

I'm connecting to the Earth Engine API through a service account :

service_account = '[email protected]'
credentials = ee.ServiceAccountCredentials(service_account, 'test.json')
ee.Initialize(credentials)

but I cannot access my assets. when I try to execute :

ee.data.getAssetRoots()[0]['id']

That should give me the root folder name of my assets. Instead I get the following error :

IndexError: list index out of range

because the list is empty...

Is it a normal behaviour ? How can I access my assets ?

1 Answer 1

1

Using a service account you cannot access directly the assets of your personnal account.

A nice trick is possible though.

Create a new folder in your assets go to it's sharing preferences and add your service account as reader or writer of the folder

enter image description here

Then you can access the folder assets content via :

folder = 'projects/earthengine-legacy/assets/users/username/folder_name'
assets = ee.data.listAssets({'parent': folder})['assets']

Note

If you want to interact with the folder content you need to change the sharing parameters of its assset individually The writer/reader sharing option of the folder does not extend to its content

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.