Wrapper for easier data management with Earth Engine python sdk
Requires account with access to Google Cloud Storage and Earth Engine.
import eeUtil
# initialize from environment variables
eeUtil.init(project='my-project', bucket='my-bucket')
# create image collection
eeUtil.createFolder('mycollection', imageCollection=True)
# upload image to collection
eeUtil.uploadAsset('image.tif', 'mycollection/myasset')
eeUtil.setAcl('mycollection', 'public')
eeUtil.ls('mycollection')
# export image to cloud storage and download
eeUtil.downloadAsset('mycollection/myasset')
Install
pip install eeUtil
Develop
git clone https://github.com/fgassert/eeUtil.git
cd eeUtil
pip install -e .
- More consistent python bindings
- Adds recursive
copy,move,remove,setAcl,createFolder. - GEE paths not starting with
/,users/projects/are relative to your user root folder (users/<username>orprojects/<project-id>/assets) uploadanddownloadstage files via Google Cloud Storage so you don't have to.
The easiest way to authorize eeUtil is using service account credentials. Once you create a service account and download your credentials.json set these in your environment.
export GOOGLE_APPLICATION_CREDENTIALS=path/to/credentials.json
Initalize these credentials by calling eeUtil.init().
eeUtil.init()
If you don't provide credentials to eeUtil.init(), it defaults to reading from credentials from the environment, and attempts to read credentials as saved by earthengine authenticate for Earth Engine and gcloud auth application-default login for Google Cloud Storage.
eeUtil.init(service_account=GEE_SERVICE_ACCOUNT,
credential_path=GOOGLE_APPLICATION_CREDENTIALS,
project=GEE_PROJECT,
bucket=GEE_STAGING_BUCKET,
credential_json=GEE_JSON)
service_accountService account name. For more information on GEE service accounts, see: https://developers.google.com/earth-engine/service_account[default: GEE_SERVICE_ACCOUNT]credential_pathPath to json file containing private key. This orcredential_jsonis required for service accounts.[default: GOOGLE_APPLICATION_CREDENTIALS]projectProject to use for GEE and GCS bucket.[default: GEE_PROJECT or CLOUDSDK_CORE_PROJECT]bucketStorage bucket for staging assets for ingestion. Will create new bucket if none provided.[default: GEE_STAGING_BUCKET]credential_jsonPass json string as alternative tocredential_path.[default: GEE_JSON]