Giter Club home page Giter Club logo

ee-dynamic-time-warping's Introduction

Multi-Dimensional Dynamic Time Warping Implementation in Google Earth Engine

Euclidean vs DTW comparison

Introduction

A multi-dimensional Dynamic Time Warping (DTW) implementation to classify remote sensing image time series dwelling in Google Earth Engine.

Only the JS API has been developed. The Python API implementation will be coming shortly.

Features

Dynamic Time Warping is an alternative to the somewhat rigid Euclidean Distance for comparing time series alignment.

The recent literature on applying DTW to satellite images time series (SITS) has been integrated in the implementation, namely, the following:

The time-weighted DTW (TWDTW) approach taken from: Maus, V., Câmara, G., Cartaxo, R., Sanchez, A., Ramos, F. M., & De Queiroz, G. R. (2016). A time-weighted dynamic time warping method for land-use and land-cover mapping. IEEE Journal of Selected Topics in Applied Earth Observations and Remote Sensing, 9(8), 3729-3739.

The time-constrained DTW (TCDTW) approach taken from: Csillik, O., Belgiu, M., Asner, G. P., & Kelly, M. (2019). Object-based time-constrained dynamic time warping classification of crops using Sentinel-2. Remote sensing, 11(10), 1257.

The vector distance (VDTW) approach taken from: Teke, Mustafa, and Yasemin Y. Çetin. "Multi-year vector dynamic time warping-based crop mapping." Journal of Applied Remote Sensing 15.1 (2021): 016517.

Usage

The details about parameter setting and their associated methods is described in the main script dtw.js.

To use the code, either copy-paste it to your code editor environment, or simply refer to the publicly-available script with the following line:

var DTW = require('users/soilwatch/functions:dtw.js');

Examples

  1. Multi-year land cover mapping using TWDTW to identify abandoned cropland suitable for rangeland restoration

The script implementing this use case located under the examples folder, and can be accessed via this link.

The story behind this use case is further described in the following medium blog post.

Sudan Sennar DTW example

  1. TBC

Dependencies

The JavaScript code for DTW (dtw.js) runs in the GEE code editor with out installing additional packages.

The example provided (examples/twdtw_sudan.js) relies on the following external dependencies:

Credits

  • SoilWatch and team with boots on the ground for providing valuable contextual information and photos.
  • My consultancy work at FAO for TCP/AFG/3706 and Lorenzo de Simone have contributed a great deal in shaping this implementation of DTW in GEE, where it is applied in the context of crop type mapping.

ee-dynamic-time-warping's People

Contributors

magosilvain avatar wouellette avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

ee-dynamic-time-warping's Issues

Error: Execution failed; out of memory. (Error code: 8)

Dear William,

I hope this message finds you well.

I executed the code on my study area, which generates classification outputs for six months with one image per month. However, when I reduce the time step and the number of images used for classification exceeds ten, a memory error occurs. Could you please provide insight into the potential cause of this issue? Is it possibly due to the extensive computational requirements of the algorithm?
I also reduced the dimensions of the study area to 6 x 6 km

Thank you for your assistance.

Best regards,

Memory Limits exceeded

Hey,

I'm trying to implement this library for dtw and am encountering memory issues within GEE.
Are there any hard limits in terms of the amount of images in the time-series, or number of sample points, number of labels, or overall region size that you are aware of?

Just as a test I'm trying to export dtw_class and the task does run for a long while

Everything before this step is fine, however the output from this function can't be printed or exported.
`var dtw_min_dist = function(key, val){
key = ee.Number.parse(key);
// Function to format the signatures to a DTW-ready EE array
var training_data_list = DTW.prepareSignatures(reference_signatures,
CLASS_NAME,
key,
BAND_NO,
PATTERNS_LEN,
band_names);

// Compute the class-wise DTW distance
return ee.ImageCollection(DTW.DTWDist(training_data_list,
s2_input_asset.select("d_0_NDVI"),
{patterns_no: val,
band_no: BAND_NO,
timeseries_len: TIMESERIES_LEN,
patterns_len: PATTERNS_LEN,
constraint_type: 'time-weighted',
distance_type: 'angular',
beta: BETA,
alpha: ALPHA
})
).min()
.rename('dtw')
// Add class band corresponding to the land cover/crop class computed.
// This is useful/necessary to generate the hard classification map from the dissimilarity values
.addBands(ee.Image(key).toByte().rename('band'));
};`

For the variables:
// Input data parameters var CLASS_NAME = 'labelno'; var AGG_INTERVAL = 5; var TIMESERIES_LEN = 37; var PATTERNS_LEN = 37; var CLASS_NO = 6; var S2_BAND_LIST = ["d_0_NDVI"]; var BAND_NO = S2_BAND_LIST.length; var DOY_BAND = 'doy';
Where the number of number of signatures is 331
AOI size is ~3700 km2

Layer error: Array.reshape: Shape incompatible with array's existing dimensions.

Dear William Ouellette,

I am trying to adapt the code for my dataset and I am getting the following error:

DTW classification: Layer error: Array.reshape: Shape incompatible with array's existing dimensions: [-1, 8, 6] vs. [268, 40].

DTW dissimilarity score: Layer error: Array.reshape: Shape incompatible with array's existing dimensions: [-1, 8, 6] vs. [268, 40].

I am a beginner in google earth engine, could you help me find where I am going wrong?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.