Last active
August 20, 2020 09:29
-
-
Save maximlamare/5d3d84cc0727b86d25332a0c273be3e5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl --location --request POST 'https://services.sentinel-hub.com/api/v1/process' \ | |
--header 'Authorization: Bearer <your-token-here>' \ | |
--form 'request={ | |
"input": { | |
"bounds": { | |
"bbox": [ | |
2.1421623229980464, | |
41.37796785471600, | |
2.2084236145019527, | |
41.40784461738553 | |
], | |
"properties": { | |
"crs": "http://www.opengis.net/def/crs/EPSG/0/4326" | |
} | |
}, | |
"data": [{ | |
"id": "ls8", | |
"type": "L8L1C", | |
"location": "AWS:us-west-2", | |
"dataFilter": { | |
"timeRange": { | |
"from": "2020-05-21T00:00:00Z", | |
"to": "2020-05-22T00:00:00Z" | |
}, | |
"mosaickingOrder": "leastCC" | |
} | |
}, | |
{ | |
"id": "l2a", | |
"type": "S2L2A", | |
"location": "AWS:eu-central-1", | |
"dataFilter": { | |
"timeRange": { | |
"from": "2020-05-22T00:00:00Z", | |
"to": "2020-05-23T00:00:00Z" | |
}, | |
"mosaickingOrder": "leastCC" | |
} | |
} | |
] | |
}, | |
"output": { | |
"width": 1024, | |
"height": 1024 | |
} | |
}' \ | |
--form 'evalscript=//VERSION=3 | |
function setup() { | |
return { | |
input: [{ | |
datasource: "ls8", | |
bands: ["B02", "B03", "B04", "B05", "B08"], | |
units: "REFLECTANCE" | |
}, | |
{ | |
datasource: "l2a", | |
bands: ["B02", "B03", "B04", "B08", "B11"], | |
units: "REFLECTANCE" | |
} | |
], | |
output: [{ | |
id: "default", | |
bands: 3, | |
sampleType: SampleType.AUTO | |
}] | |
} | |
} | |
let minVal = 0.0 | |
let maxVal = 0.4 | |
let viz = new DefaultVisualizer(minVal, maxVal) | |
function evaluatePixel(samples, inputData, inputMetadata, customData, outputMetadata) { | |
var sample = samples.ls8[0] | |
var sample2 = samples.l2a[0] | |
// Use weighted arithmetic average of S2.B02 - S2.B04 for pan-sharpening | |
let sudoPanW3 = (sample.B04 + sample.B03 + sample.B02) / 3 | |
let s2PanR3 = (sample2.B04 + sample2.B03 + sample2.B02) / 3 | |
let s2ratioWR3 = s2PanR3 / sudoPanW3 | |
let val = [sample.B04 * s2ratioWR3, sample.B03 * s2ratioWR3, sample.B02 * s2ratioWR3] | |
return { | |
default: viz.processList(val) | |
} | |
}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment