Created
February 13, 2022 16:00
-
-
Save s-kganz/8f56e3d64efee8f46c0971304e1e4198 to your computer and use it in GitHub Desktop.
Compare JS and Python TAGEE implementations
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
var TAGEE = require('users/joselucassafanelli/TAGEE:TAGEE-functions'); | |
var srtm = ee.Image("USGS/SRTMGL1_003"); | |
var geom = ee.FeatureCollection(ee.Geometry.Rectangle(-111, 40, -110.9, 40.1)); | |
// smooth the DEM | |
var gaussianFilter = ee.Kernel.gaussian({ | |
radius: 3, sigma: 2, units: 'pixels', normalize: true | |
}); | |
var srtmSmooth = srtm.convolve(gaussianFilter).resample("bilinear"); | |
var terrainMetrics = TAGEE.terrainAnalysis(TAGEE, srtmSmooth, geom.geometry()); | |
// define the reducer | |
var superReducer = ee.Reducer.median().combine(ee.Reducer.minMax(), "", true); | |
var reduction = terrainMetrics.reduceRegions( | |
geom, | |
superReducer | |
); | |
print(geom); | |
print(reduction); |
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
import TAGEE | |
import ee | |
ee.Initialize() | |
srtm = ee.Image("USGS/SRTMGL1_003") | |
geom = ee.FeatureCollection(ee.Geometry.Rectangle(-111, 40, -110.9, 40.1)) | |
# smooth the DEM | |
gaussianFilter = ee.Kernel.gaussian( | |
radius=3, sigma=2, units='pixels', normalize=True | |
) | |
srtmSmooth = srtm.convolve(gaussianFilter).resample("bilinear") | |
terrainMetrics = TAGEE.terrainAnalysis(srtmSmooth, geom.geometry()) | |
# define the reducer | |
superReducer = ee.Reducer.median().combine(ee.Reducer.minMax(), "", True) | |
reduction = terrainMetrics.reduceRegions( | |
geom, | |
superReducer | |
) | |
print(geom.getInfo()) | |
print(reduction.getInfo()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment