Skip to content

Instantly share code, notes, and snippets.

@s-kganz
Created February 13, 2022 16:00
Show Gist options
  • Save s-kganz/8f56e3d64efee8f46c0971304e1e4198 to your computer and use it in GitHub Desktop.
Save s-kganz/8f56e3d64efee8f46c0971304e1e4198 to your computer and use it in GitHub Desktop.
Compare JS and Python TAGEE implementations
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);
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