430 likes | 446 Views
Practice exercises in geodetic monitoring and remote sensing using Earth Engine. Explore Landsat and Sentinel data with Carla Braitenberg from University of Trieste. Contact: berg@units.it Tel: 339.8290713. Learn about median, NDVI, and sediment identification techniques.
E N D
Monitoraggio Geodetico e Telerilevamento EarthEngine exercizes Carla Braitenberg Dip. Matematica e Geoscienze Universita’ di Trieste berg@units.it Tel. 339 8290713
Script 05 var landsat8 = ee.ImageCollection("LANDSAT/LC08/C01/T1_TOA"); varrgb_viz = {min:0, max:0.3, bands:['R','G','B']}; var rgb_viz1 = {min:0, max:0.3, bands:['B','G','R']}; var images = landsat8.select(['B2','B3','B4','B5'], ['B','G','R','N']); images = images.filterDate('2015-04-01', '2015-04-06'); Map.addLayer(images, rgb_viz, 'True Color'); Map.addLayer(images, rgb_viz1, 'False Color');
Script 6 Median var landsat8 = ee.ImageCollection("LANDSAT/LC8_L1T_TOA"); varrgb_viz = {min:0, max:0.3, bands:['R','G','B']}; var images = landsat8.select(['B2','B3','B4','B5'], ['B','G','R','N']); images = images.filterDate('2015-04-01', '2015-10-06'); Map.addLayer(images, rgb_viz, 'True Color'); Map.addLayer(images.median(), rgb_viz, 'True Color median'); Nexttomedian, youhavealso: mode and mean. Median: Middle value separating the greater and lesser halves of a data set Mode: Most frequent value in a data set Mean: Sum ofvaluesof a data set dividedbynumberofvalues
Script 7 Sentinel var sentinel2 =ee.ImageCollection("COPERNICUS/S2"); var landsat8 = ee.ImageCollection("LANDSAT/LC8_L1T_TOA"); varrgb_viz = {min:0, max:0.3, bands:['R','G','B']}; var rgb_viz2 = {min:0, max:2000, bands:['R','G','B']}; var images = landsat8.select(['B2','B3','B4','B5'], ['B','G','R','N']); var images2 = sentinel2.select(['B2','B3','B4','B5'], ['B','G','R','N']); images = images.filterDate('2016-05-01', '2016-05-06'); images2 = images2.filterDate('2016-01-26', '2016-04-28'); Map.addLayer(images, rgb_viz, 'True Color'); Map.addLayer(images2, rgb_viz2, 'True Color sentinel'); Map.addLayer(images.median(), rgb_viz, 'True Color median');
Script 7 Sentinel- filter on location var landsat8 = ee.ImageCollection("LANDSAT/LC8_L1T_TOA"); var s2 = ee.ImageCollection("COPERNICUS/S2"); var geometry = /* color: 0000ff */ee.Geometry.Point([13, 45.5]); // // Landsat 8 // var images = landsat8.select(['B2','B3','B4','B5'], ['B','G','R','N']); // varrgb_viz = {min:0, max:0.3, bands:['R','G','B']}; // Sentinel 2 var images = s2.select(['B2','B3','B4','B8'], ['B','G','R','N']); varrgb_viz = {min:0, max:2000, bands:['R','G','B']}; images = images.filterDate('2015-08-01', '2015-12-11'); images = images.filterBounds(geometry); var sample = ee.Image(images.first()); Map.addLayer(sample, rgb_viz, 'sample'); Map.addLayer(images.median(), rgb_viz, 'True Color median');
Script 8 sentinel Min-max • var s2toa =ee.ImageCollection("COPERNICUS/S2"); • varrgb_viz = {min:0, max:2000, bands:['R','G','B']}; • var s2 = s2toa.select(['B2','B3','B4','B5'], ['B','G','R','N']) • .filterDate('2016-01-26', '2016-04-28'); • print(s2.size()); • Map.addLayer(s2, rgb_viz, 'RGB'); • Map.addLayer(s2.max(), rgb_viz, 'max'); • Map.addLayer(s2.min(), rgb_viz, 'min');
Script 9 NDVI • var s2toa =ee.ImageCollection("COPERNICUS/S2"); • varrgb_viz = {min:0, max:2000, bands:['R','G','B']}; • var s2 = s2toa.select(['B2','B3','B4','B5'], ['B','G','R','N']) • .filterDate('2016-01-26', '2016-04-28'); • print(s2.size()); • Map.addLayer(s2, rgb_viz, 'RGB', false); • var image = s2.min(); • Map.addLayer(image, rgb_viz, 'image'); • varndvi = image.normalizedDifference(['N', 'R']); • varndwi_viz = {min:-0.2, max:0.2, palette:'black,green'}; • Map.addLayer(ndvi, ndwi_viz, 'NDVI'); NDVI=(NIR-Red)/(NIR+Red) NormalizedDifferencevegetationIndex
Script 10 sediment identification Example from Caribbean Sea. The problem is to identify the sediment input from the River and detect the seasonal changes of the size and form of the sediment cloud. This is done from multispectral Landsat images. var landsat8 = ee.ImageCollection("LANDSAT/LC08/C01/T1_SR"); var landsat7 = ee.ImageCollection("LANDSAT/LE07/C01/T1_SR"); //var landsat8 = ee.ImageCollection("LANDSAT/LC8_L1T_TOA"), // landsat7 = ee.ImageCollection("LANDSAT/LE7_L1T_TOA"); varrgb_viz = {min:0, max:1500, bands:['R','G','B']}; var rgb_viz1 = {min:0, max:1500, bands:['B','G','N']}; var images = landsat8.select(['B2','B3','B5','B4'], ['B','G','N','R']); var images7 = landsat7.select(['B1','B2','B4','B3'], ['B','G','N','R']); var geometry = /* color: 0000ff */ee.Geometry.Point([-75, 11]); images = images.filterDate('2015-04-01', '2015-04-06'); images = images.filterBounds(geometry); images7 = images7.filterDate('2000-04-01', '2000-12-30'); images7 = images7.filterBounds(geometry); Map.addLayer(images, rgb_viz, 'True Color L8'); Map.addLayer(images, rgb_viz1, 'False Color L8'); Map.addLayer(images7, rgb_viz, 'True Color L7'); Map.addLayer(images7, rgb_viz1, 'False Color L7');
False color image compared to true image Landsat 8 (april 2015
sediment identification by histogram analysis The histograms were generated in Earth Engine for the Caribbean Sea. The near infrared level is similar, the B,G,R levels are higher where sediments are suspended in water. B R G N Water with sediments Water without sediments
Distinction of water covered areas from land areas • Modifying the bands used for the false images we can distinguish water covered areas better from land areas. • This can be accomplished by using the bands N and either one of B,G,R.
Calculate the difference between the two dates • Operations: select Landsat 7 and landsat 8 as in previous excersize, apply a reducer to obtain two single images, then calculate the difference between the two images. At last map the difference image, taking care of the muchsmallervalues, so you must adjust the color-scale accordingly.
var landsat8 = ee.ImageCollection("LANDSAT/LC08/C01/T1_SR"); var landsat7 = ee.ImageCollection("LANDSAT/LE07/C01/T1_SR"); //var landsat8 = ee.ImageCollection("LANDSAT/LC8_L1T_TOA"); //landsat7 = ee.ImageCollection("LANDSAT/LE7_L1T_TOA"); varrgb_viz = {min:0, max:1500, bands:['R','G','B']}; var rgb_viz1 = {min:0, max:1500, bands:['B','G','N']}; var images = landsat8.select(['B2','B3','B5','B4'], ['B','G','N','R']); var images7 = landsat7.select(['B1','B2','B4','B3'], ['B','G','N','R']); var geometry = /* color: 0000ff */ee.Geometry.Point([-75, 11]); images = images.filterDate('2015-04-01', '2015-04-06'); images = images.filterBounds(geometry); images7 = images7.filterDate('2000-04-01', '2000-12-30'); images7 = images7.filterBounds(geometry); varimagesmin = images.min(); var images7min = images7.min(); // calculate normalized difference index between blue and near infrared. Image collection must be reduced before. varndvi = imagesmin.normalizedDifference(['B', 'N']); varndwi_viz = {min:-0.4, max:0.4, palette:'black,green'}; // calculate difference between situation in 2015 and 2000. You must reduce image collection before. var diff = imagesmin.subtract(images7min); Map.setCenter(-75,11, 10); Map.addLayer(diff, {bands: ['B', 'G', 'N'], min: -500, max: 500}, 'difference'); Map.addLayer(ndvi, ndwi_viz, 'ndvi'); Map.addLayer(images, rgb_viz, 'True Color L8','false'); Map.addLayer(images, rgb_viz1, 'False Color L8','false'); Map.addLayer(images7, rgb_viz, 'True Color L7','false'); Map.addLayer(images7, rgb_viz1, 'False Color L7','false');
Difference in false colors. Purple area in oceanicmarks the change in suspendedsedimentdensity
Script 10 a SpectralanalysisPure oceanagainst Oceans with sedimenttransport
varocean=/* color: #2f43d6 */ee.Feature( ee.Geometry.Polygon( [[[-74.6484375, 11.315275668856401], [-74.6539306640625, 11.250631706195998], [-74.5989990234375, 11.216957223287755], [-74.51934814453125, 11.214263094930958], [-74.50836181640625, 11.276221681042255], [-74.5111083984375, 11.3139290681802], [-74.59075927734375, 11.330087858174997]]]), { "class": "ocean", "system:index": "0" }), sedsSuspended=/* color: #98ff00 */ee.Feature( ee.Geometry.Polygon( [[[-74.91073608398438, 11.203486330394338], [-74.91485595703125, 11.177889906154826], [-74.91348266601562, 11.152291222111307], [-74.912109375, 11.12534280296646], [-74.89151000976562, 11.099739495765622], [-74.85580444335938, 11.111867658248435], [-74.83657836914062, 11.130732686400151], [-74.83932495117188, 11.161722578835414], [-74.89151000976562, 11.198097797540497]]]), { "class": "sedsSusp", "system:index": "0" }), town=/* color: #ff725b */ee.Feature( ee.Geometry.Polygon( [[[-74.866965259989, 10.628098527268321], [-74.7625951428015, 10.390453900559237], [-74.5978002209265, 10.352630022088556], [-74.405539478739, 10.417468154740805], [-74.592307056864, 10.509299070077184], [-74.735129322489, 10.63889619415056]]]), { "class": "town", "system:index": "0" }), landsat8=ee.ImageCollection("LANDSAT/LC08/C01/T1_ANNUAL_TOA"); varallClasses=ee.FeatureCollection([ocean, sedsSuspended,town]) print(allClasses) var landsat8_2015=landsat8.filterDate('2015-01-01', '2015-12-31').select(['B[1-7]']); var landsat8_2015=landsat8_2015.median() print(landsat8_2015) varrgb_viz = {min:-0.1, max:0.3, bands:['B4','B3','B2']}; …continua sulla prossima
Continua dalla precedente. • Map.addLayer(landsat8_2015,rgb_viz) • // define chart options for spectral characterization • varchartOptions= • { • title: 'Spectral Signature of LC', • hAxis: {title: 'Wavelength (micrometers)'}, • vAxis: {title: 'Reflectance'}, • lineWidth: 1, • pointSize: 4, • series: { • 0: {color: 'd63000'}, // built-up • 1: {color: '98ff00'}, // green • 2: {color: '8b823b'}, // bare land • } • }; • // define wavelengths corresponding to bands 1 to 7 of Landsat 8 • var wavelengths = [0.44, 0.48, 0.56, 0.65, 0.86, 1.61, 2.2]; • // create a graph and print it • varspectralSignatureChart= ui.Chart.image.regions(landsat8_2015, allClasses, ee.Reducer.mean(), 30, 'class', wavelengths) • .setChartType('LineChart') • .setOptions(chartOptions); • print(spectralSignatureChart); Fine 2 maggio 2019
Corso di Monitoraggio Geodetico e TelerilevamentoEsempio di schede powerpoint portate all’esame Drying of Lake Urmia Di Felice Andrea
Lago Urmia Il lago di Urmia e' un lago salato endoreico situato tra le province iraniane dell'Azerbaigian Orientale e dell'Azerbaigian Occidentale, a occidente del Mar Caspio. Fonte:Google Earth Engine È il maggiore dei laghi interni dell'Iran, con una superficie di circa 5.200 km². Nel periodo di piena misura circa 140 km in lunghezza e 55 km in larghezza, ed ha una profondità massima di 16 m.
A causa del tasso di evaporazione elevato (da 600 mm a 1.000 mm all'anno), il lago di Urmia è in continua fase di restringimento. Per tale motivo, il tasso di salinità del lago , lo rende inadatto alla vita di qualsiasi specie di pesce. Map.setCenter(45.39, 37.7099); Lago Urmia nel 2015 Fonte:Google Earth Engine LagoUrmia nel 1985 Fonte:http://eol.jsc.nasa.gov/sseop/EFS/photoinfo.pl?PHOTO=STS41G-37-84
Per lo studio dell'evoluzione del Lago Urmia si sono utilizzati rispettivamente i satelliti (esempio 14) -Landsat 4 (Periodo:Gennaio Giugno 1991). -Landsat 5 (Periodo : Gennaio-Giugno 2010 ). -Landsat 7 (Periodo: Gennaio-Giugno 2003). -Landsat 8 (Periodo :Gennaio-Giugno 2015). -Sentinel 2 (Periodo: Luglio 2016). var land7 = ee.ImageCollection("LANDSAT/LE7_L1T_TOA"), land8 = ee.ImageCollection("LANDSAT/LC8_L1T_TOA"), land4 = ee.ImageCollection("LANDSAT/LT4_L1T_TOA"), land5 = ee.ImageCollection("LANDSAT/LT5_L1T_TOA"), geometry3 = /* color: #0b4a8b */ee.Geometry.MultiPoint( [[45.318603515625, 37.65773212628272], [45.120849609375, 38.0740414594196], [45.692138671875, 37.142803443716865]]);
varrgb_viz = {min:0, max:0.3, bands:['R','G','B']}; var rgb_viz1 = {min:0, max:0.3, bands:['B','G','R']}; var land8 = land8.select(['B4','B3','B2'], ['R','G','B']);//L8 var land8=land8.filterBounds(geometry3); var land8= land8.filterDate('2015-01-05', '2015-06-30'); var land7 = land7.select (['B3','B2','B1'] , ['R','G','B']); var land7=land7.filterBounds(geometry3); var land7= land7.filterDate('2003-01-01' , '2003-06-30'); var land4 = land4.select(['B3','B2','B1','B4'] , ['R','G','B','N']); var land4=land4.filterBounds(geometry3); var land4=land4.filterDate('1991-01-01','1991-06-30'); var land5 = land5.select(['B3','B2','B1'], ['R','G','B']); var land5 = land5.filterDate('2010-01-01', '2010-06-30'); var land5 = land5.filterBounds(geometry3); Map.addLayer(land4,rgb_viz, 'L4-91'); Map.addLayer(land7.median(),rgb_viz,'L7-03',false); Map.addLayer(land5.median(),rgb_viz,'L5-10',false); //Map.addLayer(land5.median(),rgb_viz1,'L5-10FC',false); Map.addLayer(land8.median(),rgb_viz, 'L8-15',false); //Map.addLayer(land8.median(),rgb_viz1, 'L8-15FC',false); Le bande utilizzate per l'analisi sono state quelle corrispondenti ai 3 colori primari :Rosso , Verde ,Blu. Le immagini sono state analizzate in colori reali(RGB).
var s2= ee.ImageCollection("COPERNICUS/S2"); varrgb_vis = {min:0, max:2000, bands:['R','G','B']}; var s2= s2.select(['B2','B3','B4'], ['B','G','R']); var s2=s2.filterDate('2016-07-01', '2016-07-30') var s2=s2.filterBounds(geometry3); Map.addLayer(s2.median(),rgb_vis, 'S2-16algaebloomTC',false);
var land5 = land5.filterDate('1985-04-01', '1985-08-30'); var land5 = land5.filterBounds(geometry); var land4 = land4.select(['B3','B2','B1','B4'] , ['R','G','B','N']); var land4=land4.filterBounds(geometry3); var land4=land4.filterDate('1991-01-01','1991-06-30');
var land7 = land7.select (['B3','B2','B1'] , ['R','G','B']); var land7=land7.filterBounds(geometry3); var land7= land7.filterDate('2003-01-01' , '2003-06-30'); var land5 = land5.select(['B3','B2','B1'], ['R','G','B']); var land5 = land5.filterDate('2010-01-01', '2010-06-30'); var land5 = land5.filterBounds(geometry3);
var land8 = land8.select(['B4','B3','B2'], ['R','G','B']);//L8 var land8=land8.filterBounds(geometry3); var land8= land8.filterDate('2015-01-05', '2015-06-30'); var s2= s2.select(['B2','B3','B4'], ['B','G','R']); var s2=s2.filterDate('2016-07-01', '2016-07-30') var s2=s2.filterBounds(geometry3); Il colore rosso e' dato da una fioritura algale. R B G
var landsat5 = ee.ImageCollection("LANDSAT/LT5_L1T_TOA"), landsat8 = ee.ImageCollection("LANDSAT/LC8_L1T_TOA"), geometry = /* color: #0b4a8b */ee.Geometry.MultiPoint( [[45.24169921875, 38.09998264736481], [46.153564453125, 37.234701971668166], [28.9599609375, 40.979898069620134]]), geometry2 = /* color: #8b0000 */ee.Geometry.Point([45.263671875, 37.82280243352756]); Map.setCenter(45.10986328125,37.71859032558816); varrgb_viz = {min:0, max:0.3, bands:['R','G','B']}; var land8 = landsat8.select(['B2','B3','B5','B4'], ['B','G','N','R']); var land5 = landsat5.select(['B1','B2','B4','B3'], ['B','G','N','R']); var land8 = land8.filterDate('2017-03-01', '2017-09-30'); var land8 = land8.filterBounds(geometry); var land5 = land5.filterDate('1985-04-01', '1985-08-30'); var land5 = land5.filterBounds(geometry); var land8min = land8.min(); var land5min = land5.min(); varndvi = land8min.normalizedDifference(['B', 'N']); varndvi_viz = {min:-0.2, max:0.2, palette:'black,green'}; vardiff = land8min.subtract(land5min); Map.addLayer(diff, {bands: ['B', 'G', 'N'], min: -0.02, max: 0.05}, 'Difference'); //Map.addLayer(ndvi, ndvi_viz, 'ndvi',false); Map.addLayer(land8.median(), rgb_viz, 'True Color L8'); Map.addLayer(land5.median(), rgb_viz, 'True Color L5');
var land8 = land8.filterDate('2017-03-01', '2017-09-30'); var land8 = land8.filterBounds(geometry); var land5 = land5.filterDate('1985-04-01', '1985-08-30'); var land5 = land5.filterBounds(geometry);
var land8min = land8.min(); var land5min = land5.min(); var diff = land8min.subtract(land5min); Map.addLayer(diff, {bands: ['B', 'G', 'N'], min: -0.02, max: 0.05}, 'Difference'); Dopo la riduzione delle collezioni Landsat5 e 8, dall'immagine risultante del Landsat 8 si e' sottratto l'output del Landsat 5. Le aree bianche-bluastre del lago, rappresentano le variazioni di estensione della superficie dal 1985 al 2017. Situazione pre 1985 Situazione 2017
Conclusioni -La piattaforma Earth Engine si e' rivelata un ottimo strumento per il monitoraggio dell'evoluzione del lago Urmia. Possibili miglioramenti dell'analisi al fine di individuare le principali cause del prosciugamento del lago: -Studio attraverso indice NDVI dello sviluppo delle aree coltivate nei dintorni dell'area in esame in diversi periodi temporali , in relazione al livello del lago. -Studio delle precipitazioni di carattere nevoso in diversi periodi temporali , interessanti i massicci intorno al lago, al fine di stimare il peso in termini di bilancio idrico.
Script 11 Distinguish water from land covered areas var landsat8 =ee.ImageCollection("LANDSAT/LC8_L1T_TOA"); varrgb_viz = {min:0, max:0.3, bands:['R','G','B']}; var rgb_viz1 = {min:0, max:0.3, bands:['B5','B6','B7']}; var images = landsat8.select(['B2','B3','B5','B4'], ['B','G','N','R']); varimages_water = landsat8.select(['B5','B6','B7']); var geometry = ee.Geometry.MultiPoint([12, 45,14,46]); images = images.filterDate('2015-04-01', '2015-04-30'); images = images.filterBounds(geometry); images_water = images_water.filterDate('2015-04-01', '2015-04-30'); images_water = images_water.filterBounds(geometry); Map.addLayer(images, rgb_viz, 'True Color L8'); Map.addLayer(images_water.min(), rgb_viz1, 'False Color L8');
Script 12 Birth of an Island • Between September and October 2013 in the Red Sea an Island was born. This can be well seen in the Landsat 8 images. To enhance the signal we display both the true color and the false color image before and after the appearance of the island. • The approximate coordinate of the area of interest is the following: Long 42.1367,15.0960 • Reference: http://www.nature.com/ncomms/2015/150526/ncomms8104/pdf/ncomms8104.pdf • Possibleotherislandbirth to be observed: april 2015, betweentwo Tonga islands • Reference: Garvin, J. B., Slayback, D. A., Ferrini, V., Frawley, J., Giguere, C., Asrar, G. R., & • Andersen, K. (2018). Monitoringand modeling the rapid evolution of Earth’s newestvolcanicisland: HungaTonga HungaHa’apai (Tonga) using high spatialresolution satellite observations. • Geophysical Research Letters, 45. https://doi.org/10.1002/2017GL076621 DOI: 10.1002/2017GL076621
var landsat8 =ee.ImageCollection("LANDSAT/LC8_L1T_TOA"), geometry = /* color: ffc82d */ee.Geometry.Point([42.136688232421875, 15.095991084505304]); • varrgb_viz = {min:0, max:0.3, bands:['R','G','B']}; • var rgb_viz1 = {min:0, max:0.3, bands:['B5','B6','B7']}; • var images = landsat8.select(['B2','B3','B5','B4'], ['B','G','N','R']); • var images1 = landsat8.select(['B2','B3','B5','B4'], ['B','G','N','R']); • varimages_water = landsat8.select(['B5','B6','B7']); • var images_water1 = landsat8.select(['B5','B6','B7']); • var geometry = ee.Geometry.Point([42,15]); • images1 = images1.filterDate('2013-04-01', '2013-07-01'); • images1 = images1.filterBounds(geometry); • images = images.filterDate('2013-11-1', '2013-12-30'); • images = images.filterBounds(geometry); • images_water1 = images_water1.filterDate('2013-08-01', '2013-09-11'); • images_water1 = images_water1.filterBounds(geometry); • images_water = images_water.filterDate('2013-11-1', '2013-12-30'); • images_water = images_water.filterBounds(geometry); • Map.setCenter(42,15, 10); • Map.addLayer(images1.min(), rgb_viz, 'before'); • Map.addLayer(images.min(), rgb_viz, 'after'); • Map.addLayer(images_water1, rgb_viz1, 'False Color before'); • Map.addLayer(images_water, rgb_viz1, 'False Color after');
Island birth in Red Sea BEFORE AFTER images.filterDate('2013-11-1', '2013-12-30'); images1.filterDate('2013-04-01', '2013-07-01'); Landsat 8. Bands 'B5','B6','B7
Script 13 Trend of light-time- find areas that have expanded the most • Checkdefinition of the image collection: ImageCollection IDNOAA/DMSP-OLS/NIGHTTIME_LIGHTS • Detaileddescription in publication: Elvidge et al. 1997, Photogrammetric Engineering & Remote Sensing, Vol. 63, No. 6, June 1997, pp. 727-734. • Itgivesyearlystablelighttimenear to globallybetween 1992 and 2014 from the analysis of satellite thermalinfraredimaging. It can beusedtocalculate the linear trend of the intensityof night time. Foreach pixel a linearfunctionisfitted, definedby the slope and intercept. In earthengine the twoquantities are termed “scale” and “offset” and are feededintotwoimagebands. These can bemappedeachsingularlyby a grey-toneimage, or together in the color imageof the script.
Bands of the DMSP OLS data product Image and data processing by NOAA's National Geophysical Data Center. DMSP data collected by US Air Force Weather Agency.
Script 15 Compute trend of lightime globally. • // Compute the trend ofnighttimelightsfrom DMSP. • // Add a band containing image date asyearssince 1991. • functioncreateTimeBand(img) { • varyear = ee.Date(img.get('system:time_start')).get('year').subtract(1991); • returnee.Image(year).byte().addBands(img); • } • // Fit a linear trend to the nighttimelightscollection. • varcollection = ee.ImageCollection('NOAA/DMSP-OLS/NIGHTTIME_LIGHTS') • .select('stable_lights') • .map(createTimeBand); • varfit = collection.reduce(ee.Reducer.linearFit()); • // Display a single image • Map.setCenter(30, 45, 4); • Map.addLayer(ee.Image(collection.select('stable_lights').first()), • {min: 0, max: 63}, • 'stablelights first asset'); • // Display trend in red/blue, brightness in green. • Map.addLayer(fit, • {min: 0, max: [0.18, 20, -0.18], bands: ['scale', 'offset', 'scale']}, • 'stablelights trend');
From the eedocumentation, for explanation of the functionsused for the night time trend. See: https://developers.google.com/earth-engine/ic_reducing More complex reductions are also possible using reduce(). For example, to compute the long term linear trend over a collection, use one of the linear regression reducers. The following code computes the linear trend of MODIS Enhanced Vegetation Index (EVI): // This function adds a band representing the image timestamp. varaddTime = function(image) { return image.addBands(image.metadata('system:time_start') .divide(1000 * 60 * 60 * 24 * 365)); }; // Load a MODIS collection, filter to several years of 16 day mosaics, // and map the time band function over it. var collection = ee.ImageCollection('MODIS/006/MYD13A1') .filterDate('2004-01-01', '2010-10-31') .map(addTime); // Select the bands to model with the independent variable first. var trend = collection.select(['system:time_start', 'EVI']) // Compute the linear trend over time. .reduce(ee.Reducer.linearFit()); // Display the trend with increasing slopes in green, decreasing in red. Map.setCenter(-96.943, 39.436, 5); Map.addLayer( trend, {min: 0, max: [-100, 100, 10000], bands: ['scale', 'scale', 'offset']}, 'EVI trend'); Note that the output of the reduction in this example is a two banded image with one band for the slope of a linear regression (scale) and one band for the intercept (offset). Explore the API documentation to see a list of the reducers that are available to reduce an ImageCollection to a single Image. See the ImageCollection.reduce() section for more information about reducing image collections.
From the eedocumentation, for explanation of the functionsused for the night time trend. See: https://developers.google.com/earth-engine/ic_mapping // Load a Landsat 8 collection for a single path-row.varcollection = ee.ImageCollection('LANDSAT/LC08/C01/T1_TOA') .filter(ee.Filter.eq('WRS_PATH', 44)) .filter(ee.Filter.eq('WRS_ROW', 34));// Thisfunctionadds a band representing the image timestamp.varaddTime = function(image) {returnimage.addBands(image.metadata('system:time_start'));};// Map the function over the collection and display the result.print(collection.map(addTime));