I have a polygon (fusion table) and I need to discover which is the highest point from point. Here's what I have done until now:

var elevation = ee.Image('CGIAR/SRTM90_V4');
var rainierWaypoints =

Map.addLayer(elevation.clip(rainierWaypoints), {min:0, max:300, palette:['000000',"ffffff"]},"elevation2");
var chart = ui.Chart.image.byRegion({
  image: elevation,
  regions: rainierWaypoints,
  scale: 200,
  xProperty: 'name'
  title: 'Propriedade',
  vAxis: {
    title: 'Elevation (meters)'
  legend: 'none',
  lineWidth: 1,
  pointSize: 4
var options = {
  title: 'Altitude',
  fontSize: 12,
  hAxis: {title: 'Frequência'},
  vAxis: {title: 'Altitude'},
  series: {
    0: {color: 'blue'}

var histogram = ui.Chart.image.histogram(elevation, rainierWaypoints, 30)


Map.addLayer(rainierWaypoints, {color: 'FF0000'});

Here's the fusion table that I'm using as example. https://fusiontables.google.com/data?docid=1oCYHTwkJhzDdJi3sabCm-BFyTwhu7N2HuQPpceBv#map:id=3

  • You need to share your fusiontable - otherwise we won't be able to run the script. – Kersten Mar 12 '18 at 16:53
  • @Kersten I updated the question with the fusion table. – Murilo Azevedo Mar 12 '18 at 18:04

This may not be the only solution, but works fine. It'd get messy if there is more than one pixel with same height (that problem would have another solution I think). The code:

elevation = elevation.clip(rainierWaypoints)

// Pixel position
var pixel_pos = ee.Image.pixelLonLat();

// Highest elevation
var high = elevation.reduceRegion(ee.Reducer.max(), rainierWaypoints, 10).get('elevation');

// Leave only the highest pixel (mask)
var highest = elevation.eq(ee.Image.constant(high));

// Add pixel position to the mask
var highest_point_image = elevation.addBands(pixel_pos).mask(highest);

// Get Lon & Lat of that pixel (mean to be in the middle)
var highest_point = highest_point_image.reduceRegion(ee.Reducer.mean(), rainierWaypoints, 10);

// Create a point using Lat & Lon
var point = ee.Geometry.Point([highest_point.get('longitude'), highest_point.get('latitude')]);
Map.addLayer(point, {}, 'Highest point')

The following code uses a masked image (similar to Rodrigo's approach) with ee.Image.reduceToVectors() to find the highest areas. Note that you many want to increase the value of MAX_PIXELS when analyzing very large regions.

// Set the number maximum number of pixels to sample. Increase this number
// to increase the accuracy when analyzing large regions.
var MAX_PIXELS = 1e8;

// Declare an elevation dataset to use.
var elevation = ee.Image("USGS/SRTMGL1_003");

// Area around Sao Paulo, Brazil.
var roi = ee.Geometry.Polygon(
        [[[-41.3, -24.0],
          [-42.6, -21.0],
          [-49.5, -18.9],
          [-53.4, -22.3],
          [-47.9, -26.2]]]);

// Find the highest elevation in a specified region-of-interest (roi).
var highest_elevation = elevation.reduceRegion({
    reducer: ee.Reducer.max(),
    geometry: roi,
    bestEffort: true,
    maxPixels: MAX_PIXELS,

// Created a masked image of only the highest elevations.
var highest_mask = elevation.eq(ee.Image.constant(highest_elevation));

// Create features from the non-masked high elevation areas.
var max_elevation_features = elevation.mask(highest_mask).reduceToVectors({
  geometry: roi, 
  labelProperty: 'elevation',
  bestEffort: true,
  maxPixels: MAX_PIXELS,

// Print the feature information to the console.
print('max_elevation_features', max_elevation_features);

// Add Layers to the interactive map.
Map.addLayer(roi, {color: 'white'}, 'Region of Interest');
Map.addLayer(max_elevation_features, {color:'red'}, 'Max Elevation Areas');

This approach also works on areas where there are multiple locations with the same elevation. To demonstrate this, use the following region (in the salt flats of Utah, USA):

// Flat area with multiple equivalent high points.
var roi = ee.Geometry.Polygon(
        [[[-113.40306, 40.74333],
          [-113.40306, 40.74255],
          [-113.40107, 40.74255],
          [-113.40107, 40.74333]]]);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.