Abdulahad79 commited on
Commit
a240fe9
·
verified ·
1 Parent(s): 39870a7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -5
app.py CHANGED
@@ -21,14 +21,19 @@ import rasterio
21
  from rasterio.transform import xy
22
 
23
 
24
- # Tell Earth Engine to use your local credentials file
25
- os.environ['EARTHENGINE_TOKEN'] = 'credentials' # relative path or use full path if needed
 
 
 
 
 
26
 
27
  try:
28
- ee.Initialize(project='artful-striker-466710-b3') # Replace with your actual GEE project ID
29
- print("Earth Engine initialized successfully.")
30
  except Exception as e:
31
- print(f"Error initializing Earth Engine: {e}")
32
 
33
  # Define crop season dictionary
34
  crop_season_dict = {
 
21
  from rasterio.transform import xy
22
 
23
 
24
+ # Path to your JSON key
25
+ KEY_PATH = "gee-service-key.json" # or full path if not in the same directory
26
+
27
+ # Email from your service account JSON file
28
+ SERVICE_ACCOUNT = "gee-service@artful-striker-466710-b3.iam.gserviceaccount.com"
29
+
30
+ credentials = ee.ServiceAccountCredentials(SERVICE_ACCOUNT, KEY_PATH)
31
 
32
  try:
33
+ ee.Initialize(credentials)
34
+ print("Earth Engine initialized with service account.")
35
  except Exception as e:
36
+ print(f" Initialization failed: {e}")
37
 
38
  # Define crop season dictionary
39
  crop_season_dict = {