Last active
February 4, 2026 09:29
-
-
Save Choumingzhao/23886aafdafd78876614f0d9d4104ea9 to your computer and use it in GitHub Desktop.
Evalscript for the mapping of flood on 2023.10 in Maoming, Guangdong., PRC
This file contains hidden or 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
| //VERSION=3 | |
| // This is a simple adoption from Sentinel-hub use case from [https://custom-scripts.sentinel-hub.com/sentinel-1/flood_mapping/] | |
| // To share a long evalscript, we need a public url. Github Gist's raw url is nice way. | |
| var beforeflood_date = "2023-10-12"; var duringflood_date = "2023-10-24"; | |
| function setup() { | |
| return { | |
| input: [{ | |
| bands: [ | |
| "VV" | |
| ] | |
| }], | |
| output: { bands: 3 }, | |
| mosaicking: "ORBIT" | |
| } | |
| } | |
| function filterScenes (scenes) { | |
| return scenes.filter(function (scene) { | |
| // set dates for before-and-during flood analysis | |
| var allowedDates = [beforeflood_date,duringflood_date]; | |
| var sceneDateStr = dateformat(scene.date); | |
| if (allowedDates.indexOf(sceneDateStr)!= -1) return true; | |
| else return false; | |
| }); | |
| } | |
| // Flood mapping | |
| function calcFM(sample) { | |
| var outvv = sample.VV; | |
| return [1.5*outvv]; | |
| } | |
| function dateformat(d){ | |
| var dd = d.getDate(); | |
| var mm = d.getMonth()+1; | |
| var yyyy = d.getFullYear(); | |
| if(dd<10){dd='0'+dd} | |
| if(mm<10){mm='0'+mm} | |
| var isodate = yyyy+'-'+mm+'-'+dd; | |
| return isodate; | |
| } | |
| function evaluatePixel(samples,scenes) { | |
| var outbe = 0; | |
| var outdu = 0; | |
| // before-flood image | |
| outbe = calcFM(samples[1]); | |
| // during-flood image | |
| outdu = calcFM(samples[0]); | |
| return [outbe,outdu,outdu] | |
| // ************************************ | |
| // mask creation | |
| // var dout = outbe - outdu; | |
| // return [dout > 0.05 ? 1 : 0] | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
View it via this