Skip to main content

Visualize classified time series data with interactive Sankey plots in Google Earth Engine.

Project description

sankee

Binder conda-forge link conda-forge link Read the Docs license link Downloads

Visualize changes in classified time series data with interactive Sankey plots in Google Earth Engine

Sankee example showing grassland expansion in the Nile Delta

Contents

Description

sankee provides a dead-simple API that combines the power of Google Earth Engine and Plotly to visualize changes in land cover, plant health, burn severity, or any other classified imagery over a time series in a region of interst using interactive Sankey plots. Use a library of built-in datasets like NLCD, MODIS Land Cover, or CGLS for convenience or define your own custom datasets for flexibility. sankee works by randomly sampling points in a time series of classified imagery to visualize how cover types changed over time.

sankee can be found in the Earth Engine Developer Resources!

Installation

Using Pip

pip install sankee

Using Conda

sankee can be downloaded through conda-forge within a Conda environment.

conda install -c conda-forge sankee

Requirements

Quick Start

Using a Premade Dataset

Datasets in sankee are used to apply labels and colors to classified imagery (e.g. a value of 42 in an NLCD 2016 image should be labeled "Evergeen forest" and colored green). sankee includes premade Dataset objects for common classified datasets in GEE like the National Land Cover Dataset (NLCD), MODIS land cover, Copernicus Global Land Service (CGLS), and the Landscape Change Monitoring System (LCMS).

import ee
import sankee

ee.Initialize()

# Choose a premade dataset object that contains band, label, and palette information for NLCD
dataset = sankee.datasets.NLCD2016

# Select images to compare
nlcd2001 = ee.Image("USGS/NLCD/NLCD2001")
nlcd2016 = ee.Image("USGS/NLCD/NLCD2016")

# Build a list of images
img_list = [nlcd2001, nlcd2016]
# Build a matching list of labels for the images (optional)
label_list = ["2001", "2016"]

# Define an area of interest
vegas = ee.Geometry.Polygon(
    [[[-115.01184401606046, 36.24170785506492],
      [-114.98849806879484, 36.29928186470082],
      [-115.25628981684171, 36.35238941394592],
      [-115.34692702387296, 36.310348922031565],
      [-115.37988600824796, 36.160811202271944],
      [-115.30298171137296, 36.03653336474891],
      [-115.25628981684171, 36.05207884201088],
      [-115.26590285395109, 36.226199908103695],
      [-115.19174513910734, 36.25499793268206]]])

# Choose a title to display over your plot (optional)
title = "Las Vegas Urban Sprawl, 2001 - 2016"

# Generate your Sankey plot
plot = sankee.sankify(img_list, vegas, label_list, dataset, max_classes=4, title=title)
plot

A more thorough example using sankee to plot changes in MODIS snow and ice cover can be found in the documentation. MODIS glacier loss example Sankey plot

Using a Custom Dataset

Datasets can also be manually defined for custom images. Custom images could be user-created land cover classifications, burn severity maps, deforestation maps, etc. Anything where pixel values represent specific classifications. See the documentation for an example of using sankee with a custom classified NDVI dataset.

Features

Modular Datasets

Datasets in sankee define how classified image values are labeled and colored when plotting. label and palette arguments for sankee functions can be manually provided as dictionaries where pixel values are keys and labels and colors are values. Every value in the image must have a corresponding color and label. Datasets also define the band name in the image in which classified values are found.

Any classified image can be visualized by manually defining a band, palette, and label. However, premade datasets are included for convenience in the sankee.datasets module. To access a dataset, use its name, such as sankee.datasets.NLCD2016. To get a list of all dataset names, run sankee.datasets.names(). Datasets can also be accessed using sankee.datasets.get() which returns a list of Dataset objects that can be selecting by indexing.

# List all sankee built-in datasets
sankee.datasets.names()

>> ['LCMS_LU',
    'LCMS_LC',
    'NLCD2016',
    'MODIS_LC_TYPE1',
    'MODIS_LC_TYPE2',
    'MODIS_LC_TYPE3',
    'CGLS_LC100']

# Preview a list of available images belonging to one dataset
sankee.datasets.CGLS_LC100.get_images(3)

>> ['COPERNICUS/Landcover/100m/Proba-V-C3/Global/2015',
    'COPERNICUS/Landcover/100m/Proba-V-C3/Global/2016',
    'COPERNICUS/Landcover/100m/Proba-V-C3/Global/2017',
    '...']

Flexible Time Series

sankee can handle any length of time series. The number of images will determine the number of time steps in the series. The example below shows a three-image time series.

MODIS glacier loss example Sankey plot

Integration with geemap

geemap is a great tool for exploring changes in GEE imagery before creating plots with sankee. Integration is quick and easy. Just use geemap like you normally would, and pass the images and feature geometries to sankee for plotting. Click here for an interactive notebook that demonstrates using sankee with geemap.

The sankee package is also integrated directly into geemap, giving users a code-free interface to sankee's premade datasets (thanks Qiusheng Wu!). Documentation and video tutorials are available from geemap. Support for custom datasets is coming soon to geemap!

Editable Plots

The plot returned by sankee.sankify is a plotly.graph_objs._figure.Figure which can be easily edited after creation like any other Plotly Graph Object. The plot.update_layout function has many options which can be used to change things like plot size or label styles. For example, we can update plot size and title color of an existing plot using the code below.

plot = sankee.sankify( ... )
plot.update_layout(height=1000, width=2400, title_font_color="red")

Contributing

If you find bugs or have feature requests, please open an issue!


Top

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sankee-0.0.6.tar.gz (30.0 kB view details)

Uploaded Source

File details

Details for the file sankee-0.0.6.tar.gz.

File metadata

  • Download URL: sankee-0.0.6.tar.gz
  • Upload date:
  • Size: 30.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/0.0.0 importlib_metadata/4.8.1 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.7

File hashes

Hashes for sankee-0.0.6.tar.gz
Algorithm Hash digest
SHA256 ce04442f1ec1aa1f0cca2dab794ca0fbfecece44af681b902a94d96c84993869
MD5 b3ed41330a4490b736dd58b7e2c2bcd8
BLAKE2b-256 f788b731f5e86723d611c8039a364976778efd0674415da15cd919e96f8f3625

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page