Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python API: fix ee.data.create_assets() when creating parents folders #185

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jbardo
Copy link

@jbardo jbardo commented Jul 23, 2022

When calling ee.data.create_assets() with mk_parents=True, for example via the cli:

earthengine create folder --parents projects/<project_id>/assets/a/b/c

we systematically get the following error:

TypeError: Parameter "name" value "projects/<project_id>/assets" does not match the pattern "^projects/[^/]+/assets/.*$"

It seems the code still refers to an outdated organization user/project instead of projects/<project_id>/assets.

@google-cla
Copy link

google-cla bot commented Jul 23, 2022

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@jbardo jbardo changed the title Python API: fix ee.data.create_assets() when recursively creating parents Python API: fix ee.data.create_assets() when creating parents folders Jul 23, 2022
@bhagya0yashree
Copy link

bhagya0yashree commented Mar 5, 2024

import os

Replace with your Google Earth Engine project ID

PROJECT_ID = "project id"

Replace with the path to your folder containing .tif files

FOLDER_PATH = "path to the folder"

Function to upload a single image

def upload_image(image_path, asset_id):
"""
Uploads a .tif image to the specified GEE asset ID.
"""
from earthengine import ee

Initialize Earth Engine

ee.Initialize(authenticate=True)

Upload the image

task = ee.batch.Upload.image(image_path, asset_id=asset_id, project=PROJECT_ID)
task.start()
print(f'Uploading {image_path} to {asset_id}...')
task.await()
print('Upload complete!')

Loop through files in the folder and upload them

for filename in os.listdir(FOLDER_PATH):
if filename.endswith('.tif'):
# Construct asset ID with filename (replace with desired structure)
asset_id = f'users/{os.path.splitext(filename)[0]}'
image_path = os.path.join(FOLDER_PATH, filename)
upload_image(image_path, asset_id) and this is the error message i'm getting : task.await()
^^^^^
SyntaxError: invalid syntax
So basically I was trying upload image folder from my desktop to my GEE account using this python script but somehow I'm getting error messages and I'm not able to fix it. can @sufyanAbbasi help me with this?

@dchirst
Copy link

dchirst commented Aug 22, 2024

Is there any progress on this? We face the same issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants