lunes, 3 de julio de 2023

Lionel Messi seen from the sky!!

Since the last FIFA World Cup everyone has been talking about Messi. But one person in Córdoba (ARG) went one step further: a drawing of Lionel Messi in the crop! So it can be seen from the sky!. To be able to see it you need to be registered to Google Earth Engine. Let's have a look!

Open the code editor and write:

//import Sentinel 2 collection
var s2 = ee.ImageCollection("COPERNICUS/S2_SR")
// Define a region
var region = ee.Geometry.Polygon([[
  [-64.27491667317739,-32.30908813533604],
  [-64.27491667317739,-32.313585635718105],
  [-64.27079680013051,-32.313585635718105],
  [-64.27079680013051,-32.30908813533604]
]])
// Filter the collection using the defined region
var filtered = s2.filterBounds(region)
// Filter by dates
filtered = filtered.filterDate('2023-01-01', '2023-01-15')
// Filter clouds
filtered = filtered.filter(ee.Filter.lt('CLOUD_COVERAGE_ASSESSMENT', 20))
// Convert the collection into a list
var ilist = filtered.toList(filtered.size())
// there are 3 images in this period, get the first one (you can also try with the others)
var i = ee.Image(ilist.get(0))
// compute a vegetation index 
var nd = i.normalizedDifference(['B8', 'B4'])
// clip with the region 
nd = nd.clip(region)
//Get the date of the image to show as the name of the image in the map
var d = i.date().format('yMMdd').getInfo()
// Get the min and max values of the vegetation index in the region we defined
var minmax = nd.reduceRegion({
  reducer:ee.Reducer.minMax(),
  geometry: region,
  scale: 10
}).getInfo()
var min = minmax['nd_min']
var max = minmax['nd_max']*0.7 // stretch
// create visualization parameters (you can play around with the palette in this section)
var vis = {min:min, max:max, palette:['pink', 'brown', 'black']}
// add layer to map
Map.addLayer(nd, vis, d)
// center scene
Map.centerObject(region, 16)

Or just use the following link: https://code.earthengine.google.com/447a24f33cedfa8a8c676d822340bb73

No hay comentarios:

Publicar un comentario