eMapR / lt-gee-py

Python interface to the Google Earth Engine implementation of the LandTrendr spectral-temporal segmentation algorithm.
Apache License 2.0
6 stars 1 forks source link

lt-gee-py

Python interface to the Google Earth Engine implementation of the LandTrendr spectral-temporal segmentation algorithm.

Introduction

LandTrendr is set of spectral-temporal segmentation algorithms that are useful for change detection in a time series of moderate resolution satellite imagery (primarily Landsat) and for generating trajectory-based spectral time series data largely absent of inter-annual signal noise. LT was originally implemented in IDL (Interactive Data Language), but with the help of engineers at Google, it has been ported to the GEE platform.

The LandTrendr class from lt-gee-py is a light wrapper around the Google Earth Engine API that includes convenience methods to generate images and collections in the format required for LandTrendr on GEE. Please be aware this package is in alpha and may change.

Getting Started

Download and Install packages and dependencies

conda install -c conda-forge earthengine-api
pip install lt-gee-py

Authenticate on Google Earth Engine

earthengine authenticate # There are several alternatives for this. See link above.

Basic Usage

import ee
from ltgee import LandTrendr, LandsatComposite, LtCollection

# Initialize access to Google's EE servers
ee.Initialize("my_project_name")

# Initialize variables for LandTrendr algorithm
composite_params = {
    "start_date": date(1985, 6,1),
    "end_date": date(2017, 9,1),
    "area_of_interest": ee.Geometry({
        'type': 'Polygon',
        'coordinates': [
            [
                [-122.37202331327023,44.62585686599272],
                [-122.26765319608273,44.62585686599272],
                [-122.26765319608273,44.696185837887384],
                [-122.37202331327023,44.696185837887384],
                [-122.37202331327023,44.62585686599272],
                ]
            ]
    }),
    "mask_labels": ['cloud', 'shadow', 'snow', 'water'],
    "debug": True
}
lt_collection_params = {
        "sr_collection": LandsatComposite(**composite_params),
        # "sr_collection": composite_params, # - you may also just pass in your own collection or the params directly. Note: in the former, some methods in the class may not work.
        "index": 'NBR',
        "ftv_list": ['TCB', 'TCG', 'TCW', 'NBR'],
}
lt_params = {
    "lt_collection": LtCollection(**lt_collection_params),
    # "lt_collection": lt_collection_params, # - you may also just pass in your own collection or the params directly. Note: in the former, some methods in the class may not work.
    "run_params": {
            "maxSegments": 6,
            "spikeThreshold": 0.9,
            "vertexCountOvershoot":  3,
            "preventOneYearRecovery":  True,
            "recoveryThreshold":  0.25,
            "pvalThreshold":  .05,
            "bestModelProportion":  0.75,
            "minObservationsNeeded": 6,
        }
}

# Instantiating LandTrendr object. Note: The object will immediately request to run the algorithm on Google's servers.
lt = LandTrendr(**lt_params)

# Access resulting image using the data attribute.
lt_data = lt.data

Features / Methods

Manuscript

Citation

Kennedy, R.E., Yang, Z., Gorelick, N., Braaten, J., Cavalcante, L., Cohen, W.B., Healey, S. (2018). Implementation of the LandTrendr Algorithm on Google Earth Engine. Remote Sensing. 10, 691.

Except as otherwise noted, the content of this repository and accompanying description site (https://emapr.github.io/LT-GEE/) are licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License.