Hello,
I want to run the statistical API in batch process for three differene gpkg that I have. I have written for loop to open each of this gpkg, run it for different dates and then save it in different location.
However, the result is that it runs only for the thirs out of three loops.
This is the for loop I have used:
urls_gpck=['s3://gis/path/file1.gpkg',
's3://gis/path/file2.gpk',
's3://gis/path/file3.gpk']
urls_results=['s3://gis/results/test1',
's3://gis/results/test2',
's3://gis/results/test3']
times=[["2019-09-01T00:00:00Z","2020-03-30T00:00:00Z"],
["2020-09-01T00:00:00Z","2021-03-30T00:00:00Z"],
["2021-09-01T00:00:00Z","2022-03-30T00:00:00Z"]]
for gpck,res_loc,date_list in zip(urls_gpck,urls_results,times):
request_payload = {
"input": {
"features":{
"s3": {
"url": gpck,
"accessKey": "SECRET1234",#fake
"secretAccessKey": "SecretAccessKEY1234" #fake :)
}
},
"data": [
{
"type": "sentinel-2-l2a",
"dataFilter": {
"mosaickingOrder": "leastCC"
}
}
]
},
"aggregation": {
"timeRange": {
"from":date_list[0],
"to": date_list[1]
},
"aggregationInterval": {
"of": "P15D"
},
"evalscript": evalscript,
"resx": 10,
"resy": 10
},
"output": {
"s3": {
"url": res_loc,
"accessKey": "SECRET",
"secretAccessKey": "SecretAccessKey1234"
}
}
}
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json'
}
url = "https://services.sentinel-hub.com/api/v1/statistics/batch"
response = oauth.request("POST", url=url, headers=headers, json=request_payload)
request_id = response.json()['id']
The result is that I get jsons results only for the third item (test3) but not for the first two items. It seems like the loop runs without really send the request?
My goal is to be able to run statistical api requests in batch process inside for loop, if possible.