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)
  .select('LST_Day_1km')
  .mean()
  .multiply(0.02)
  .subtract(273.15)
  .rename('temp');

// 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(values.style({ color: 'red', pointSize: 2 }), {}, 'samples')

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

Advertisements

Leave a Reply

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

WordPress.com Logo

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

Google photo

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

Twitter picture

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

Facebook photo

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

Connecting to %s