Skip to main content

Hi everyone,


I have had a skim through the existing examples of using the Sentinel Hub API and have used them successfully in a python script. I was wondering whether there is an existing way to replace the hard-coded EvalScript in the JSON payload with posting instead an EvalScript file including the JavaScript code. Is that possible?

For example:


with open(“example_evalscript.js”, “r”) as f:

response=requests.post(api_endpoint, headers=headers, json=json, files={example_evalscript.js: f})


When I try the above I am getting a 500 HTTP response status code which means that very likely this functionality doesn’t exist, but if not is there a work-around?


Kind regards,

D.

Using sentinelhub-py implementation (to be released in next few days, until then feat/stat-api branch you can do precisely that:


with open('./data/statapi_evalscript.js', 'r') as es:
evalscript = es.read()

...

stats = SentinelHubStat(aggregation=aggregation, calculations=calculations, input_data=[input_data], bbox=bbox)

response = stats.get_data()[0]

There will be a notebook with the proper release, showcasing the functionality.


Thanks! Good to know that this will be released soon! It will help a lot with managing processing scripts!


Will ping you when it’s ready.


Reply