Scatter plot in GEE

Is is getting colder or warmer going up the mountain?

Draw a geometry and add the code below. Or click here.

// set the dates
var startDate = ee.Date.fromYMD(2018,1,1);
var endDate = ee.Date.fromYMD(2019,1,1);

// getting modis Land Surface Temperature
var temperature = ee.ImageCollection("MODIS/006/MOD11A2")
  .filterDate(startDate, endDate)

// get the Digital Elevation Model
var dem = ee.Image('CGIAR/SRTM90_V4').rename('elevation');

// combine two images
var img = dem.addBands(temperature);

// sample N points from the 2-band image
var values = img.sample({ region: geometry, scale: 500, numPixels: 1000, geometries: true}) 

Map.addLayer({ color: 'red', pointSize: 2 }), {}, 'samples')

// plot sampled features as a scatter chart
var chart = ui.Chart.feature.byFeature(values, 'elevation', ['temp'])
  .setOptions({ pointSize: 2, pointColor: 'red', width: 300, height: 300, titleX: 'Elevation (m)', titleY: 'Temperature (C)' })

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s