Advertisement
biplovbhandari

ee_common_scripts

Mar 4th, 2024
858
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.03 KB | None | 0 0
  1. ee_username = 'projects/pyregence-ee/'
  2. asset_id_base = 'assets/prediction-output-frap-tsf/CA'
  3. bucket_name = 'prediction-output-frap-tsf'
  4. folder_path = '/Users/bbhandar/Downloads/prediction-output-frap-tsf/CA'
  5.  
  6. tiff_files = [f for f in os.listdir(folder_path) if f.endswith('.tif')]
  7.  
  8. for tiff_file in tiff_files:
  9.     asset_id = f'{ee_username}{asset_id_base}/Prediction-CA_{tiff_file.replace(".tif", "")}'
  10.     gcs_path = f'gs://{bucket_name}/{tiff_file}'
  11.     command = f'earthengine upload image --asset_id={asset_id} {gcs_path}'
  12.     print(command)
  13.     #subprocess.run(command, shell=True)
  14.  
  15. for tiff_file in tiff_files:
  16.     year = int(tiff_file.replace(".tif", "").split("_")[2])
  17.     asset_id = f'{ee_username}{asset_id_base}/pred_risk_{year}'
  18.     gcs_path = f'gs://{bucket_name}/{tiff_file}'
  19.     command = f'earthengine asset set --time_start {year}-01-01 --time_end {year}-12-31 --cite https://drive.google.com/drive/folders/1yQYV28xJGQzOF-KTD4qW0VqSQoB5SwHB {asset_id}'
  20.     print(command)
  21.     #subprocess.run(command, shell=True)
  22.  
  23.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement