本文整理汇总了Python中ee.Initialize方法的典型用法代码示例。如果您正苦于以下问题:Python ee.Initialize方法的具体用法?Python ee.Initialize怎么用?Python ee.Initialize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ee
的用法示例。
在下文中一共展示了ee.Initialize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: quota
# 需要导入模块: import ee [as 别名]
# 或者: from ee import Initialize [as 别名]
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"]
)
)
示例2: image_move
# 需要导入模块: import ee [as 别名]
# 或者: from ee import Initialize [as 别名]
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
示例3: table_move
# 需要导入模块: import ee [as 别名]
# 或者: from ee import Initialize [as 别名]
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
示例4: assetsize
# 需要导入模块: import ee [as 别名]
# 或者: from ee import Initialize [as 别名]
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
示例5: fparse
# 需要导入模块: import ee [as 别名]
# 或者: from ee import Initialize [as 别名]
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
示例6: fparse
# 需要导入模块: import ee [as 别名]
# 或者: from ee import Initialize [as 别名]
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
示例7: pytest_configure
# 需要导入模块: import ee [as 别名]
# 或者: from ee import Initialize [as 别名]
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()
示例8: testInitialization
# 需要导入模块: import ee [as 别名]
# 或者: from ee import Initialize [as 别名]
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)
示例9: ee_init
# 需要导入模块: import ee [as 别名]
# 或者: from ee import Initialize [as 别名]
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)
示例10: InitializeApi
# 需要导入模块: import ee [as 别名]
# 或者: from ee import Initialize [as 别名]
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, '')
示例11: setup_testfolder
# 需要导入模块: import ee [as 别名]
# 或者: from ee import Initialize [as 别名]
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
示例12: report
# 需要导入模块: import ee [as 别名]
# 或者: from ee import Initialize [as 别名]
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)
示例13: planet_key_entry
# 需要导入模块: import ee [as 别名]
# 或者: from ee import Initialize [as 别名]
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")
示例14: initialize
# 需要导入模块: import ee [as 别名]
# 或者: from ee import Initialize [as 别名]
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))
示例15: tasks
# 需要导入模块: import ee [as 别名]
# 或者: from ee import Initialize [as 别名]
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")))