Skip to main content

I’m trying to use the same script which used to work for downloading the S2 images, here is the example:


url = 'https://services.sentinel-hub.com/api/v1/process'


payload = {'input': {'bounds': {'properties': {'crs': 'http://www.opengis.net/def/crs/EPSG/0/32719'}, 'bbox': :452300, 7467000, 470000, 7478000]}, 'data': :{'type': 'L8L1C', 'dataFilter': {'timeRange': {'from': '2020-08-05T16:06:08.352041Z', 'to': '2020-11-13T16:06:08.352041Z'}}}]}, 'output': {'resx': 10, 'resy': 10, 'responses': :{'identifier': 'default', 'format': {'type': 'image/jpeg'}}]}, 'evalscript': '\n//VERSION=3\n\n\n\nfunction setup() {\n return {\n input: :"B02", "B03", "B04"],\n output: { bands: 3 }\n };\n}\n\n\n\nminVal = 0.0;\nlet maxVal = 0.4;\nlet viz = new HighlightCompressVisualizer(minVal, maxVal);\nfunction evaluatePixel(sample) {\n let val = =sample.B04, sample.B03, sample.B02];\n // return viz.processList(val);\n return val.map(v => viz.process(v));\n\n}\n\n\n'}


res = requests.request("POST", url, headers=headers, data = json.dumps(payload), timeout=10)


which gives me the following error:


res = requests.request("POST", url, headers=headers, data = json.dumps(payload), timeout=10)

You need to use different end-point for Landsat-8, see:

docs.sentinel-hub.com
d3714e73b38a87afa3c31502a6696052a7395163.png


Landsat 8-9 Level 1



Use Sentinel Hub Processing API to access Landsat 8-9 Level 1 data with 8 optical, 2 thermal, and a 15 m resolution panchromatic band.








The URL works but it doesn’t give pansharpened response using the following evalscript:


"evalScript": "//VERSION=3\nlet minVal = 0.0;\nlet maxVal = 0.4;\n\nlet viz = new HighlightCompressVisualizer(minVal, maxVal);\n\nfunction evaluatePixel(samples) {\n let sudoPanW = (samples.B04 + samples.B03 + samples.B02 * 0.4) / 2.4;\n let ratioW = samples.B08 / sudoPanW;\n let val = =samples.B04 * ratioW, samples.B03 * ratioW, samples.B02 * ratioW];\n val = viz.processList(val);\n val.push(samples.dataMask);\n return val;\n}\n\nfunction setup() {\n return {\n input: :{\n bands: :\n "B02",\n "B03",\n "B04",\n "B08",\n "dataMask"\n ]\n }],\n output: {\n bands: 4\n }\n }\n}\n\n"

Hm, the evalscript looks good.

What do you mean that “it doesn’t give pansharpened response”?


With b8 it sharpens the RGB image. So we have to use b8 as an overlay. This is what the code says.


Sorry, but I do not understand, what is the problem.


Basically, I am trying to obtain the pansharpened image of L8 using B08 but the evalscript fails. If i use just use B02, B03, B04 the RGB image quality is terrible. I have tried to debug my script but it wont return the pansharpened image.


I have no idea, why the evalscript fails. If I put exactly the same evalscript to EO Browser, it works just fine. So I am guessing you are doing something else wrong.


apps.sentinel-hub.com
0d605cf007e70fef63de75e75f6672e960701301.jpg

Sentinel-hub EO-Browser3



Landsat 8 (USGS archive) imagery taken on November 28, 2020








The same evalscript works for me as well, the problem is I want to find out the date of the image through metadata.


evalscript = """

//VERSION=3




let minVal = 0.0;
let maxVal = 0.4;
let viz = new HighlightCompressVisualizer(minVal, maxVal);
function evaluatePixel(samples) {
let sudoPanW = (samples.B04 + samples.B03 + samples.B02 * 0.4) / 2.4;
let ratioW = samples.B08 / sudoPanW;
let val = [samples.B04 * ratioW, samples.B03 * ratioW, samples.B02 * ratioW];
val = viz.processList(val);
val.push(samples.dataMask);
return val;
}
function setup() {
return {
input: [{
bands: ["B02","B03","B04","B08","dataMask" ]
}],
output: {
bands: 4
}
}
}

function updateOutputMetadata(scenes, inputMetadata, outputMetadata) {
outputMetadata.userData = { "metadata": JSON.stringify(scenes) }
return [0]
}


"""

payload = {
"input":{
"bounds":{
"geometry":{
"type": "Polygon",
"coordinates": COORDINATES
},
"properties":{
"crs":"http://www.opengis.net/def/crs/EPSG/0/32719"}},
# "crs": "http://www.opengis.net/def/crs/OGC/1.3/CRS84"}},
"data":[{
"dataFilter":{
"timeRange":{
"from":strt_dt,
"to":end_dt
},
"maxCloudCoverage":100,
"previewMode":"EXTENDED_PREVIEW"},
"processing":{"upsampling":"BICUBIC"},
"type":TYPE}]},
"output":{"resx":10,"resy":10,
"responses": [
{
"identifier": "userdata",
"format": {
"type": resp_type
}
}
]
}, "evalscript": evalscript

}

Reply