TransWikia.com

Accessing personal assets if connected through service account to Google Earth Engine

Geographic Information Systems Asked on December 8, 2020

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 ?

One Answer

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

Correct answer by Pierrick Rambaud on December 8, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP