A new question derived from my Seeking website to do geoprocessing online?

In Google Earth Engine, is it possible (if so, how?) to draw a polygon and extract the land cover inside?

I would guess so, since it says in the Google Earth Engine API page:

The functionality of Earth Engine is exposed through an API available in both JavaScript and Python. The API supports complex geospatial analyses including overlay, map algebra, array operations, image processing, classification, change detection, time series analysis, joins, raster-vector conversions, vector-based extraction of image statistics and much more. Algorithms are constantly being added, enhanced and updated. Through the API, users are free to script more complex analyses and creatively recombine existing algorithms. Reporting of results is supported through charting, mapping and table or image export.

  • What you really need is a 'clip' function. I have asked before but is there a reason for not using an open source GIS program like QGIS? It would be a piece of cake on such a program. – Kingfisher Feb 18 '16 at 18:06
  • It needs to be accessible from the Web for our client. It's not ideal to have them install a software, even if it's open source. – Nahas Feb 18 '16 at 18:10
  • What area are you considering doing that ? – PROBERT Feb 18 '16 at 18:24
  • @PROBERT : The areas of extraction are catchments distributed world wide. – Nahas Feb 18 '16 at 18:43
  • @Nahas . Good luck with that ! I hope you can find what you need. – PROBERT Feb 18 '16 at 19:25

To use Earth Engine to extract landcover information for a polygon region, do the following steps. The example demonstrates using the ESA GlobCover 2009 landcover dataset, but other landcover datasets could be analyzed similarly.

  1. Open up the Earth Engine Code Editor application at https://code.earthengine.google.com/. If you do not currently have access to Earth Engine, you will be presented with instructions on how to register for access.
  2. In the search box, type in landcover.
  3. From the results returned, select the GlobCover: Global Land Cover Map landcover dataset.
  4. Click the Import button to add the dataset as a variable to the Imports section of the Code Editor. Rename the variable from the default name "image" to "globcover".
  5. Using the Draw a shape tool located in the upper left corner of the map, draw a polygon on the map. By default, the polygon will be named "geometry"
  6. Type in the following Javascript code into the editor window:
    // Extract the landcover band
    var landcover = globcover.select('landcover');
    // Clip the image to the polygon geometry
    var landcover_roi = landcover.clip(geometry);
    // Add a map layer of the landcover clipped to the polygon.
    // Print out the frequency of landcover occurrence for the polygon.
    var frequency = landcover.reduceRegion({
    print('landcover frequency', frequency.get('landcover'));
  1. Click "Run" to execute the code, which will display landcover for the polygon, and print the landcover frequency statistics (sampled on a 1000m grid) to the console tab.
  • Just a detail : Can I get a percentage instead of a pixel count? I asked in a new question here. – Nahas Feb 25 '16 at 20:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.