Finally, Google Earth Engine Plugin for QGIS was Released

Long time ago I wrote a post about Google Earth Engine with the title Geospatial Technology Innovation from Google. While writing the post, I imagined if I could use Google Earth Engine in QGIS rather than in a web browser, because at that time I felt a little bit weird doing GIS thing in a web browser. 

Like a dream come true, just several days ago, the Google Earth Engine plugin for QGIS was released. The plugin was authored by Gennadii Donchyts with first version 0.0.1 and working with minimum QGIS version 3.8.0.

Google Earth Engine Plugin Installation

Like any other plugins, the GEE plugin can be installed from QGIS plugin repository. Let's see how to install in the following step.

From the Plugin menu select Manage and Install Plugins... The plugin windows will appear as in figure 1. In the search menu type google. The Google Earth Engine plugin will show up. Select it and push Install  Plugin button

Google Earth Engine QGIS Plugin Installation
Figure 1. Google Earth Engine QGIS Plugin Installation
In the installation process, an authorization token is required. Therefore we need to log in to google account to get the token. As shown in figure 2,  log in to your google account and copy the key. Paste the key to the Authorization window as in figure 3.    

Log in to google account to get authorization token
Figure 2. Log in to google account to get authorization token


Authorization window
Figure 3.. Authorization window

Testing The Installation

To test the plugin installation, open python console as in figure4. Then import the Google Earth Engine module with import ee code syntax. Run the code. If there is no error appear, then the plugin was successfully installed.

Testing Google Earth Engine Plugin Installation
Figure 4. Testing Google Earth Engine Plugin Installation

How to Use Google Earth Engine Plugin in QGIS?

Google Earth Engine is a scripting module. To use it we need to know the code syntax or function to do a job, a processing or analysis task. There are many things we could do with Google Earth Engine, because it has so rich dataset and analysis tools. With this plugin available in QGIS, we can access directly the dataset and doing analysis in QGIS, which made it's so powerful to do remote sensing data processing and analysis.

Now, let's see how to use the Google Earth Engine plugin in QGIS with some examples.

Adding Data/Satellite Imagery

For the first example we will add Landsat 8 satellite imagery with false color composite. To add a data or satellite imagery from Google Earth Engine we need to know the image full name. In the Google Earth Engine Data Catalog can be found the dataset's name and all the details. The following code shows how to add Landsat satellite imagery in QGIS with Google Earth Engine. Figure 5 shows the Landsat 8 imagery was added to QGIS map canvas.

import ee
from ee_plugin import Map
image = ee.Image('LANDSAT/LC08/C01/T1_TOA/LC08_044034_20140318'); #Define the visualization parameters. vizParams = { 'bands': ['B5', 'B4', 'B3'], 'min': 0, 'max': 0.5, 'gamma': [0.95, 1.1, 1] }; #Center the map and display the image. Map.setCenter(-122.1899, 37.5010, 10); #San Francisco Bay Map.addLayer(image, vizParams, 'false color composite');

Landsat 8 satellite imagery false color composite in QGIS
Figure 5. Landsat 8 satellite imagery false color composite in QGIS

Normalized Difference Vegetation Index (NDVI) Calculation


The next example we will perform NDVI calculation using the same imagery. To do NDVI calculation, Red and Near Infrared satellite bands are required. In Landsat 8 the Red band is band 4 and band 5 is near infrared. To calculate NDVI values, the normalizedDifference function is used. The following code shows how to calculate NDVI with Google Earth Engine scripts and the result can be seen in the figure 6.

import ee
from ee_plugin import Map
landsat8=ee.Image('LANDSAT/LC08/C01/T1_TOA/LC08_044034_20140318');
ndvi=landsat8.normalizedDifference(['B5','B4']);
Map.addLayer(ndvi,{'min':-1, 'max':1, 'palette':['blue', 'white', 'red']}, 'NDVI', True)

NDVI image QGIS GEE
Figure 6. NDVI image result

Quantifying Forest Change

Last example in this post, we will quantify forest change based on Hansen global forest change data. In the code below, two images are selected each for gain and loss. Using And operator the two images are combined, so we get gain and loss image. The result can be seen in the figure 7. Find out more about this tutorial in Global Forest Change Tutorial.

import ee
from ee_plugin import Map

gfc2014 = ee.Image('UMD/hansen/global_forest_change_2015');
lossImage = gfc2014.select(['loss']);
gainImage = gfc2014.select(['gain']);

#Use the and() method to create the lossAndGain image.
gainAndLoss = gainImage.And(lossImage);

#Show the loss and gain image.
Map.addLayer(gainAndLoss.updateMask(gainAndLoss),{'palette': 'red'}, 'Gain and Loss');

Quantifying forest change QGIS Google Earth Engine
Figure 7. Quantifying forest change
There are a lot of tutorials available in Google Earth Engine website. Just check it for yourself. Most of the tutorial in Javascript, so we have to adapt it little bit with Python syntax, but the function and other things remain the same.

That's all this post about Google Earth Engine Plugin for QGIS 3. In this post we had learnt how to install the Google Earth Plugin in QGIS, testing the installation and see some examples how to apply it in QGIS. Thanks for reading.

Related Posts

Disqus Comments