Using Geemap for Geospatial Data Analysis and Visualization
åŗäŗgeemapēę°ę®åęäøåÆč§å - 仄čŖåØęåę²³ęµäøåæēŗæå宽度为ę”ä¾
This notebook was developed for the 第äŗå±āå Øå½å°ē空é“大ę°ę®äøäŗč®”ē®āē 讨ä¼.
Authors: Qiusheng Wu
Link to this notebook: https://gishub.org/gee_workshop_2021
Introduction
Description
Google Earth Engine (GEE) is a cloud computing platform with a multi-petabyte catalog of satellite imagery and geospatial datasets. It enables scientists, researchers, and developers to analyze and visualize changes on the Earthās surface. The geemap Python package provides GEE users with an intuitive interface to manipulate, analyze, and visualize geospatial big data interactively in a Jupyter-based environment. The topics will be covered in this workshop include:
Introducing geemap and the Earth Engine Python API
Creating interactive maps
Searching GEE data catalog
Displaying GEE datasets
Classifying images using machine learning algorithms
Computing statistics and exporting results
Producing publication-quality maps
Extracting river width and centerline
This workshop is intended for scientific programmers, data scientists, geospatial analysts, and concerned citizens of Earth. The attendees are expected to have a basic understanding of Python and the Jupyter ecosystem. Familiarity with Earth science and geospatial datasets is useful but not required.
äøęē®ä»
Geemap Python软件å äøŗGEEēØę·ęä¾äŗäøäøŖē“č§ēēé¢ļ¼åÆä»„åØåŗäŗJupyterēēÆå¢äøä»„äŗ¤äŗę¹å¼ęä½ćåęååÆč§åå°ē空é“大ę°ę®ćę¬ę¬”ē 讨ä¼å°ę¶åēäø»é¢å ę¬ļ¼
ä»ē»GeemapåEarth Engine Python API
å建交äŗå¼å°å¾
ęē“¢GEEę°ę®ē®å½
对ę¶é“åŗåę°ę®čæč”åÆč§å
使ēØęŗåØå¦ä¹ ē®ę³åƹ影åčæč”åē±»
č®”ē®ē»č®”åč¾åŗē»ę
å¶ä½é«č“Øéēå°å¾
čŖåØęåę²³ęµäøåæēŗæå宽度ē
Useful links
Google Earth Engine and geemap Python Tutorials (55 videos with a total length of 15 hours)
Spatial Data Management with Google Earth Engine (19 videos with a total length of 9 hours)
Prerequisite
Set up a conda environment
geemap basics
Import libraries
Set you Internet proxy if needed. 设置ē½ē»ä»£ēć

Create an interactive map
Customize the default map
You can specify the center(lat, lon) and zoom for the default map. The lite mode will only show the zoom in/out tool.
Add basemaps
Change basemaps without coding

Add WMS and XYZ tile layers
Examples: https://viewer.nationalmap.gov/services/
Use drawing tools
Convert GEE JavaScript to Python
https://developers.google.com/earth-engine/guides/image_visualization
You can also convert GEE JavaScript to Python without coding.

Earth Engine datasets
Load Earth Engine datasets
Search the Earth Engine Data Catalog
Use the datasets module
Use the Inspector tool

Data visualization
Use the Plotting tool

Change layer opacity
Visualize raster data
Visualize vector data
Add a legend
Add a colorbar
Create a split-panel map
Create linked maps
Create timelapse animations
Create time-series composites
Data analysis
Descriptive statistics
Zonal statistics
Zonal statistics by group
Unsupervised classification
Source: https://developers.google.com/earth-engine/guides/clustering
The ee.Clusterer package handles unsupervised classification (or clustering) in Earth Engine. These algorithms are currently based on the algorithms with the same name in Weka. More details about each Clusterer are available in the reference docs in the Code Editor.
Clusterers are used in the same manner as classifiers in Earth Engine. The general workflow for clustering is:
Assemble features with numeric properties in which to find clusters.
Instantiate a clusterer. Set its parameters if necessary.
Train the clusterer using the training data.
Apply the clusterer to an image or feature collection.
Label the clusters.
The training data is a FeatureCollection with properties that will be input to the clusterer. Unlike classifiers, there is no input class value for an Clusterer. Like classifiers, the data for the train and apply steps are expected to have the same number of values. When a trained clusterer is applied to an image or table, it assigns an integer cluster ID to each pixel or feature.
Here is a simple example of building and using an ee.Clusterer:

Add data to the map
Make training dataset
There are several ways you can create a region for generating the training dataset.
Draw a shape (e.g., rectangle) on the map and the use
region = Map.user_roiDefine a geometry, such as
region = ee.Geometry.Rectangle([-122.6003, 37.4831, -121.8036, 37.8288])Create a buffer zone around a point, such as
region = ee.Geometry.Point([-122.4439, 37.7538]).buffer(10000)If you don't define a region, it will use the image footprint by default
Train the clusterer
Classify the image
Label the clusters
Visualize the result
Export the result
Supervised classification
Source: https://developers.google.com/earth-engine/guides/classification
The Classifier package handles supervised classification by traditional ML algorithms running in Earth Engine. These classifiers include CART, RandomForest, NaiveBayes and SVM. The general workflow for classification is:
Collect training data. Assemble features which have a property that stores the known class label and properties storing numeric values for the predictors.
Instantiate a classifier. Set its parameters if necessary.
Train the classifier using the training data.
Classify an image or feature collection.
Estimate classification error with independent validation data.
The training data is a FeatureCollection with a property storing the class label and properties storing predictor variables. Class labels should be consecutive, integers starting from 0. If necessary, use remap() to convert class values to consecutive integers. The predictors should be numeric.

Add data to the map
Make training dataset
There are several ways you can create a region for generating the training dataset.
Draw a shape (e.g., rectangle) on the map and the use
region = Map.user_roiDefine a geometry, such as
region = ee.Geometry.Rectangle([-122.6003, 37.4831, -121.8036, 37.8288])Create a buffer zone around a point, such as
region = ee.Geometry.Point([-122.4439, 37.7538]).buffer(10000)If you don't define a region, it will use the image footprint by default
In this example, we are going to use the USGS National Land Cover Database (NLCD) to create label dataset for training

Train the classifier
Classify the image
Render categorical map
To render a categorical map, we can set two image properties: landcover_class_values and landcover_class_palette. We can use the same style as the NLCD so that it is easy to compare the two maps.
Visualize the result
Export the result
Training sample creation

WhiteboxTools

Map making
Plot a single band image
Plot an RGB image
Add map elements
Plot multiple layers
Use custom projections
Data export
Export ee.Image
Exporting all bands as one single image
Exporting each band as one image
Export an image to Google Drive¶
Export ee.ImageCollection
Extract pixels as a numpy array
Export pixel values to points
Download sample data
Export pixel values as a shapefile
Export pixel values as a csv
Export ee.FeatureCollection
Extracting river width and centerline
Create an interactive map.
Find an image by ROI.
Add image to the map.
Extract river width for a single image.
Add result to the map.
Add Global River Width Dataset to the map.
Find images by ROI.
Get the list of image ids.
Extract river width for a list of images.