2

I was using a Google Earth Engine(GEE) account and the corresponding Google Drive storage was very less for me.I extended the drive storage for my another Google account and activated GEE for that account. I had lots of data within different assets of previous account. For transferring them I'm following these procedure:

  1. Share each asset with my second account.
  2. Using ee.Image()/ee.FeatureCollection() etc. Is there any way to transfer an entire Assets at a time rather than transferring each files within it one by one?

2 Answers 2

6

Yes, one way is to use the earthengine python API. First create a new folder through the code editor for your destination folder.

Then you can run this peace of code in a jupyter notebook (or colab)

import ee
ee.Initialize()

# folder from where to copy
src_folder = "projects/earthengine-legacy/assets/users/username/old_folder"
# folder where to copy
dest_folder = "projects/earthengine-legacy/assets/users/username/new_folder"

# get all assets in the folder
assets = ee.data.listAssets({'parent': src_folder})

# loop through assets and copy them one by one to the new destination
for asset in assets['assets']:
    # construct destination path
    new_asset = dest_folder + '/' + asset['id'].split('/')[-1]
    # copy to destination
    ee.data.copyAsset(asset['id'], new_asset, True)
    # delete source asset
    ee.data.deleteAsset(asset['id'])
0

I wasn't very satsfied by the vanilla method provided in the ee.data module so I coded it in geetools plugin lib.

Using the Asset object, on can call the move methods directly from a folder and define a destination. All the children will be moved as well and deleted from the source location. It work recursively for any tree depth:

import ee, geetools

src = ee.Asset("projects/bar/assets/foo")
dst = ee.Asset("projects/bar/assets/new_foo")
src.move(dst)

See more information in Asset documentation page.

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.