Skip to main content

Is it possible to pass a “custom evalscript” as base64 encoded parameter in a OGC WMS request within a leaflet webmap?


If yes, then please assist.


At the moment I have reference to this FAQ link that says this is possible, but I am struggling a little. I’m not quite sure how to structure the request for this to work.


Below is my attempt, but the response is 400.


const sentine2RGBLayer = L.tileLayer.wms(`${sentinelHubWMSBaseUrl}/${sentinel2InstanceID}`, {
tileSize: 512,
maxcc: 50,
preset: "CUSTOM",
datasource: "Sentinel-2 L1C",
layers: "B01,B02,B03",
evalscript: "cmV0dXJuIFtCMDgqMi41LEIwNCoyLjUsQjAzKjIuNV07",
time: `2023-01-28`,
transparent: "true",
format: "image/png",
crs: L.CRS.EPSG4326,
});

Why do I need this? I would like to built custom script client side and then submit to Sentinel Hub as a WMS request.

I am specifically interested in rescaling and alternate color ramp changes to a layer (or custom script) for the visualization of data retrieved.

At the moment I succeed with calling configured layers, with preset color maps.


const sentine2RGBLayer = L.tileLayer.wms(`${sentinelHubWMSBaseUrl}/${sentinel2InstanceID}`, {
tileSize: 512,
maxcc: 50,
layers: "TRUE-COLOR-S2-L1C",
transparent: "true",
format: "image/png",
crs: L.CRS.EPSG4326,
});

Thank you in advance.

Hi,

Could you please share your evalscript and the raw wms url for the request? Thank you.


https://services.sentinel-hub.com/ogc/wms/e3***********************************66?service=WMS&request=GetMap&layers=B01%2CB02%2CB03&styles=&format=image%2Fpng&transparent=true&version=1.1.1&maxcc=50&preset=CUSTOM&datasource=Sentinel-2%20L1C&evalscript=cmV0dXJuIFtCMDgqMi41LEIwNCoyLjUsQjAzKjIuNV07&time=2023-01-28&width=512&height=512&srs=EPSG%3A4326&bbox=30.547485351562504,-29.44438130948882,30.552978515625004,-29.439597566602902

Base64 decoding of evalscript “cmV0dXJuIFtCMDgqMi41LEIwNCoyLjUsQjAzKjIuNV07”:

return uB08*2.5,B04*2.5,B03*2.5];

Hi,

Sorry for the confusion. The LAYERS parameter should be set as one of the layers in your configuration, e.g., TRUE-COLOR-S2-L1C.

The correct url for your wms request would be the following:

https://services.sentinel-hub.com/ogc/wms/e3***********************************66?service=WMS&request=GetMap&layers=TRUE-COLOR-S2-L1C&styles=&format=image%2Fpng&transparent=true&version=1.1.1&maxcc=50&preset=CUSTOM&datasource=Sentinel-2%20L1C&evalscript=cmV0dXJuIFtCMDgqMi41LEIwNCoyLjUsQjAzKjIuNV07&time=2023-01-28&width=512&height=512&srs=EPSG%3A4326&bbox=30.547485351562504,-29.44438130948882,30.552978515625004,-29.439597566602902

Changing the layer to one that is set in the configurator worked, thank you!


Reply