Skip to content

Latest commit

 

History

History
457 lines (336 loc) · 11.7 KB

index.md

File metadata and controls

457 lines (336 loc) · 11.7 KB
title description author tags date_published
An Introduction to Geospatial Analysis
This workshop provides a fundamental overview of remote sensing and geospatial analysis using the JavaScript API of Earth Engine.
TC25
introductory, GIS, remote sensing, Google Earth Engine
2019-10-09

Geometries - Open In Code Editor

Features - Open In Code Editor

Images - Open In Code Editor

Image to Table - Open in Code Editor

Timelapse - Open in Code Editor

We will introduce types of geospatial data, using these data on the Earth Engine platforms, and discuss a host of functionality to visualize and analyze them. This workshop was originally created for a workshop during Yale-NUS Data 2.0 hackathon and then updated for Yale GIS Day 2018.

Introduction

Collection, visualization, and analysis of geographical or spatial data.

Data types

  • Vector data represent lat-long coordinates
  • Raster data comprises of pixels with associated values

  • Points

Points

  • Lines

Lines

  • Polygons

Polygons

  • Raster layers/bands

Raster

Image sources: https://gisgeography.com/spatial-data-types-vector-raster/


Google Earth Engine platform

Introductory video

Code Editor

  • Cloud-based platform for planetary scale geospatial analysis
  • Uses Google's computational resources to reduce processing time
  • Massive archive of remote sensing data
  • 200+ public datasets
  • over 4000 new images every day
  • over 5 million images
  • over 30 petabytes of data

Source: Google Earth Engine User Summit


Code Editor (Source: developers.google.com)


Basic Functions

Declaring variables

var variableName = ee.ContainerType(value);

A container (in the form ee.variabletype) is used to wrap up a native javascript object type so that Google's server can recognize its structure and perform operations on it

Centering map

Map.setCenter(long, lat, zoomLevel);

Zoom level varies from 0 (no zoom) to 20 (highest zoom level)

Displaying metadata

print(variableName);

You cannot print more than 5000 elements at once.

Adding a layer to the map

Map.addLayer(variableName);

Variable types in Earth Engine

Strings

var str = ee.String('This is a string. Or is it? It is.');

Numbers

var num = ee.Number(5);

Arrays

var arr = ee.Array([[5, 2, 3], [-2, 7, 10], [6, 6, 9]]);

Lists

var lis = ee.List([5, 'five', 6, 'six']);

Dictionaries

var dict = ee.Dictionary({five: 5, six: 6});

And the fun stuff

  • Geometries
  • Features
  • Feature Collections
  • Images
  • Image Collections

Geometries – declaration and types

Points

var poi = ee.Geometry.Point(0, 45);

Multi Points

var multi = ee.Geometry.MultiPoint(0, 45, 5, 6, 70, -56);

Line String

var lineStr = ee.Geometry.LineString([[0, 45], [5, 6], [70, -56]]);

Multi Line String

var mlineStr =
ee.Geometry.MultiLineString([[[0, 45], [5, 6], [70, -56]], [[0, -45], [-5, -6], [-70, 56]]]);

Linear Ring

var linRin = ee.Geometry.LinearRing(0, 45, 5, 6, 70, -56, 0, 45);

Rectangle

var rect = ee.Geometry.Rectangle(0, 0, 60, 30);

Polygon

var poly = ee.Geometry.Polygon([[[0, 0], [6, 3], [5, 5], [-30, 2], [0, 0]]]);

Multi Polygon

var multiPoly =
ee.Geometry.MultiPolygon([ee.Geometry.Polygon([[0, 0], [6, 3], [5, 5], [-30, 2], [0, 0]]),
ee.Geometry.Polygon([[0, 0], [-6, -3], [-5, -5], [30, -2], [0, 0]])]);

Features and Feature Collections

  • Features are geometries associated with specific properties
  • Feature Collections are groups of features

Chicago map by neighborhood


Functions and mapping

  • A set of instructions to perform a specific task
function functionName(Arguments) {
statements;
};

Call function

var result = functionName(input);

Map function over Feature or Image Collection

var result = input.map(functionName);

Mapping a function over a collection sends the each element of the collection to a different server to be processes.


Operations on Geometries

Geometry operations

Find area of geometry

var geoArea = geometry.area();

All units in Earth Engine are in meters

Find length of line

var linLen = lineString.length();

Find perimeter of geometry

var geoPeri = geometry.perimeter();

Reduce number of vertices in geometry

var simpGeo = geometry.simplify(100);

Find centroid of geometry

var centrGeo = geometry.centroid();

Create buffer around geometry

var buffGeo = geometry.buffer(100);

Find bounded rectangle of the Geometry

var bounGeo = geometry.bounds();

Find the smallest envelope that can envelop the Geometry

var convexGeo = geometry.convexHull();

Find common area between two or more geometries

var interGeo = geometry1.intersection(geometry2);

Find area that includes two or more geometries

var unGeo = geometry1.union(geometry2);

Operations on Features

Feature operations

Set property name and value of geometry to create a feature

var feat = ee.Feature(geometry, {Name: 'featureName', Size: 500});

Create a new feature from existing feature while renaming a property

var featNew = feature.select(['name'], ['descriptor']);

Extract values of a property from a Feature

var featVal = feature.get('size');

Filters

Creator a filter for values of a property

var bFilter = ee.Filter.eq(propertyName, value);

or .neq , .gt , .gte , .lt , and .lte

Create a filter based on maximum difference from a threshold

var diffFilter = ee.Filter.maxDifference(threshold, propertyName, value);

Create a text filter

var txtFilter = ee.Filter.stringContains(propertyName, stringValue);

or .stringStartsWith, and .stringEndsWith

Create a range filter

var rangeFilter = ee.Filter.rangeContains(propertyName, stringValue, minValue, maxValue);

Create a list filter to check for certain values

var listFilter = ee.Filter.listContains(propertyName, value1, propertyName2, value2);

.inList to test against list of values

Create a filter of dates

var dateFilter = ee.Filter.calendarRange(startDate, stopDate);

Create a filter for particular days of the year

var dayFilter = ee.Filter.dayOfYear(startDay, stopDay);

Create a filter to subset geospatial data

var boundsFilter = ee.Filter.bounds(geometryOrFeature);

Combining and inversing filters

var newFilter = ee.Filter.and(listOfFilters);
var newFilter = ee.Filter.or(listOfFilters);
var inverseFilter = ee.Filter.not(filter);

Operations on Images

Image operations

Selecting the bands of an image

var band = var_Image.select(bandName);

Creating masks

var mask = image.eq(value);

or .neq or .gt or .gte or .lt or .lte

Applying masks

var masked = image.mask(mask);

Pixelwise calculation

var results = image.sum(value);

or .subtract , .multiply , .divide , .max , .min , .abs , .round , .floor , .ceil , .sqrt , .exp, .log, .log10, .sin , .cos , .tan , .sinh , .cosh , .tanh , .acos, .asin

Shift pixels of an image

newImage = oldImage.leftShift(valueOfShift);

or .rightShift

Create a single value from an image by applying a reducer based on regions of interest

var outputDictionary = varImage.reduceRegion(reducer, geometry, scale);

Operations on Image Collections

Select the first n numbers of images in a collection (based on property)

var selectedImages = imCollection.limit(n, propertyName, order);

Select images in collection based on particular properties

var selectedIm = imCollection.filterMetadata(propertyName, relation, value);

Relations could be "equals", "less_than", "greater_than", "starts_with", "ends_with", and "contains"

Select images within date range

var selectedIm = imCollection.filterDate(startDate, stopDate);

Select images within Geometry

var selectedIm = imCollection.filterBounds(geometry);

Perform pixelwise calculations for all images in collection

var sumOfImages = imCollection.sum();

or .product, .max, .min, .mean, .mode, .median, and .count

Create composite of images in collection with the last image on top

var mosaicOfImages = imCollection.mosaic();

Importing and exporting data

Image to table example

Timelapse example

Dubai timelapse

Urban growth in Dubai

Export image, video or table to Google Drive, Asset, or Google Cloud

Export.image.toDrive({
  collection: varImage, description: 'fileName', region: geometry, scale: 1000
});

or image.toCloudStorage, image.toAsset, table.toDrive, table.toCloudStorage, video.toCloudStorage, and video.toDrive


Example Applications

What can you do with Google Earth Engine?


Resources

Geospatial Software Design

Google Earth Engine API documentation

Google Earth Engine Developers forum

Example scripts from Prof. Dana Tomlin's handouts for his course on Geospatial Software Design