Python ee.Initialize() Examples
The following are 30
code examples of ee.Initialize().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
ee
, or try the search function
.
Example #1
Source File: conftest.py From openet-ssebop-beta with Apache License 2.0 | 6 votes |
def pytest_configure(): # Called before tests are collected # https://docs.pytest.org/en/latest/reference.html#_pytest.hookspec.pytest_sessionstart logging.basicConfig(level=logging.DEBUG, format='%(message)s') logging.getLogger('googleapiclient').setLevel(logging.ERROR) logging.debug('Test Setup') # On Travis-CI authenticate using private key environment variable if 'EE_PRIVATE_KEY_B64' in os.environ: print('Writing privatekey.json from environmental variable ...') content = base64.b64decode(os.environ['EE_PRIVATE_KEY_B64']).decode('ascii') GEE_KEY_FILE = 'privatekey.json' with open(GEE_KEY_FILE, 'w') as f: f.write(content) ee.Initialize(ee.ServiceAccountCredentials('', key_file=GEE_KEY_FILE)) else: ee.Initialize()
Example #2
Source File: acl_changer.py From gee_asset_manager_addon with Apache License 2.0 | 6 votes |
def fparse(path): ee.Initialize() if ee.data.getAsset(path)["type"].lower() == "folder": gee_folder_path = recursive(path) for folders in gee_folder_path: children = ee.data.listAssets({"parent": "projects/earthengine-legacy/assets/{}".format(folders)}) for child in children['assets']: if child["type"].lower() == "image_collection": collection_list.append(child["id"]) elif child["type"].lower() == "image": image_list.append(child["id"]) elif child["type"].lower() == "table": table_list.append(child["id"]) elif ee.data.getAsset(path)["type"].lower() == "image": image_list.append(path) elif ee.data.getAsset(path)["type"].lower() == "image_collection": collection_list.append(path) elif ee.data.getAsset(path)["type"].lower() == "table": table_list.append(path) else: print(ee.data.getAsset(path)["type"].lower()) return [collection_list, table_list, image_list, folder_paths] ##request type of asset, asset path and user to give permission
Example #3
Source File: ee_report.py From gee_asset_manager_addon with Apache License 2.0 | 6 votes |
def fparse(path): ee.Initialize() if ee.data.getAsset(path)["type"].lower() == "folder": gee_folder_path = recursive(path) for folders in gee_folder_path: children = ee.data.listAssets({"parent": folders}) for child in children["assets"]: if child["type"].lower() == "image_collection": collection_list.append(child["id"]) elif child["type"].lower() == "image": image_list.append(child["id"]) elif child["type"].lower() == "table": table_list.append(child["id"]) elif ee.data.getAsset(path)["type"].lower() == "image": image_list.append(path) elif ee.data.getAsset(path)["type"].lower() == "image_collection": collection_list.append(path) elif ee.data.getAsset(path)["type"].lower() == "table": table_list.append(path) else: print(ee.data.getAsset(path)["type"].lower()) return [collection_list, table_list, image_list, folder_paths] ##request type of asset, asset path and user to give permission
Example #4
Source File: ee_report.py From gee_asset_manager_addon with Apache License 2.0 | 6 votes |
def assetsize(asset): ee.Initialize() header = ee.data.getAsset(asset)["type"] if header == "IMAGE_COLLECTION": collc = ee.ImageCollection(asset) size = collc.aggregate_array("system:asset_size") return [str(humansize(sum(size.getInfo()))), collc.size().getInfo()] elif header == "IMAGE": collc = ee.Image(asset) return [str(humansize(collc.get("system:asset_size").getInfo())), 1] elif header == "TABLE": collc = ee.FeatureCollection(asset) return [str(humansize(collc.get("system:asset_size").getInfo())), 1] elif header == "FOLDER": num = subprocess.check_output( "earthengine --no-use_cloud_api ls " + asset, shell=True ).decode("ascii") return ["NA", len(num.split("\n")) - 1] # folder parse
Example #5
Source File: batch_mover.py From gee_asset_manager_addon with Apache License 2.0 | 6 votes |
def table_move(initial, replace_string, replaced_string, fpath): ee.Initialize() if replace_string == replaced_string or replace_string == None: final = fpath else: final = initial.replace(replace_string, replaced_string) try: if ee.data.getAsset(final): print("Table already moved: {}".format(final)) except Exception: print("Moving table to {}".format(final)) try: ee.data.renameAsset(initial, final) except Exception as e: print(e) # Collection copy
Example #6
Source File: batch_mover.py From gee_asset_manager_addon with Apache License 2.0 | 6 votes |
def image_move(initial, replace_string, replaced_string, fpath): ee.Initialize() if replace_string == replaced_string or replace_string == None: final = fpath else: final = initial.replace(replace_string, replaced_string) try: if ee.data.getAsset(final): print("Image already moved: {}".format(final)) except Exception: print("Moving image to {}".format(final)) try: ee.data.renameAsset(initial, final) except Exception as e: print(e) # Table copy
Example #7
Source File: geeadd.py From gee_asset_manager_addon with Apache License 2.0 | 6 votes |
def quota(): ee.Initialize() for roots in ee.data.getAssetRoots(): quota = ee.data.getAssetRootQuota(roots["id"]) print("") print( "Root assets path: {}".format( roots["id"].replace("projects/earthengine-legacy/assets/", "") ) ) print( "Used {} of {}".format( humansize(quota["asset_size"]["usage"]), humansize(quota["asset_size"]["limit"]), ) ) print( "Used {:,} assets of {:,} total".format( quota["asset_count"]["usage"], quota["asset_count"]["limit"] ) )
Example #8
Source File: geeadd.py From gee_asset_manager_addon with Apache License 2.0 | 5 votes |
def assetsize(asset): ee.Initialize() header = ee.data.getAsset(asset)["type"] if header == "IMAGE_COLLECTION": collc = ee.ImageCollection(asset) size = collc.aggregate_array("system:asset_size") print("") print(str(asset) + " ===> " + str(humansize(sum(size.getInfo())))) print("Total number of items in collection: {}".format(collc.size().getInfo())) elif header == "IMAGE": collc = ee.Image(asset) print("") print( str(asset) + " ===> " + str(humansize(collc.get("system:asset_size").getInfo())) ) elif header == "TABLE": collc = ee.FeatureCollection(asset) print("") print( str(asset) + " ===> " + str(humansize(collc.get("system:asset_size").getInfo())) ) elif header == "FOLDER": b = subprocess.check_output( "earthengine --no-use_cloud_api du " + asset + " -s", shell=True ).decode("ascii") num = subprocess.check_output( "earthengine --no-use_cloud_api ls " + asset, shell=True ).decode("ascii") size = humansize(float(b.strip().split(" ")[0])) print("") print(str(asset) + " ===> " + str(size)) print("Total number of items in folder: {}".format(len(num.split("\n")) - 1))
Example #9
Source File: oauth.py From gee_tools with MIT License | 5 votes |
def Initialize(filename, credential_path='default'): """ Authenticate to GEE with the specified credentials If credential_path is set to 'defualt', it searches for the 'filename' in the same folder in which credentials are stored locally """ if credential_path == 'default': credential_path = os.path.split(ee.oauth.get_credentials_path())[0] path = os.path.join(credential_path, filename) def get_credentials(): try: tokens = json.load(open(path)) refresh_token = tokens['refresh_token'] return Credentials( None, refresh_token=refresh_token, token_uri=ee.oauth.TOKEN_URI, client_id=ee.oauth.CLIENT_ID, client_secret=ee.oauth.CLIENT_SECRET, scopes=ee.oauth.SCOPES) except IOError: raise ee.EEException( 'Please authorize access to your Earth Engine account by ' 'running\n\nearthengine authenticate\n\nin your command line, and then ' 'retry.') credentials = get_credentials() ee.Initialize(credentials)
Example #10
Source File: oauth.py From gee_tools with MIT License | 5 votes |
def rename_current_user(name, credential_path=DEFAULT_PATH): """ Rename the current user. If you run `ee.Initialize()` after this you will be ask to initialize. """ origin = ee.oauth.get_credentials_path() destination = os.path.join(credential_path, name) shutil.move(origin, destination)
Example #11
Source File: exporting.py From pycrop-yield-prediction with MIT License | 5 votes |
def __init__(self, locations_filepath=Path('data/yield_data.csv'), collection_id='MODIS/051/MCD12Q1'): self.locations = load(locations_filepath) self.collection_id = collection_id try: ee.Initialize() print('The Earth Engine package initialized successfully!') except ee.EEException: print('The Earth Engine package failed to initialize! ' 'Have you authenticated the earth engine?')
Example #12
Source File: ee_auth.py From qgis-earthengine-plugin with MIT License | 5 votes |
def init(): try: ee.Initialize() except ee.ee_exception.EEException: authenticate() ee.Initialize() # retry initialization once the user logs in
Example #13
Source File: batch_uploader.py From geeup with Apache License 2.0 | 5 votes |
def __get_google_auth_session(username, password): ee.Initialize() options = Options() options.add_argument('-headless') uname=str(username) passw=str(password) if os.name=="nt": driver = Firefox(executable_path=os.path.join(lp,"geckodriver.exe"),firefox_options=options) else: driver = Firefox(executable_path=os.path.join(lp,"geckodriver"),firefox_options=options) try: # Using stackoverflow for third-party login & redirect driver.get('https://stackoverflow.com/users/signup?ssrc=head&returnurl=%2fusers%2fstory%2fcurrent%27') time.sleep(5) driver.find_element_by_xpath('//*[@id="openid-buttons"]/button[1]').click() time.sleep(5) driver.find_element_by_xpath('//input[@type="email"]').send_keys(uname) driver.find_element_by_xpath("//div[@id='identifierNext']/span/span").click() time.sleep(5) driver.find_element_by_xpath('//input[@type="password"]').send_keys(passw) driver.find_element_by_xpath('//*[@id="passwordNext"]').click() time.sleep(5) driver.get('https://code.earthengine.google.com') time.sleep(8) except Exception as e: print(e) driver.close() sys.exit('Failed to setup & use selenium') cookies = driver.get_cookies() session = requests.Session() for cookie in cookies: session.cookies.set(cookie['name'], cookie['value']) driver.close() return session
Example #14
Source File: ee_test.py From earthengine with MIT License | 5 votes |
def testInitialization(self): """Verifies library initialization.""" def MockSend(path, params, unused_method=None, unused_raw=None): if path == '/algorithms': return {} else: raise Exception('Unexpected API call to %s with %s' % (path, params)) ee.data.send_ = MockSend # Verify that the base state is uninitialized. self.assertFalse(ee.data._initialized) self.assertEquals(ee.data._api_base_url, None) self.assertEquals(ee.ApiFunction._api, None) self.assertFalse(ee.Image._initialized) # Verify that ee.Initialize() sets the URL and initializes classes. ee.Initialize(None, 'foo') self.assertTrue(ee.data._initialized) self.assertEquals(ee.data._api_base_url, 'foo/api') self.assertEquals(ee.ApiFunction._api, {}) self.assertTrue(ee.Image._initialized) # Verify that ee.Initialize(None) does not override custom URLs. ee.Initialize(None) self.assertTrue(ee.data._initialized) self.assertEquals(ee.data._api_base_url, 'foo/api') # Verify that ee.Reset() reverts everything to the base state. ee.Reset() self.assertFalse(ee.data._initialized) self.assertEquals(ee.data._api_base_url, None) self.assertEquals(ee.ApiFunction._api, None) self.assertFalse(ee.Image._initialized)
Example #15
Source File: geeadd.py From gee_asset_manager_addon with Apache License 2.0 | 5 votes |
def tasks(): ee.Initialize() statuses = ee.data.listOperations() st = [] for status in statuses: st.append(status["metadata"]["state"]) print("Tasks Running: " + str(st.count("RUNNING"))) print("Tasks Ready: " + str(st.count("READY"))) print("Tasks Completed: " + str(st.count("COMPLETED"))) print("Tasks Failed: " + str(st.count("FAILED"))) print("Tasks Cancelled: " + str(st.count("CANCELLED")))
Example #16
Source File: ppipe.py From Planet-GEE-Pipeline-CLI with Apache License 2.0 | 5 votes |
def planet_key_entry(args): if args.type == "quiet": write_planet_json({"key": args.key}) elif args.type == None and args.key == None: try: subprocess.call("planet init", shell=True) except Exception as e: print("Failed to Initialize")
Example #17
Source File: utils.py From earthengine with MIT License | 5 votes |
def ee_init(self): """Load the EE credentils and initialize the EE client.""" if self.account and self.private_key: credentials = ee.ServiceAccountCredentials(self.account, self.private_key) elif self.refresh_token: credentials = oauth2client.client.OAuth2Credentials( None, ee.oauth.CLIENT_ID, ee.oauth.CLIENT_SECRET, self.refresh_token, None, 'https://accounts.google.com/o/oauth2/token', None) else: credentials = 'persistent' ee.Initialize(credentials=credentials, opt_url=self.url)
Example #18
Source File: apitestcase.py From aqua-monitor with GNU Lesser General Public License v3.0 | 5 votes |
def InitializeApi(self): """Initializes the library with standard API methods. This is normally invoked during setUp(), but subclasses may invoke it manually instead if they prefer. """ self.last_download_call = None self.last_thumb_call = None self.last_table_call = None ee.data.send_ = self.MockSend ee.Reset() ee.Initialize(None, '')
Example #19
Source File: utils.py From aqua-monitor with GNU Lesser General Public License v3.0 | 5 votes |
def ee_init(self): """Load the EE credentils and initialize the EE client.""" if self.account and self.private_key: credentials = ee.ServiceAccountCredentials(self.account, self.private_key) elif self.refresh_token: credentials = oauth2client.client.OAuth2Credentials( None, ee.oauth.CLIENT_ID, ee.oauth.CLIENT_SECRET, self.refresh_token, None, 'https://accounts.google.com/o/oauth2/token', None) else: credentials = 'persistent' ee.Initialize(credentials=credentials, opt_url=self.url)
Example #20
Source File: apitestcase.py From earthengine with MIT License | 5 votes |
def InitializeApi(self): """Initializes the library with standard API methods. This is normally invoked during setUp(), but subclasses may invoke it manually instead if they prefer. """ self.last_download_call = None self.last_thumb_call = None self.last_table_call = None ee.data.send_ = self.MockSend ee.Reset() ee.Initialize(None, '')
Example #21
Source File: test_upload.py From gee_asset_manager with Apache License 2.0 | 5 votes |
def setup_testfolder(): ee.Initialize() root = ee.data.getAssetRoots()[0]['id'] testfolder_name = root + '/test_geebam_' + get_random_string(8) ee.data.createAsset({'type': ee.data.ASSET_TYPE_FOLDER}, testfolder_name) logging.info('Setting up test folder %s', testfolder_name) return testfolder_name
Example #22
Source File: ee_authenticate.py From CrisisMappingToolkit with Apache License 2.0 | 5 votes |
def initialize(account=None, key_file=None): '''Initialize the Earth Engine object, using your authentication credentials.''' try: ee.Initialize() except: # in the past, EE keys had to be installed manually. We keep this old method for # backwards compatibility if account == None: f = open(__MY_ACCOUNT_FILE, 'r') account = f.readline().strip() if key_file == None: key_file = __MY_PRIVATE_KEY_FILE ee.Initialize(ee.ServiceAccountCredentials(account, key_file))
Example #23
Source File: ee_test.py From aqua-monitor with GNU Lesser General Public License v3.0 | 5 votes |
def testInitialization(self): """Verifies library initialization.""" def MockSend(path, params, unused_method=None, unused_raw=None): if path == '/algorithms': return {} else: raise Exception('Unexpected API call to %s with %s' % (path, params)) ee.data.send_ = MockSend # Verify that the base state is uninitialized. self.assertFalse(ee.data._initialized) self.assertEquals(ee.data._api_base_url, None) self.assertEquals(ee.ApiFunction._api, None) self.assertFalse(ee.Image._initialized) # Verify that ee.Initialize() sets the URL and initializes classes. ee.Initialize(None, 'foo') self.assertTrue(ee.data._initialized) self.assertEquals(ee.data._api_base_url, 'foo/api') self.assertEquals(ee.ApiFunction._api, {}) self.assertTrue(ee.Image._initialized) # Verify that ee.Initialize(None) does not override custom URLs. ee.Initialize(None) self.assertTrue(ee.data._initialized) self.assertEquals(ee.data._api_base_url, 'foo/api') # Verify that ee.Reset() reverts everything to the base state. ee.Reset() self.assertFalse(ee.data._initialized) self.assertEquals(ee.data._api_base_url, None) self.assertEquals(ee.ApiFunction._api, None) self.assertFalse(ee.Image._initialized)
Example #24
Source File: batch_info.py From gee_asset_manager with Apache License 2.0 | 5 votes |
def report(filename): ee.Initialize() assets_root = ee.data.getAssetRoots() writer = ReportWriter(filename) writer.writerow(['Asset id', 'Type', 'Size [MB]', 'Time', 'Owners', 'Readers', 'Writers']) for asset in assets_root: # List size+name for every leaf asset, and show totals for non-leaves. if asset['type'] == ee.data.ASSET_TYPE_FOLDER: children = ee.data.getList(asset) for child in children: _print_size(child, writer) else: _print_size(asset, writer)
Example #25
Source File: acl_changer.py From gee_asset_manager_addon with Apache License 2.0 | 4 votes |
def access(collection_path, user, role): ee.Initialize() asset_list = fparse(collection_path) asset_names = list(itertools.chain(*asset_list)) print("Changing permission for total of " + str(len(asset_names)) + " items.....") for count, init in enumerate(asset_names): print("Working on ===> {}".format(init)) acl = ee.data.getAssetAcl(init) if role == "reader": if not user in acl["readers"]: baselist = acl["readers"] baselist.append(user) acl["readers"] = baselist acl["owners"] = [] try: ee.data.setAssetAcl(init, json.dumps(acl)) except Exception as e: print(e) else: print("user already has read access to this asset:SKIPPING") if role == "writer": if not user in acl["writers"]: baselist = acl["writers"] baselist.append(user) acl["readers"] = baselist acl["owners"] = [] try: ee.data.setAssetAcl(init, json.dumps(acl)) except Exception as e: print(e) else: print("user already has write access to this asset:SKIPPING") if role == "delete": if not user in acl["readers"]: print("user does not have permission:SKIPPING") else: baselist = acl["readers"] baselist.remove(user) acl["readers"] = baselist acl["owners"] = [] try: ee.data.setAssetAcl(init, json.dumps(acl)) except Exception as e: print(e)
Example #26
Source File: ee_test.py From earthengine with MIT License | 4 votes |
def testCallAndApply(self): """Verifies library initialization.""" # Use a custom set of known functions. def MockSend(path, params, unused_method=None, unused_raw=None): if path == '/algorithms': return { 'fakeFunction': { 'type': 'Algorithm', 'args': [ {'name': 'image1', 'type': 'Image'}, {'name': 'image2', 'type': 'Image'} ], 'returns': 'Image' }, 'Image.constant': apitestcase.BUILTIN_FUNCTIONS['Image.constant'] } else: raise Exception('Unexpected API call to %s with %s' % (path, params)) ee.data.send_ = MockSend ee.Initialize(None) image1 = ee.Image(1) image2 = ee.Image(2) expected = ee.Image(ee.ComputedObject( ee.ApiFunction.lookup('fakeFunction'), {'image1': image1, 'image2': image2})) applied_with_images = ee.apply( 'fakeFunction', {'image1': image1, 'image2': image2}) self.assertEquals(expected, applied_with_images) applied_with_numbers = ee.apply('fakeFunction', {'image1': 1, 'image2': 2}) self.assertEquals(expected, applied_with_numbers) called_with_numbers = ee.call('fakeFunction', 1, 2) self.assertEquals(expected, called_with_numbers) # Test call and apply() with a custom function. sig = {'returns': 'Image', 'args': [{'name': 'foo', 'type': 'Image'}]} func = ee.CustomFunction(sig, lambda foo: ee.call('fakeFunction', 42, foo)) expected_custom_function_call = ee.Image( ee.ComputedObject(func, {'foo': ee.Image(13)})) self.assertEquals(expected_custom_function_call, ee.call(func, 13)) self.assertEquals(expected_custom_function_call, ee.apply(func, {'foo': 13})) # Test None promotion. called_with_null = ee.call('fakeFunction', None, 1) self.assertEquals(None, called_with_null.args['image1'])
Example #27
Source File: cancel_tasks.py From openet-ssebop-beta with Apache License 2.0 | 4 votes |
def main(key=None, state='READY', regex=None): """Cancel Earth Engine tasks Parameters ---------- key : str, optional File path to an Earth Engine json key file. state : str, {'ALL', 'READY', 'RUNNING'} Task state (the default is to only cancel 'READY' tasks). regex : str, optional """ logging.info('\nCancelling {} tasks'.format(state.lower())) if state == 'ALL': states = ['READY', 'RUNNING'] else: states = [state] logging.info('\nInitializing Earth Engine') if key: logging.info(' Using service account key file: {}'.format(key)) # The "EE_ACCOUNT" parameter is not used if the key file is valid ee.Initialize(ee.ServiceAccountCredentials('deadbeef', key_file=key), use_cloud_api=True) else: ee.Initialize(use_cloud_api=True) # Get current task list tasks = utils.get_ee_tasks(states=states) if regex: logging.info('\nFiltering tasks:') logging.info('{}'.format(regex)) tasks = {task_desc: task_info for task_desc, task_info in tasks.items() if re.match(regex, task_desc)} logging.info('\nCancelling tasks:') for task_desc, task_info in tasks.items(): logging.info(task_desc) logging.debug(task_info) try: ee.data.cancelTask(task_info['id']) # ee.data.cancelOperation(tasks[export_id]['id']) except Exception as e: logging.info(' Exception: {}\n Skipping'.format(e))
Example #28
Source File: cancel_tasks.py From openet-ssebop-beta with Apache License 2.0 | 4 votes |
def main(key=None, state='READY', regex=None): """Cancel Earth Engine tasks Parameters ---------- key : str, optional File path to an Earth Engine json key file. state : str, {'ALL', 'READY', 'RUNNING'} Task state (the default is to only cancel 'READY' tasks). regex : str, optional """ logging.info('\nCancelling {} tasks'.format(state.lower())) if state == 'ALL': states = ['READY', 'RUNNING'] else: states = [state] logging.info('\nInitializing Earth Engine') if key: logging.info(' Using service account key file: {}'.format(key)) # The "EE_ACCOUNT" parameter is not used if the key file is valid ee.Initialize(ee.ServiceAccountCredentials('deadbeef', key_file=key), use_cloud_api=True) else: ee.Initialize(use_cloud_api=True) # Get current task list tasks = utils.get_ee_tasks(states=states) if regex: logging.info('\nFiltering tasks:') logging.info('{}'.format(regex)) tasks = {task_desc: task_info for task_desc, task_info in tasks.items() if re.match(regex, task_desc)} logging.info('\nCancelling tasks:') for task_desc, task_info in tasks.items(): logging.info(task_desc) logging.debug(task_info) try: ee.data.cancelTask(task_info['id']) # ee.data.cancelOperation(tasks[export_id]['id']) except Exception as e: logging.info(' Exception: {}\n Skipping'.format(e))
Example #29
Source File: ee_test.py From aqua-monitor with GNU Lesser General Public License v3.0 | 4 votes |
def testCallAndApply(self): """Verifies library initialization.""" # Use a custom set of known functions. def MockSend(path, params, unused_method=None, unused_raw=None): if path == '/algorithms': return { 'fakeFunction': { 'type': 'Algorithm', 'args': [ {'name': 'image1', 'type': 'Image'}, {'name': 'image2', 'type': 'Image'} ], 'returns': 'Image' }, 'Image.constant': apitestcase.BUILTIN_FUNCTIONS['Image.constant'] } else: raise Exception('Unexpected API call to %s with %s' % (path, params)) ee.data.send_ = MockSend ee.Initialize(None) image1 = ee.Image(1) image2 = ee.Image(2) expected = ee.Image(ee.ComputedObject( ee.ApiFunction.lookup('fakeFunction'), {'image1': image1, 'image2': image2})) applied_with_images = ee.apply( 'fakeFunction', {'image1': image1, 'image2': image2}) self.assertEquals(expected, applied_with_images) applied_with_numbers = ee.apply('fakeFunction', {'image1': 1, 'image2': 2}) self.assertEquals(expected, applied_with_numbers) called_with_numbers = ee.call('fakeFunction', 1, 2) self.assertEquals(expected, called_with_numbers) # Test call and apply() with a custom function. sig = {'returns': 'Image', 'args': [{'name': 'foo', 'type': 'Image'}]} func = ee.CustomFunction(sig, lambda foo: ee.call('fakeFunction', 42, foo)) expected_custom_function_call = ee.Image( ee.ComputedObject(func, {'foo': ee.Image(13)})) self.assertEquals(expected_custom_function_call, ee.call(func, 13)) self.assertEquals(expected_custom_function_call, ee.apply(func, {'foo': 13})) # Test None promotion. called_with_null = ee.call('fakeFunction', None, 1) self.assertEquals(None, called_with_null.args['image1'])
Example #30
Source File: ee_del_meta.py From gee_asset_manager_addon with Apache License 2.0 | 4 votes |
def delprop(collection_path, property): ee.Initialize() lst = [] header = ee.data.getInfo(collection_path)["type"] if header == "IMAGE": lst.append(collection_path) assets_names = lst if header == "IMAGE_COLLECTION": assets_list = ee.data.getList(params={"id": collection_path}) assets_names = [os.path.basename(asset["id"]) for asset in assets_list] print("Deleting metadata for total of " + str(len(assets_names)) + " assets.....") for count, items in enumerate(assets_names): if header == "IMAGE_COLLECTION": nullgrid = {property: None} init = collection_path + "/" + items try: print( "Processing " + str(count + 1) + " of " + str(len(assets_names)), end="\r", ) ee.data.setAssetProperties(init, nullgrid) except Exception as e: print( "Could not run " + str(count + 1) + " of " + str(len(assets_names)) ) print(e) if header == "IMAGE": nullgrid = {property: None} init = collection_path + "/" + items try: print( "Processing " + str(count + 1) + " of " + str(len(assets_names)), end="\r", ) ee.data.setAssetProperties(init, nullgrid) except Exception as e: print( "Could not run " + str(count + 1) + " of " + str(len(assets_names)) ) print(e) # delprop(collection_path='users/samapriya/LA_ASSET_EXP/LS_UNMX_OTSU_MEDOID',property='gridded') # ee.data.setAssetProperties(args.asset_id, properties)