I get a "syntax error" for my else-statement (commented the error) but I can't find anything wrong with my indentation.
The code is to download a batch of satellite images, and the error pops up when I try calling the function with a sat_imagery object.
Would really appreciate any help, thanks!
def download_satellite_imagery(sat_imagery): #satellite imagery object
next_batch_size = 10 #set no. of new tasks to be added after reaching task limit
target_count = 3000 - next_batch_size #Threshold before creating new tasks
task_count = get_queued_task() #Execute function & store R/R tasks in var.
queued_filenames = get_queued_task_filenames() #Execute function & store
print('Number of active tasks: {: }.'.format(task_count)) #Print active tasks
for i in range(1,imagery_count):
imagery_file = DIMG + '_{:06d}'.format(i)
imagery_filepath = '/content/gdrive/MyDrive/' + drive_folder + '/' + imagery_file + '.tif'
if task_count == 3000: #Number of tasks has reached limit
#Loop until task count has not reach target_count
while task_count > target_count:
active_task = get_queued_task() #Get no. of tasks on list
if active_task < task_count: #Check if there are finished tasks
task_count = active_task
print("*"*30)
print("Number of current pending tasks in queue: {: }.".format(task_count))
print("Remaining tasks before starting new batch: {: }.".format(task_count-target_count)
else: #error found here
if (os.path.exists(imagery_filepath)==False): #prevents duplication of tasks
if (imagery_file not in queued_filenames):
print("-----------------------")
print("Starting new task...")
print("downloading "+ imagery_file)
#Set var to store centroid coordinates obtained from centroid CSV
c_lon = df['lon'][i]
c_lat = df['lat'][i]
#Employ centroid coordinates to define a geospatial circle using GEE point geometry
#Buffer of 1920m - 1/2 grid size measured from centroid to grid boundary
geometry = ee.Geometry.Point([c_lon, c_lat]).buffer(1920)
#Redefine geom var with c of circle as its value
geometry = geometry.getInfo()['coordinates'][0]
scale =15
task_config = {
'scale': scale, #satellite resolution
'region': geometry, #area coverage to download
'driveFolder': drive_folder #folder path
}
#Describe image batch export object & name as task
task = ee.batch.Export.image(sat_imagery, imagery_file, task_config)
task.start() #Pass the task to GEE
task_count += 1
if task_count %1000 == 0:
task_count = get_queued_task() #Execute get_queued_tasks only after every 1000 tasks
print('Number of active tasks: {: }.'.format(task_count))
else:
print("On queue: " + imagery_file + ".tif")
else:
print("Downloaded: " + imagery_file +".tif")````
Aucun commentaire:
Enregistrer un commentaire