faizan1041
(Faizan Ali)
November 14, 2020, 6:15am
#1
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)
gmilcinski
(Grega Milcinski)
November 14, 2020, 7:32am
#2
You need to use different end-point for Landsat-8, see:
faizan1041
(Faizan Ali)
November 23, 2020, 1:02pm
#3
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"
gmilcinski
(Grega Milcinski)
November 23, 2020, 8:08pm
#4
Hm, the evalscript looks good.
What do you mean that “it doesn’t give pansharpened response”?
faizan1041
(Faizan Ali)
November 24, 2020, 7:44pm
#5
With b8 it sharpens the RGB image. So we have to use b8 as an overlay. This is what the code says.
gmilcinski
(Grega Milcinski)
November 26, 2020, 9:55pm
#6
Sorry, but I do not understand, what is the problem.
faizan1041
(Faizan Ali)
December 2, 2020, 1:44pm
#7
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.
gmilcinski
(Grega Milcinski)
December 2, 2020, 9:35pm
#8
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.
faizan1041
(Faizan Ali)
December 8, 2020, 3:52pm
#9
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
}