Last active
December 16, 2023 16:01
-
-
Save cocomice/a83dd39a903e28c9c549653c4b2f94df to your computer and use it in GitHub Desktop.
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
| // Function to calculate CSI index | |
| function calculateCSI(image) { | |
| var csi = image.normalizedDifference(['B7', 'B5']).rename('csi'); | |
| return image.addBands(csi); | |
| } | |
| // Function to calculate the area [m2] given a region | |
| function calculateArea(image, region, scale, varName) { | |
| var areaImage = image.clip(region).multiply(ee.Image.pixelArea()); | |
| var area = areaImage.reduceRegion({ | |
| reducer: ee.Reducer.sum(), | |
| geometry: region, | |
| scale: scale, | |
| maxPixels: 1e13, | |
| tileScale: 14 | |
| }); | |
| return area.get(varName).getInfo(); // "csi" is the band name, adjust if needed | |
| } | |
| // Function to export image as a png file to Google Drive | |
| var projection = myImg.projection().getInfo(); | |
| Export.image.toDrive({ | |
| image: exportImg, | |
| description: 'Erhai_Landuse_2021', | |
| folder: 'GEE_workspace', | |
| crs: projection.crs | |
| // crsTransform: projection.transform | |
| }); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment