Google earth engine sentinel 2

Google earth engine sentinel 2 DEFAULT

Sentinel 2A surface reflectance product

step 1: import the administrative data and select the province of interest.

var cambodia = ee.FeatureCollection("users/servirmekong/countries/KHM_adm1"); var KampongThum = cambodia.filter(ee.Filter.eq("NAME_1","Kâmpóng Thum")).geometry();

step 2: Set band information.

var inBands = ee.List(['QA60','B1','B2','B3','B4','B5','B6','B7','B8','B8A','B9','B11','B12']); var outBands = ee.List(['QA60','cb','blue','green','red','re1','re2','re3','nir','re4','waterVapor','swir1','swir2']);

step 3: set time period and cloud filter variables.

var CloudCoverMax = 30; var startDate = "2018-01-01"; var endDate = "2018-12-31"; var studyArea = KampongThum;

step 4: import the sentinel 2A data.

// Get Sentinel-2 data var s2 = ee.ImageCollection('COPERNICUS/S2_SR') .filterDate(startDate,endDate) .filterBounds(studyArea) .filter('CLOUDY_PIXEL_PERCENTAGE',CloudCoverMax)) .filter('CLOUD_COVERAGE_ASSESSMENT',CloudCoverMax));

step 5: write a function to scale the data.

// scale the data var scaleData = function scaleBands(img){ var prop = img.toDictionary(); var myImg =['B1','B2','B3','B4','B5','B6','B7','B8','B8A','B9','B11','B12']).divide(10000); myImg = myImg.addBands(['QA60'])).set(prop).copyProperties(img,['system:time_start','system:footprint']); return ee.Image(myImg); };

step 6: Scale the data

var s2 =,outBands);

step 7: Display the data

var s2 =,outBands); Map.addLayer(s2.median().clip(KampongThum),{min:0,max:0.6,bands:"swir1,nir,red"}, "surface reflectance KKampong Thum");


Like this:



IGIS Tech Notes describe workflows and techniques or using geospatial science and technologies in research and extension. They are works in progress, and we welcome feedback and comments below.

by Annie Taylor


Google Earth Engine (EE) is a cloud/browser-based platform for planetary scale geospatial analysis that relies on Google's processing and storage capabilities to enable large analyses in very little time. Earth Engine is home to hundreds of public remote sensing/geospatial datasets totaling more than thirty petabytes, and is continuously updated as images are captured. Here, we take advantage of the up-to-date and easy-to-access satellite imagery in Earth Engine to calculate and display a vegetation index (NDVI) from recent Sentinel imagery, anywhere on earth. This Tech Note reviews the code necessary to do this in Earth Engine based on requests to leverage this tool for agricultural applications.

Need some help getting started? View the recording of our Introduction to Earth Engine workshop (July 2020).

Get started in Earth Engine (new users)

  1. Register for an Earth Engine account at with a Gmail account.
  2. Once you’re an approved user (can take a day or two), go to the Earth Engine Interface at to get started.
  3. If you’re completely new to Earth Engine, you may want to check out the Earth Engine Get Started guide or the API Tutorials. You can also watch a recording of our Introduction to Earth Engine Workshop.

Import Sentinel-2 Imagery within your study area

Note: if you choose to copy and paste these lines of code into the EE Code Editor, you may need to re-type the quote marks, as these may not paste correctly.

  • Import all available Sentinel 2 surface reflectance imagery as an ee.ImageCollection:
  • Using the drawing tools in the top left of the map, draw a point or rectangle representing your study area. Press ‘Exit’ when you have finished your drawing, or select a shape and press ‘delete’ to remove it. This shape will automatically be called ‘geometry.’
Drawing Toollbar
Exit Drawing Mode
  • Modify your first line to filter the image collection just to your study area.
  • Center your map at your study area.
  • Optional: if you’d like to filter for images captured between two dates, use the filterDate() function shown below, with dates formatted as ‘yyyy-mm-dd’.

Calculate NDVI from the Sentinel-2 imagery

  • Create a function that adds an NDVI band to a Sentinel-2 image. NDVI is calculated as the normalized difference between the near-infrared band and the red band, which correspond to the 8th and 4th band in the Sentinel-2 imagery.
  • Apply this function across your image collection using the ‘map’ function to add NDVI as a band to each image and save it as a new image collection.

Select the Most Recent Image

  • Sort the image collection by date and select the most recent image to save it as a new variable.
  • Print the image’s metadata to the console to view its metadata, including the date it was captured.

Add the Most Recent NDVI Image to the Map

  • Create a variable with the NDVI color scheme/palette.
  • Select just the NDVI band and add the NDVI image to the map using the NDVI color scheme. Name the layer ‘Recent NDVI’ for the map legend.
  • Hit the ‘Run’ button to see the resulting NDVI image displayed on the Map, and to view the image metadata that is now printed to the Console (right side of the screen). To see the map more clearly, check off the shape you drew by hovering over the Geometry Imports bar and unchecking the box next to ‘geometry.’

You’re done! Here are a few potential next steps:

  1. Check out acopy of the final codein Earth Engine to check your work.
  2. Explore the NDVI value at a given point by selecting the Inspector tool (upper right) and clicking at any point on the image.
  3. Calculate the average, minimum, or maximum NDVI value across your study area with theReduce Regions function.
  4. Explore how tofilter out cloudy pixels in Sentinel imagery, if this is a common issue in your study area.
  5. Export the raster as a GeoTIFFto analyze it in other geospatial software programs.
  6. Calculate a multi-day NDVI median composite image using the ten most recent images. This optional code is also included in theEE script.

More Resources

This work was supported by the USDA - National Institute of Food and Agriculture (Hatch Project 1015742; Powers).

  1. Lake cumberland homes for rent
  2. Duplex in forest park ga
  3. In the middle of meaning
  4. Osrs greater demon locations

4. Intro to Sentinel-2¶

Sentinel-2 satellites (there are 2) are part of the European Space Agency’s (ESA) Copernicus system and contain the MultiSpectral Instrument (MSI), which provides hi-resolution imagery that is useful for land use monitoring.

As with other datasets in Google Earth Engine (GEE), more details and links to resources are available on the collection’s landing pages.

What is important for us is that it has several image bands across the optical electromagnetic spectrum that will be useful feature for classifying land use, particular that of built-up areas.

Let’s explore this data source and get sense of it’s resolution and attributes.

For visualization we’ll look at just the Red, Green and Blue channels and clip around Nepal.

# reminder that if you are installing libraries in a Google Colab instance you will be prompted to restart your kernaltry:importgeemap,eeexceptModuleNotFoundError:if'google.colab'instr(get_ipython()):print("package not found, installing w/ pip in Google Colab...")!pip install geemap else:print("package not found, installing w/ conda...")!conda install mamba -c conda-forge -y !mamba install geemap -c conda-forge -y importgeemap,ee
try:ee.Initialize()exceptExceptionase:ee.Authenticate()ee.Initialize()# get our Nepal boundaryaoi=ee.FeatureCollection("FAO/GAUL/2015/level0").filter(ee.Filter.eq('ADM0_NAME','Nepal')).geometry()# Sentinel-2 image filtered on 2019 and on Nepalse2=ee.ImageCollection('COPERNICUS/S2').filterDate("2019-01-01","2019-12-31").filterBounds(aoi).median().divide(10000)rgb=['B4','B3','B2']# set some thresholdsrgbViz={"min":0.0,"max":0.3,"bands":rgb}# initialize our mapmap1=geemap.Map()map1.centerObject(aoi,7)map1.addLayer(se2.clip(aoi),rgbViz,"S2")map1.addLayerControl()map1

We can see a real color image of Nepal. We reduced our Image Collection to an image representing the median of 2019 and it appears we’ve also captured some clouds around Kathmandu. We will make a cloud mask to clear the image up using Sentinel-2’s QA band. We’re modeling this (in Python) from the example used in GEE:

defse2mask(image)'QA60')# using the bit mask for clouds and cirrus clouds respectivelycloudmask=1<<10cirrusmask=1<<11# we only want clear skiesmask=quality_band.bitwiseAnd(cloudmask).eq(0)and(quality_band.bitwiseAnd(cirrusmask).eq(0))# we'll divide by 10000 to make interpreting the reflectance values easierreturnimage.updateMask(mask).divide(10000)se2=ee.ImageCollection('COPERNICUS/S2').filterDate("2019-01-01","2019-12-31").filterBounds(aoi).filter("CLOUDY_PIXEL_PERCENTAGE",20)).map(se2mask).median()# initialize our mapmap2=geemap.Map()map2.centerObject(aoi,7)map2.addLayer(se2.clip(aoi),rgbViz,"S2")map2.addLayerControl()map2

That cleared things up nicely!

Next we’ll integrate Sentinel-2 image data with VIIRS-DNB nighttime lights.


Freud has a reputation for being a universal genius, albeit out of this world. Agree, Dima convinces me. - Freud once. will telepathically, and she will push it apart in front of you. I throw a pillow into Dimka, he dodges and the pillow hits.

Earth sentinel 2 engine google

Her robe, as if by accident, crawls up, and I suddenly notice that there is NOTHING under it. - So I was sitting, or were my legs wider apart. Im silent, as dumb. Maybe its better like this. - Ophira spreads her knees wider, and I see the cherished pink stripe opening to my eyes.

Supervised Classification with Sentinel 2 Satellite Images - Google Earth Engine - Machine Learning

I was shocked, but said that this is so and that I really want. it made me even hotter. she sucked me in again.

Now discussing:

And I was in no hurry to let her out of there, to the screams and sounds of frantic sex, the servants came running, and then the guests came up. And in front of this whole crowd, a picture appeared as a guy with the most insignificant title, frying the Countess in the. Ass, like the cheapest prostitute.

And she likes all this indecency, she likes it very much.

252 253 254 255 256