Package: tagee
Google Earth Engine (GEE) is a high-performance cloud-based platform for processing geospatial data.There is a myriad of processing toolboxes in GEE, but this repository/package aims to contribute to the GEE community for making terrain analysis seamlessly.InstallationTerrain Analysis in Google Earth Engine (TAGEE) is a repository that contains the GEE Javascript code and a Python API implementation with reproducible examples for both.You can use TAGEE in the Earth Engine code editor with arequirestatement.varTAGEE=require('users/joselucassafanelli/TAGEE:TAGEE-functions');Or install the Python package from pip:pip install tageeAdditional examples information are below.Feature OverviewAvailable terrain attributes:AttributeUnitDescriptionElevationmeterHeight of terrain above sea levelSlopedegreeSlope gradientAspectdegreeCompass directionHillshadedimensionlessBrightness of the illuminated terrainNorthnessdimensionlessDegree of orientation to NorthEastnessdimensionlessDegree of orientation to EastHorizontal curvaturemeterCurvature tangent to the contour lineVertical curvaturemeterCurvature tangent to the slope lineMean curvaturemeterHalf-sum of the two orthogonal curvaturesMinimal curvaturemeterLowest value of curvatureMaximal curvaturemeterHighest value of curvatureGaussian curvaturemeterProduct of maximal and minimal curvaturesShape IndexdimensionlessContinuous form of the Gaussian landform classificationThe users are referred to Florinsky (2016) for mathematical concepts of geomorphometry, a historical overview of the progress of digital terrain modelling, and the notion of the topographic surface and its limitations.Florinsky, Igor. Digital terrain analysis in soil science and geology. Academic Press, 2016.Please, cite the following paper when using TAGEE:Safanelli, J.L.; Poppiel, R.R.; Ruiz, L.F.C.; Bonfatti, B.R.; Mello, F.A.O.; Rizzo, R.; Demattê, J.A.M. Terrain Analysis in Google Earth Engine: A Method Adapted for High-Performance Global-Scale Analysis. ISPRS Int. J. Geo-Inf. 2020, 9, 400. DOI:https://doi.org/10.3390/ijgi9060400Important note!As TAGEE uses spheroidal geometries and elevation nodes from a 3x3 moving window to calculate partial derivatives and hence terrain attributes, the visualization of the outputs is affected by the scale, which require the adjustment of the histogram for proper visualization. This happens because GEE produces different pyramids from your data (from the local up to the global scale) and consequently the pixel size changes dynamically, affecting the range of the estimated attribute values. Until you specify your final resolution, say 30m/pixel, the pyramids will dynamically affect the visualization of an output for different visualizaiton scales. You can determine your final resolution by exporting the results to assets and importing back further processing or map composition.Minimal reproducible exampleOPEN THE EXAMPLE DIRECTLY IN THE GEE CODE EDITOR.NOTE: Any Earth Engine user with the above link can use it to view and run the example code. However, you need to login.Javascript// Importing modulevarTAGEE=require('users/joselucassafanelli/TAGEE:TAGEE-functions');// World bounding boxvarbbox=ee.Geometry.Rectangle({coords:[-180,-60,180,60],geodesic:false});// Water maskvarhansen_2016=ee.Image('UMD/hansen/global_forest_change_2016_v1_4').select('datamask');varhansen_2016_wbodies=hansen_2016.neq(1).eq(0);varwaterMask=hansen_2016.updateMask(hansen_2016_wbodies);// Loading SRTM 30 mvardemSRTM=ee.Image('USGS/SRTMGL1_003').clip(bbox).rename('DEM');// Smoothing filtervargaussianFilter=ee.Kernel.gaussian({radius:3,sigma:2,units:'pixels',normalize:true});// Smoothing the DEM with the gaussian kernel.vardemSRTM=demSRTM.convolve(gaussianFilter).resample("bilinear");// Terrain analysisvarDEMAttributes=TAGEE.terrainAnalysis(TAGEE,demSRTM,bbox).updateMask(waterMask);print(DEMAttributes.bandNames(),'Parameters of Terrain');// VisualizationvarvizVC=TAGEE.makeVisualization(DEMAttributes,'VerticalCurvature','level2',bbox,'rainbow');Map.addLayer(vizVC,{},'VerticalCurvature');Map.setCenter(0,0,2);Example descriptionIn the Javascript code editorhttps://code.earthengine.google.com/, it is necessary to import the moduleTAGEE-functions.varTAGEE=require('users/joselucassafanelli/TAGEE:TAGEE-functions');Then, you need to define the bounding box (study region limits) and import the Digital Elevation Model for terrain analysis (e.g. SRTM 30 m).// World bounding boxvarbbox=ee.Geometry.Rectangle({coords:[-180,-60,180,60],geodesic:false});// Water maskvarhansen_2016=ee.Image('UMD/hansen/global_forest_change_2016_v1_4').select('datamask');varhansen_2016_wbodies=hansen_2016.neq(1).eq(0);varwaterMask=hansen_2016.updateMask(hansen_2016_wbodies);// Loading SRTM 30 mvardemSRTM=ee.Image('USGS/SRTMGL1_003').clip(bbox).rename('DEM');// Smoothing filtervargaussianFilter=ee.Kernel.gaussian({radius:3,sigma:2,units:'pixels',normalize:true});// Smoothing the DEM with the gaussian kernel.vardemSRTM=demSRTM.convolve(gaussianFilter).resample("bilinear");Finally, you can run the TAGEE module for calculating the terrain attributes.// Terrain analysisvarDEMAttributes=TAGEE.terrainAnalysis(TAGEE,demSRTM,bbox).updateMask(waterMask);print(DEMAttributes.bandNames(),'Parameters of Terrain');List(13elements){0:Elevation1:Slope2:Aspect3:Hillshade4:Northness5:Eastness6:HorizontalCurvature7:VerticalCurvature8:MeanCurvature9:GaussianCurvature10:MinimalCurvature11:MaximalCurvature12:ShapeIndex}TAGEE has an additional feature for making the visualization easier and adapated to a dynamic scale (legend), once the pixel distances for the derivatives calculations are influenced by the visualization level. The legend limits are estimated by the 5th and 95th percentiles existing within the bounding box.// VisualizationvarvizVC=TAGEE.makeVisualization(DEMAttributes,'VerticalCurvature','level2',bbox,'rainbow');Map.addLayer(vizVC,{},'VerticalCurvature');Map.setCenter(0,0,2);For the functionmakeVisualization, you need to specify:Attributes in multiband objectAttribute name (string, e.g. 'VerticalCurvature')Visualization level (string, e.g. 'level2')Bounding box objectColor pallete (string, e.g. 'rainbow')The visualization levels are:Visualization levelPixel resolution (m)'level0'157000'level1'78000'level2'39000'level3'20000'level4'10000'level5'5000'level6'2000'level7'1000'level8'611'level9'306'level10'153'level11'76'level12'38'level13'19'level14'10'level15'5Available color palettes: 'rainbow', 'inferno', 'cubehelix', 'red2green', 'green2red', 'elevation', 'aspect' and 'hillshade'.Python APIThe Python TAGEE package is implemented very similarly to the JS version.# import & initialize the earth engine APIimporteeee.Initialize()# import relevant functionfromtageeimportterrainAnalysis# set up a smoothed DEMgaussianFilter=ee.Kernel.gaussian(radius=3,sigma=2,units='pixels',normalize=True)srtmSmooth=ee.Image("USGS/SRTMGL1_003").convolve(gaussianFilter).resample("bilinear")# Calculate terrain metrics over a given geometry. You must provide a geometry# in the terrainAnalysis call.geom=ee.FeatureCollection(ee.Geometry.Rectangle(-111,40,-110.9,40.1))terrainMetrics=terrainAnalysis(srtmSmooth,geom.geometry())# Summarize the metrics in the geometryreduction=terrainMetrics.reduceRegions(geom,ee.Reducer.median())print(reduction.getInfo())For any request, comment and suggestion, please send me a email (my github nicknameat gmail.com)