JavaScript: Using Google Earth Engine to Monitor Disease Risk

Page 1

Integrating Trypanosomiasis/Tsetse Flies Data with Climatic and Environmental Factors using Google Earth Engine

International Research Institute for Climate and Society, Earth Institute, Columbia University

Pietro Ceccato Carolyn Balk Alice Stevenson Benjamin Marconi


2


CONTENTS

1.

3

2.

4

2.1. What is a Fusion Table?

5

2.2. How to Import Data from Your Computer to a Fusion Table?

6

2.3. How to Import a Fusion Table into Google Earth Engine? 2.3.1. In the fusion table 2.3.2. In Google Earth Engine

7 7 7

2.4. How to Display a Fusion Table as a Map into Google Earth Engine?

8

3.

10

3.1. Load the Tanzania Shape File

10

3.2. Upload LANDSAT8 Images

10

4.

13

4.1. How to Create Water Bodies by Converting the RGB space into HSV space?

13

4.2. Mapping the Water Bodies

16

5.

19

5.1. Load the Precipitation CHIRPS data

19

5.2. Creating Precipitation Time-Series

20

5.3. Mapping Precipitation Data

21

6.

23

6.1. Load the Land Surface Minimum and Maximum Temperature Data from MODIS

23

6.2. Creating Temperature Time-Series

24

1


6.3. Map Temperature Data

24

7.

26

7.1. Load the NDVI from MODIS

26

7.2. Creating NDVI Time-Series

27

7.3. Map NDVI Data

27

2


1.

Introduction

This manual describes how to integrate and visualize health data (e.g. Trypanosomiasis and Tsetse flies) in conjunction with high spatial resolution climate and environmental information within Google Earth Engine (GEE). It describes how to: 1) Upload field measurements data on Trypanosomiasis and Tsetse flies 2) Visualize the data into Google Earth Engine 3) Compare the field data with information on vegetation, bare soil and water bodies derived from monthly LANDSAT images at 30m spatial resolution 4) Identify progression of water bodies on monthly basis 5) Visualize and analyze time series of precipitation data 6) Visualize and analyze time series of temperature data (maximum and minimum land surface temperature) 7) Visualize and analyze time series of vegetation index (Normalized Difference Vegetation Index): NDVI) data

Prior to using this manual and Google Earth Engine, You need to register to Google Earth Engine: In order to use Google Earth Engine, you must be registered for an account in Google Earth Engine using the following URL: https://signup.earthengine.google.com using a @gmail.com email address. Using a @gmail.com email address ensures that you will be able to use add-ons with your account, such as fusion tables. Registration is free and takes maximum 24 hours before receiving confirmation from Google to use Google Earth Engine.

3


2.

Uploading Trypanosomiasis and Tsetse Flies Field Data

The following chapter describes how to upload your field data using the fusion table from Google Earth Engine. Once you have uploaded the field data, you will be able to visualize them into Google Earth Engine. The results will be accessible using the following URL: https://code.earthengine.google.com/8e6409b4b330cbe12eaee5a0a868f7ee

where you can display the field data as in Figure 1

Figure 1: Field data integrated into Google Earth Engine

4


2.1. What is a Fusion Table?

A fusion table is similar to an Excel spreadsheet, except that a fusion table has the capacity for larger sets of data (hundreds and thousands of rows and columns are possible) to be shared seamlessly over the internet. Fusion tables can be created by uploading Excel spreadsheets into the fusion table application. The fusion table application allows users to collaborate together, share, and instantly visualize the data in multiple ways, be it a chart, map, or graph. Users can then embed these images into blogs or websites. Fusion tables also allow users to build upon other publically available fusion tables and share these data with even more users. For more information about fusion tables, click here.

5


2.2. How to Import Data from Your Computer to a Fusion Table? Once you have collected your data and placed them into an Excel file, you can upload the data into a Fusion Table following the steps: 1. Go to Google Drive and sign in with your Google Account (@gmail.com email) 2. Click the New button and select More > Google Fusion Tables. 3. Choose the file to upload from your computer and click Next. ○ Files can be uploaded as comma-separated text (.csv), other textdelimited files (.tsv, etc), KML (.kml) (see “Notes on Creating a Fusion Table” for more information), or spreadsheets (.xls, .xslx, .ods and Google Spreadsheets). ■ Note that country files are in KML. 4. Preview the columns being imported. Click Next. 5. Edit the table's name, attribution and description as needed. You can see and change these values later by selecting File > About. 6. Click Finish. In this example, our fusion table is called “Sampling Points.” 7. (if uploading a set of longitude and latitude points, click Map of Latitude to visualize the points.)

Notes on Creating a Fusion Table: ● Addresses must be in a single column. ● Longitude and latitude points must be in decimal degrees (e.g. 32.453, -15.861), and can be in column with a space in between or in two columns. ● For polygons or shapes, please see the Keyhole Markup Language webpage. ● Each user can only use up to 1 GB of data free of charge. ● Column names cannot have special characters in them, even periods (e.g., “Apple.Banana” must be “AppleBanana”)

6


2.3. How to Import a Fusion Table into Google Earth Engine? In this section you will learn how to import and visualize the fusion table in Google Earth Engine. The result will be accessible using the following URL: https://code.earthengine.google.com/59e6ea9b967c17ba736693e6e563aa25

2.3.1. In the fusion table

1. Click File > About this table 2. At the bottom of the pop-up box, an Id (e.g., ft:1xYp__1IY1AHZADFldNlaqDskYm6byszfgSKWTb-k) will be listed. 3. Copy this Id. 4. Input the Id into the Google Earth Engine code: var tsp = ee.FeatureCollection(‘_______’); The variable “tsp” in this case stands for “Trypanosomiasis Sampling Points.”

2.3.2. In Google Earth Engine

You will write the following script to upload the Fusion Table ID (see Figure 2). Data Upload Specific to the Tsetse Fly and Trypanosomiasis:

Figure 2: Script to upload fusion table for each individual data set 7


2.4. How to Display a Fusion Table as a Map into Google Earth Engine? 1. Input the Google Earth Engine code after the Id: Map.addLayer(tsp,{color:

‘FF0000’}, ‘Sampling Points Location’); ○ FF0000 stands for various color swatches in the red, green, and blue color scheme. FF0000, for example, is full red, but zero blue and green. 2. In order to center the map to the region of interest, input the code:

Map.setCenter(__,__,__) ○ The first number is longitude (east is positive, west is negative), latitude (north is positive, south is negative), and the zoom ratio.

Map Display Specific to the Tsetse Fly and Trypanosomiasis

Map Centering Specific to the Tsetse Fly and Trypanosomiasis:

The map with the fusion table points will look like this (see Figure 3):

Figure 3: Field data integrated into Google Earth Engine

8


The high spatial resolution satellite images from Google Maps are also available in Google Earth Engine. By clicking the “Satellite” button in the top right hand corner, the map will look like this (see Figure 4):

Figure 4: Field data integrated into Google Earth Engine with high spatial resolution images

Because the map is already centered, zooming in cuts off several points. To zoom in, use the “+” and “-” tool in the top left-hand corner. Depending on which area is zoomed in on, it will look like the following (in “map” view) (see Figure 5):

Figure 5: Field data integrated into Google Earth Engine zoom function 9


3.

Upload LANDSAT Images

The following chapter describes how to upload and display monthly LANDSAT8 images at 30m spatial resolution into Google Earth Engine. The results will be accessible using the following URL: https://code.earthengine.google.com/89a019c4469dcd7fd643b4f2b5ffe7ca

3.1. Load the Tanzania Shape File 1. Google Earth Engine has a database of countries saved as a Fusion Table. ○ The Id for Tanzania, United Republic of is ‘1tdSwUL7MVpOauSgRzqVTOwdfy17KDbw-1d9omPw’

3.2. Upload LANDSAT8 Images 1. Type var image = ee.ImageCollection(‘LANDSAT/LC8_L1T_TOA’); 2. Load the Landsat 8 image library and filter the months, type var oct = image.filterDate('2014-10-01', '2014-10-31'); and so on through May 2016

3. To create SWIR/NIR/Red false color composite in order to visualize vegetation in green, water bodies in blue and bare soils in red, take the median of the images to create a seamless image, and clip to desired country (in this case, Tanzania). 10


Type var octClip = oct.select('B6', 'B5', 'B4').median().clip(Country); and so on through May 2016 ○ Recall that we named Tanzania “Country.”

4. To visualize the map, add the map layer, type: Map.addLayer(octClip, {}, 'October 2014'); and so on through May 2016

5. Repeat for all other months. 6. After, add the trypanosomiasis data and display the data using these two codes (see above): var tsp = ee.FeatureCollection(‘ft:1xYp__1IY1AHZADFldNlaqDskYm6byszfgSKWTb-k’); Map.addLayer(tsp,{color: ‘FF0000’}, ‘Sampling Points Location’);

11


7. All codes from Section 1 (Data Upload Specific to the Tsetse Fly and Trypanosomiasis, Map Display Specific to the Tsetse Fly and Trypanosomiasis, and Map Centering Specific to the Tsetse Fly and Trypanosomiasis) continue underneath. The LANDSAT 8 images in “map� view will look like the following (Figure 6):

Figure 6: Field data integrated into Google Earth Engine with monthly LANDSAT8 images

12


4.

Upload and Create Water Bodies Products

The following chapter describes how to upload, create and display monthly water body products derived from LANDSAT8 images at 30m spatial resolution into Google Earth Engine. The results will be accessible using the following URL:

https://code.earthengine.google.com/52a79ee016d488dda9131c17cb0340a5 The algorithm developed to automatically map water bodies is derived from the method developed by Pekel and Ceccato (Pekel et al., 2011) based on the RGB to HSV conversion.

Pekel, JF., Ceccato, P., Vancutsem, C., Cressman, K., Vanbogaert, E., Defourny, P. (2011). Development and Application of Multi-Temporal Colorimetric Transformation to Monitor Vegetation in the Desert Locust Habitat. IEEE Journal of Selected Topics in Applied Earth Observations and Remote Sensing, 4:(2), 318-326

1. First, the LANDSAT 8 images must be loaded (follow the steps in “How to Upload LANDSAT Images.”) 2. Upload the Tanzania shapefile, then upload the LANDSAT 8 image library and filter the months that are of interest, create SWIR/NIR/red false color composite, take the median of the images to create a seamless image, and clip to desired country (i.e. Tanzania) (follow the steps in “How to Upload LANDSAT Images.”). Once these steps have been taken, the water bodies can be created and visualized.

4.1. How to Create Water Bodies by Converting the RGB space into HSV space? 1. Isolate the hue bands for each month. To do so, type

var octHue = octClip.rgbToHsv().select('hue'); and do so for each month desired. In this case, continue to isolate hue bands by using this command for each month through to April. It will look like the following: 13


2. Isolate the saturation bands for each month. This will be done in the same way

as the hue isolation. Type var octSat = octClip.rgbToHsv().select('saturation'); and do so for each month desired. In this case, continue to isolate saturation bands by using this command for each month through to April. It will look like the following:

3. Isolate the value bands for each month. This will be done in the same way as the

hue and saturation isolation. Type var octVal = octClip.rgbToHsv().select('value'); and do so for each month desired. In this case, continue to isolate value bands by using this command for each month through to April. It will look like the following:

4. Create a Cloud Mask This cloud mask will be used in the following step to isolate water. To create the cloud mask, use the isolated value and saturation variables from the above step. Type var octCloud = octVal.gte(0.30).and(octSat.lte(0.85)); var isolatedOctCloud = octCloud.mask(octCloud.eq(0)); 14


and copy both of the above lines for each month desired. In this case, continue create a cloud mask by using this command for each month through to April. It will look like the following:

5.

Isolate the Water Bodies

The final step will be to isolate water and remove the cloud masks from the isolated water. This will result in only water bodies being displayed. To isolate water, use the isolated hue bands from above. Type var octWater = octHue.gte(0.40).and(octHue.lte(0.8333)); var isolatedOctWater = octWater.mask(octWater.eq(1)); var maskedOctWater = isolatedOctWater.subtract(isolatedOctCloud.eq(1)); and copy all of the above lines for each month desired. In this case, continue isolate water and subtract the cloud mask by using this command for each month through to April. It will look like the following:

15


4.2. Mapping the Water Bodies The water bodies have been isolated and can be mapped. To add the layers, type Map.addLayer(maskedOctWater, {palette: ‘FF0000’},‘October 2014 Water Bodies’); and copy this code for each month that must be displayed, in this case the months of October to April. The only thing that will need to change is the palette being used so that the water bodies of each month can be differentiated. The code will eventually look like the following:

16


Ultimately, the map and legend will look like this, with each color representing a different month (Figure 7):

Figure 7: Water body products integrated into Google Earth Engine derived from monthly LANDSAT8 images

By clicking the “Satellite� button in the top right hand corner, the map will look like this (Figure 8):

17


Figure 8: Water body products integrated into Google Earth Engine derived from monthly LANDSAT8 images

18


5.

Upload and Create Precipitation Time-Series

The following chapter describes how to upload, create and display time series of precipitation data set derived from the CHIRPS satellite product at 5km spatial resolution. The results will be accessible using the following URL:

https://code.earthengine.google.com/3f417c197c00798d2feec5752f59f34e

Load the Tanzania Shapefile To do this, type var Country = ee.FeatureCollection(‘ft:1tdSwUL7MVp0auSgRzqVT0wdfy17KDbw1d9omPw’).filterMetadata('Country', ‘equals’, ‘Tanzania, United Republic of’);

5.1. Load the Precipitation CHIRPS data This will be done in a similar way to loading the Tanzania shapefile. 1. Load the CHIRPS dataset. To do so, type var CHIRPS = ee.ImageCollection(‘UCSB-CHG/CHIRPS/PENTAD’); 2. Next, identify the country for which the time series is being created. In this case, Tanzania will be identified using the same feature collection code that was used to import the shapefile. Type var Tanzania = ee.FeatureCollection(‘ft:1tdSwUL7MVp0auSgRzqVT0wdfy17KDbw1d9omPw’).filterMetadata('Country', ‘equals’, ‘Tanzania, United Republic of’); 3. Identify the small region of interest for extracting the time series. This will be done using the polygon feature on the map. The area of interest must be selected on the map and named. In this case, a small area of Tanzania was selected using the “Draw a Shape” tool located on the toolbar in the far left corner of the Google Earth Engine map. The polygon in this case looked like this:

19


and the code looked like this:

Once this has been done, and the polygon has been named, load the variable. Type var small_region

5.2. Creating Precipitation Time-Series 1. To create a full time series, select the full range of dates of the CHIRPS data.

This will be from January 1, 1981 to February 27, 2016. Once this is done, the time series will need to be made specific to the small region determined above. The resulting time series will be located on the right-hand console. It will be available for export and the data will be available for download by clicking on the icon in the top right corner. The code for this will look like the following:

20


And the time series will look like this:

2. To get more specific, simply change the first line of code to reflect the desired

dates for the time series. If, for example, a one-year precipitation time series is required, the dates may range from January 1, 2015 to December 31, 2015. The code to do so will look like the following:

The resulting time series will also be located on the right-hand console. It will be available for export and the data will be available for download by clicking on the icon in the top right corner. It will look like this:

5.3. Mapping Precipitation Data 1. To map the entire range of precipitation data available in the CHIRPS dataset, clipped to the Tanzania region, the code will look like the following:

The result will be the mean precipitation values from 1986 to 2015 added to the map. 21


2.

The same can be done for the smaller range of precipitation values. The only difference, like in the time series, will be the date range. The following is an example of the code for the same one-year time series visualized above:

The result will be the mean precipitation values for all months of 2015 added to the map (Figure 9).

Figure 9: Precipitation CHIRPS data set

22


6.

Upload and Create Temperature Time-Series

The following chapter describes how to upload, create and display time series of maximum and minimum Land Surface Temperature derived from MODIS sensor at 1 km spatial resolution. The results will be accessible using the following URL:

https://code.earthengine.google.com/f41320aba02e6abcc5e945546847eb24

Load the Tanzania Shapefile To do this, type var Country = ee.FeatureCollection(‘ft:1tdSwUL7MVp0auSgRzqVT0wdfy17KDbw1d9omPw’).filterMetadata('Country', ‘equals’, ‘Tanzania, United Republic of’);

To select a small region of interest within the loaded national shapefile, type the command below. This command names the geometry which has been created using the polygon feature on the map: var small_region

6.1. Load the Land Surface Minimum and Maximum Temperature Data from MODIS Select the temperature data set from MODIS Land Surface Temperature Day and Night, and collect bands (and scale) for Day Time. To distinguish between day and night, alter the code in the “selection” section as shown below.

23


Select the desired dates for which data can be pulled from the MODIS database, the LANDSAT imagery and the fusion table. The temporal scale of all three sources must be the same (overlapping) to effectively select dates. In this example the first day/night collection spans from January 1st, 2000 to March 31st, 2016. The second set spans January 1st, 2015 to December 31st, 2016.

The next step involves assigning the collection05night/day and collection01night/day to a specified region of Tanzania. To do so, a new variable named “clipped” is assigned to a sector of the larger polygon that contains the dates selected above. The command “clip” limits the values in an array, in this case the data is being averaged across the time series.

6.2. Creating Temperature Time-Series To chart both the short and long term time series selected, the 5-year period is names TS5 and the one year period TS1. To chart the data, the command Chart.image.series is used, where the time series, region and the reducer command ee.Reducer.mean() are specified in parenthesis (reducers aggregate data over time and space).

6.3. Map Temperature Data To finally map the day temperature for the 2015 mean values and 2000-2016 range mean values, use the command Map.addLayer. To incorporate a wide range of 24


temperatures, the lower bound is set to 0 degrees Celsius (‘min’) and the upper bound to 40 degrees (‘max’). The commands should look like:

Figure 10: Temperature from MODIS data set

The plotted mean LST 2015 (and 2000-2016) values should look like the image above (Figure 10) when the filter is selected.

25


7.

Upload and Create Vegetation Index Time-Series

The following chapter describes how to upload, create and display monthly vegetation index (Normalized Difference Vegetation Index) derived from MODIS at 250 m spatial resolution into Google Earth Engine. The results will be accessible using the following URL:

https://code.earthengine.google.com/b9955c728d7216347d4a69ce3611b1fb

Load the Tanzania Shapefile To do this, type var Country = ee.FeatureCollection(‘ft:1tdSwUL7MVp0auSgRzqVT0wdfy17KDbw1d9omPw’).filterMetadata('Country', ‘equals’, ‘Tanzania, United Republic of’);

To select a small region of interest within the loaded national shapefile, type the command below. This command names the geometry which has been created using the polygon feature on the map: var small_region

7.1. Load the NDVI from MODIS Select the NDVI data set from MODIS NDVI: var modisNDVI = ee.ImageCollection('MODIS/MCD43A4_NDVI'); Values for NDVI exist as one value per month, so data is filtered into two time ranges as in the temperature data section above var collection05 = ee.ImageCollection(modisNDVI.filterDate('2002-01-01', '2016-1231'));

26


var collection01 = ee.ImageCollection(modisNDVI.filterDate('2008-01-01', '2008-1231'));

7.2. Creating NDVI Time-Series As with temperature, the temporal specification must be clipped to the specific Tanzanian region using the “.mean().clip command� : var clipped05 = collection05.mean().clip(region) var clipped01 = collection01.mean().clip(region)

The long-term time series is plotted for the full time period within the smaller region specified above. Time series one is denoted TS5.The single year time series is represented with TS1.

7.3. Map NDVI Data To map the NDVI composite for one year (2008), a layer is added to the map, using the clip command to limit the data array to values between 0 and 1. The color scheme is defined using the palette command to create 8 unique shades.

The map of the NDVI composite for the full 2002-2016 time series is coded the same as the shorter series (Figure 11).

27


Figure 11: NDVI from MODIS data set

The addition of disease data should plot on the map much like the image below (Figure 12). The finished map with the command Map.setCenter assigned to (36.5, -4, 9) should appear similar to Figure 12:

Figure 12: NDVI data with field data.

28


Turn static files into dynamic content formats.

Create a flipbook
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.