Learning is fun and Google Earth Engine has made it more fun. Today, we will learn how to generate histogram in the Google Earth Engine.
Data Overview
The Global Multi-resolution Terrain Elevation Data 2010 (GMTED2010) dataset contains elevation data for the globe collected from various sources. The version of the dataset available here is Breakline Emphasis, 7.5 arc-seconds resolution. Breakline emphasis maintains the critical topographic features (streams or ridges) within the landscape by maintaining any minimum elevation or maximum elevation value on a breakline that passes within the specified analysis window. More details are available in the dataset report.
The primary source dataset for GMTED2010 is NGA’s SRTM Digital Terrain Elevation Data (DTED®, http://www2.jpl.nasa.gov/srtm/) (void-filled) 1-arc-second data. For the geographic areas outside the SRTM coverage area and to fill in remaining holes in the SRTM data, the following sources were used: non-SRTM DTED®, Canadian Digital Elevation Data (CDED) at two resolutions, Satellite Pour l’Observation de la Terre (SPOT 5) Reference3D, National Elevation Dataset (NED) for the continental United States and Alaska, GEODATA 9 second digital elevation model (DEM) for Australia, an Antarctica satellite radar and laser altimeter DEM, and a Greenland satellite radar altimeter DEM.
This dataset replaces the GTOPO30 Elevation Model.
Here is the code:
// Select your country
var countries = ee.FeatureCollection("ft:1tdSwUL7MVpOauSgRzqVTOwdfy17KDbw-1d9omPw")
var country_name = ['Nepal']
//var country_name = ['Kenya']
var country = countries.filter(ee.Filter.inList('Country', country_name));
Map.centerObject(country,7); //Zoom to Study area
var image = ee.Image().toByte()
//.paint(roi, 'fill') // Get color from property named 'fill'
.paint(country, 2, 2); // Outline using color 3, width 5.
// Create a custom elevation palette from hex strings.
var elevationPalette = ['061E84','0DF83B', '1BB747','286107', 'F90B04', 'E6694D','EAB01E','F07B0E','CFCCCC','F7F9F9','F9F8F8'];
// Use these visualization parameters, customized by location.
var visParams = {min: -0, max: 7000, palette: elevationPalette};
// Plot a histogram of elevation
// Load a global elevation image.
//var elev = ee.Image('USGS/GMTED2010')
var elev = ee.Image('CGIAR/SRTM90_V4');
// Add the elevation to the map.
Map.addLayer(elev, {}, 'elevation b/w');

Now add Histogram
// Generate the histogram data.
var histogram = ui.Chart.image.histogram({
image: elev,
region: country,
scale: 200,
minBucketWidth: 300
});
histogram.setOptions({
title: 'Histogram of Elevation (in meters) in '+country_name
});
print(histogram);
Map.addLayer(elev.clip(country), visParams, 'Elevation Map of '+country_name);
//Map.setCenter(-107, 39, 6);
/************************ Title ****************************/
Map.add(ui.Label(
'Elevation Map of '+country_name,
{
fontWeight: 'bold',
//fontColors: 'red',
BackgroundColor: '09B3EC',
//.paint(roi, 'fill')
fontSize: '14px'}));

Pingback: Using 2001 MODIS Land Cover Type Yearly Global 500m Data to Determine the Land-Cover Analysis (Study Area: Mexico) – DINESH SHRESTHA
Pingback: Learn How to Add two charts next to the map to interactively display a time-series of NDVI and reflectance for each click on the map? – DINESH SHRESTHA
Pingback: Create a Chart to show Landsat 8 TOA Spectra at three points near Mumbai City – DINESH SHRESTHA
Pingback: Learn how to calculate and export 90th Percentile Annual NDVI for years 1985-2019 using Landsat 8, 7, and 5 scenes (Study Area: Turkey) – DINESH SHRESTHA
Pingback: Use 2018 Landsat 8 Scenes for Land Cover Classification in Google Earth Engine (Study Area: Dubai) – DINESH SHRESTHA
Pingback: Land Cover Change Analysis between 1999 and 2018 in GEE (Study Area: Mumbai) – DINESH SHRESTHA
Pingback: Time-lapse: Animate 30m Landsat images generated 90th percentile Annual NDVI from 1999 to 2018 (Study Area: South America) – DINESH SHRESTHA
Hi, all 🙂
I don’t know, what ‘var countries = ee.FeatureCollection(“ft:1tdSwUL7MVpOauSgRzqVTOwdfy17KDbw-1d9omPw”)’ means, but it could be changing by:
var countries = ee.FeatureCollection(“FAO/GAUL/2015/level0”);
and then get the country you want by this:
var country_name = [‘Nepal’]
var country = countries.filter(ee.Filter.inList(‘ADM0_NAME’, country_name));
Have a nice day 🙂
Zdenek