Skip to main content

Hi,


Using python 3.9 and sentinelhub 3.8.0, ogc requests fail when multiple dates are available and a custom eval script is provided in the request, see basic example below:


from sentinelhub import CRS, BBox, DataCollection, MimeType, SHConfig
from sentinelhub.api.ogc import OgcRequest
from sentinelhub.constants import CustomUrlParam, ServiceType

config = SHConfig()
config.instance_id = INSTANCE_ID

evalscript = """
//VERSION=3

function setup() {
return {
input: [{
bands: ["B02", "B03", "B04"]
}],
output: {
bands: 3
}
};
}

function evaluatePixel(sample) {
return [sample.B04, sample.B03, sample.B02];
}
"""

ogc_request = OgcRequest(
layer="S2-L1C",
bbox=BBox(bbox=[46.16, -16.15, 46.51, -15.58], crs=CRS.WGS84),
data_collection=DataCollection.SENTINEL2_L1C,
time=("2019-12-15", "2019-12-25"),
service_type=ServiceType.WMS,
size_x=512,
size_y=856,
config=config,
image_format=MimeType.TIFF,
custom_url_params={
CustomUrlParam.EVALSCRIPT: evalscript
}
)

ogc_request.get_data()

This results in the following error:


DownloadFailedException                   Traceback (most recent call last)
Cell In [2], line 42
8 evalscript = """
9 //VERSION=3
10
...
400 Client Error: Bad Request for url: https://services.sentinel-hub.com/ogc/wms/[INSTANCE_ID]?SERVICE=wms&WARNINGS=False&MAXCC=100.0&EvalScript=UTJsQlowbERRWFpNTVZwR1ZXeE9TbFF3TkRsTmQyOUxTVU5CWjBsSFdqRmliVTR3WVZjNWRVbElUbXhrU0ZaM1MwTnJaMlYzYjJkSlEwRm5TVU5CWjBsSVNteGtTRlo1WW1sQ04wTnBRV2RKUTBGblNVTkJaMGxEUVdkSlIyeDFZMGhXTUU5cFFtSmxkMjluU1VOQlowbERRV2RKUTBGblNVTkJaMGxEUVdkWmJVWjFXa2hOTmtsR2MybFJha0Y1U1dsM1owbHJTWGROZVVselNVTktRMDFFVVdsWVVXOW5TVU5CWjBsRFFXZEpRMEZuU1VOQ09WaFRkMHRKUTBGblNVTkJaMGxEUVdkSlEwRm5Zak5XTUdOSVZqQlBhVUkzUTJsQlowbERRV2RKUTBGblNVTkJaMGxEUVdkSlEwSnBXVmMxYTJONmIyZE5kMjluU1VOQlowbERRV2RKUTBGblNVTkNPVU5wUVdkSlEwRm5TVU5CWjJaVWMwdEpRMEZuU1Vnd1MwTnBRV2RKUTBKdFpGYzFhbVJIYkhaaWFVSnNaRzFHYzJSWFJqQmFWa0p3WlVkV2MwdElUbWhpV0VKeldsTnJaMlYzYjJkSlEwRm5TVU5CWjBsSVNteGtTRlo1WW1sQ1ltTXlSblJqUjNoc1RHdEpkMDVEZDJkak1rWjBZMGQ0YkV4clNYZE5lWGRuWXpKR2RHTkhlR3hNYTBsM1RXd3dOME5wUVdkSlEwSTVRMmM5UFE9PQ%3D%3D&BBOX=-16.15%2C46.16%2C-15.58%2C46.51&FORMAT=image%2Ftiff&CRS=EPSG%3A4326&TIME=2019-12-25T07%3A14%3A02Z%2F2019-12-25T07%3A14%3A02Z&WIDTH=512&HEIGHT=856&LAYERS=S2-L1C&REQUEST=GetMap&VERSION=1.3.0
Server response: "Failed to evaluate script!
undefined:3: SyntaxError: Unexpected token }
}
^"

  • The code above works if only a single date is available in the time interval, e.g. time=“2019-12-15”

  • Furthermore, it also works, if the exact same eval script is configured directly in the layer instead.

  • Finally, it works using python 3.7 and sentinelhub 3.0.0

Do you have any idea, what causes this?


Best regards

Lasse

Hi,

Thank you for reporting! I was able to reproduce the behaviour with the information you provided. There was an issue with the evalscript encoding function that created a valid WMS URL only for the first scene in the array of scenes, and corrupted ones for any additional scene. A bugfix has been pushed to the develop branch of sentinelhub-py.
It will unfortunately take some time until the next release, which is why I suggest you to:

  • install the library from the develop branch,
  • or define the evalscript in the configuration layer if that works for your processing chain.

I hope that solves your issue.


Hi,

Thank you for fixing the bug!

Best regards


Reply