Coder Social home page Coder Social logo

emapr / lt-gee Goto Github PK

View Code? Open in Web Editor NEW
192.0 24.0 65.0 88.09 MB

Google Earth Engine implementation of the LandTrendr spectral-temporal segmentation algorithm. For documentation see:

Home Page: https://emapr.github.io/LT-GEE

License: Apache License 2.0

CSS 0.06% R 0.64% Jupyter Notebook 14.08% Python 9.73% JavaScript 75.50%
landtrendr google-earth-engine time-series-analysis landsat change-detection landscape-dynamics mapping

lt-gee's Introduction

banner image

LT-GEE

Google Earth Engine implementation of the LandTrendr spectral-temporal segmentation algorithm

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.



banner image

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.

lt-gee's People

Contributors

clarype avatar jdbcode avatar ramblingrek 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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

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

lt-gee's Issues

Issue: 'FUNCTION TO REDUCE COLLECTION TO SINGLE IMAGE PER YEAR BY MEDOID'

Thank you so much for developing the amazing tool in GEE. I found that medoid method was applied to create yearly landsat composite (article link). I found the relevant codes in GEE for this operation (medoid method):

// make a medoid composite with equal weight among indices
var medoidMosaic = function(inCollection, dummyCollection) {
  
  // fill in missing years with the dummy collection
  // ** braaten edit 2023-05-02: toList and If are resource intensive, simply
  // ** merging the inCollection and dummyCollection should achieve the goal
  // ** of have at least one image for the median operation.
  var imageCount = inCollection.toList(1).length();                                                            // get the number of images 
  var finalCollection = ee.ImageCollection(ee.Algorithms.If(imageCount.gt(0), inCollection, dummyCollection)); // if the number of images in this year is 0, then use the dummy collection, otherwise use the SR collection
  // var finalCollection = inCollection.merge(dummyCollection);
  
  // calculate median across images in collection per band
  var median = finalCollection.median();                                                                       // calculate the median of the annual image collection - returns a single 6 band image - the collection median per band
  
  // calculate the different between the median and the observation per image per band
  var difFromMedian = finalCollection.map(function(img) {
    var diff = ee.Image(img).subtract(median).pow(ee.Image.constant(2));                                       // get the difference between each image/band and the corresponding band median and take to power of 2 to make negatives positive and make greater differences weight more
    return diff.reduce('sum').addBands(img);                                                                   // per image in collection, sum the powered difference across the bands - set this as the first band add the SR bands to it - now a 7 band image collection
  });
  
  // get the medoid by selecting the image pixel with the smallest difference between median and observation per band 
  return ee.ImageCollection(difFromMedian).reduce(ee.Reducer.min(7)).select([1,2,3,4,5,6], ['B1','B2','B3','B4','B5','B7']); // find the powered difference that is the least - what image object is the closest to the median of teh collection - and then subset the SR bands and name them - leave behind the powered difference band
};

Here, .reduce(ee.Reducer.min(7) gave me output with the lowest value of the pixels rather than the closest value to the median. I am not so sure through, this may lead to the inappropriate result. Could you please confirm that the tool actually used medoid method to prepare yearly single image? I will be very grateful for that.
I might be wrong. If so, please accept my apologies and let me know why it is alright. Thank you so much! I will be looking forward to your kind response.

Band 4 returning negative spectral response

I'm using Landtrendr to get the spectral response per pixel per year to map historical forest fires. Before I do any of this I want to validate it for an area I know was burned in May 2017. In doing so I noticed that the raw spectral response from band 4 for my area of interest (bounds3 in the script) was returning negative values for all pixels for all years I was investigating. I have no idea why. I don't think it is an image issue as it is present in all pixels for all years.

This is my first github issue so please let me know if I left any info out.
Thanks.

GEE code

buildSRcollection does not work for southern hemisphere

In update 14.11 on 2018-06-13, you wrote that you improved the buildSRcollection function to account for the medoid image of the growing season of the southern hemisphere. The theory was that as long as you take the startDay later in the year than the endDay, you would result in a medoid image collection consisting of acquisition dates somewhere in January for example.

I ran the following code snippet that was published along with the update, but it did not result in acquisition dates in the southern summer.

// load the LandTrendr.js module
var ltgee = require('users/emaprlab/public:Modules/LandTrendr.js');

// define parameters
var startYear = 1985;
var endYear = 2017;
var startDay = '12-20';
var endDay = '02-20';
var aoi = ee.Geometry.Point(-122.8848, 43.7929);

// center and zoom the display in case outputs are to be mapped 
Map.centerObject(aoi,10);
Map.addLayer(aoi);

// apply LandTrendr.js functions
var annualSRcollection = ltgee.buildSRcollection(startYear, endYear, startDay, endDay, aoi);

// add property 'acquisition_date' to each image with the date converted to UNIX style. 
var annualSRcollection = annualSRcollection.map(function(im){
  var newdate = ee.Date(im.get('system:time_start')).format("yyyy-MM-dd");
  return im.set({'acquisition_date': newdate});
});
print(annualSRcollection);

But the code returns an image collection where all images are taken around August 31st
image

Why does it do that?

Could it have anything to do with the hardcoded date of August 1st in lines 217 and 205?

line 205:
.set('system:time_start', (new Date(year,8,1)).valueOf()); // add the year to each medoid image - the data is hard-coded Aug 1st

line 217:
imgs = imgs.concat(tmp.set('system:time_start', (new Date(i,8,1)).valueOf())); // concatenate the annual image medoid to the collection (img) and set the date of the image - hard coded to the year that is being worked on for Aug 1st

Change map mask value for YOD is not consistent with other bands

PR #13 moves the operation to add 1 to the the segment start year to calculate year of change detection (YOD). A consequence is that the mask value -9999 is now -9998, which is different than the other change map bands. Need to make all band mask values consistent. I don't think the issue is breaking anything in the module.

getSegmentData - startYear.add(1)

Hello! Me again, but I am really using your module and indeed thanks for creating such an interesting implementation and useful APIs.

Still in the getSegmentData function, I noticed that you increment of 1 every start year:

return ee.Image.cat([startYear.add(1), endYear, startVal, endVal, mag, dur, rate, dsnr])

So you basically assign every vertex to the segment at the left of the vertex. May I ask why did you make this choice? Is it in order not to have the endYear of a segment coincide with the startYear of the subsequent segment? Also the duration it is still returned as endYear - startYear so I found it a bit hard to wrap my head around it at first. Also, this leads to some segments of duration of 1 year having the same year as startYear and endYear, here an example:

image

So I wanted to ask you whether is there a computational reason behind this choice?

Thank you!

Exporting shows nothing

Hi, I have tested this code, but I got nothing;
as it showed NoneType data error!
ltVertStack = getLTvertStack(lt.select(["LandTrendr"])).toShort()

drive = ee.batch.Export.image.toDrive(
image = ltVertStack,
description = "ltVertStack_test_to_drive",
folder = 'lt_gee_py_test',
fileNamePrefix = 'ltVertStack_test',
region = [[-123.98757934570312,47.49679221520181],[-123.90655517578125,47.49586436835716],[-123.90449523925781,47.55243302404593],[-123.98551940917969,47.553359870859]],
scale = 30
)
drive.start()

Validation and pixel area calculation error

  1. Whenever I try to validate the LandTrendr map with reference from google earth image, I see the map is 2,3 pixels off from the actual change detected. It's happening almost 7/10 in both loss and gain map.

  2. Another problem is, I used,

//For MAG area calculation
var magChange = changeImg.select(['mag']).gte(200).and(changeImg.select(['mag']).lt(800));
var areaPalette = magChange.multiply(areaImage);
var areaPaletteSqM = areaPalette.reduceRegion({
reducer: ee.Reducer.sum(),
geometry: aoi,
scale: 30,
maxPixels: 1e13
}).getNumber('mag');

//For YOD area calculations,
var magChange = changeImg.select(['yod']).gte(1990).and(changeImg.select(['yod']).lt(2020));
var areaPalette = magChange.multiply(areaImage);
var areaPaletteSqM = areaPalette.reduceRegion({
reducer: ee.Reducer.sum(),
geometry: aoi,
scale: 30,
maxPixels: 1e13
}).getNumber('yod');

I used these codes for calculating pixel area in sq.km for both Magnitude and Year of Detection map and found errors.
In 'Loss' map, almost 20% og rmse loss of YOD against MAG map (in pixel area of sq.km)
But in 'gain' map, almost less than 1% rmse loss of YOD against MAG map.

.unmask on masked values adds incorrect sized array in getSegmentData

Running across this issue with Landtrendr masked values when calling getSegmentData. When concatenating all the segment information, unmask is called with an ee.Array of 8 rows by 1 column. Because the segment information is not yet an array image, this 8x1 array is inserted for masked values per band, and when converted to an array image row-wise, previously masked pixels have a 64x1 array of -9999s.

I think the fix is simply to just unmasked with a single 1x1 array image, e.g.

return ee.Image.cat([startYear.add(1), endYear, startVal, endVal, mag, dur, rate, dsnr])
  .unmask(ee.Image(ee.Array([[-9999]])))
  .toArray(0);

This works for me.

Logic for filtering change map by year is wrong

In the getChangeMap function, the LandTrendr results image array is first subset to the segment that is either hi/lo limit case for start year, magnitude, or duration. Later, the selected segments are filtered by year, duration, etc.

Problem: in this flow the selected segment might be e.g. outside of the year range filter when someone wants to know what is the greatest disturbance between 2010 and 2020. There could have been a disturbance that occurred in that year range, but if it is not the greatest in the time series, no results will be returned.

Proposed solution: apply all of the filters to the segments array first and do the segment selection by first/last, least/greatest, fastest/slowest last.

Breaking changes: I don't think this will break anything. Results before and after the change could be different. Would argue that the results from the proposed change is what people are expecting but not getting right now and are unaware.

NDVI vegetation loss and interpretation of wildfires

Need to know some basic things about NDVI calculation in Landtrendr.
How do I interpret the graphs obtained from the NDVI vegetation loss calculation? The magnitude value is given as greater than 200, and the years are 2005–2015. Also, in Landtrendr, what does the magnitude refer to? @jdbcode

Looking for answers. Thank you in advance.

mag

Error when running UI Time Series Animator

Hey there,

Thanks very much for the useful tool and maintaining it! I'm new to this and trying to use the UI Time Series Animator to make a GIF. After running the code and defining the region of interest, I get the following error:

Line 205: List.map, argument 'list': Invalid type.
Expected type: List.
Actual type: Float.
Actual value: -110.438

And line 205 is:
var scaleString = ee.String('Width (km): ').cat(ee.Geometry.LineString([[geomLims.xmin, geomLims.ymin],[geomLims.xmax, geomLims.ymin]]).length().divide(1000).multiply(100).round().divide(100)).getInfo();

This seems to be associated with the geomLims objects. When I try to print those above line 205 I get:

Number (Error)
List.map, argument 'list': Invalid type.
Expected type: List.
Actual type: Float.
Actual value: -110.438

I get these errors both when running the "UI LandTrendr Time Series Animator" and "UI LandTrendr Time Series Animator (dev)". The API(?) version works though ("UI LandTrendr Fitted Imagery Time Series Viewer"), and I was able to export a .tif file w/ annual images for my area of interest.

segCount for 'all' 'loss' and 'gain' disturbance

I have used the LT-GEE for a while and found it's a very useful and powerful tool. Recently, I have been troubled by a problem, I ran LT-GEE API in order to get change map and segment count, including 'all', 'loss' and 'gain'. Finally three segCount maps have been obtained. From my perspective, the value for a pixel in three segCount maps should be '' 'all' = 'loss' + 'gain' ''. However, the pixels values which equal to 1 in 'all' map are also 1 in both 'loss' and 'gain' maps. I carefully checked my code but didn't find any mistakes. So I decided to write to ask for help. Any suggestions will be appreciated.

Scale of data display on the LT change mapper

The features on both the change mapper and the time series pages are amazing, and have been useful to a resource manager who is interested in tracking change over the last 30 years. He's asked me what the scale is for these datasets. On the time series page, the pixel size appears to be 30 meters, but on the change mapper site, the Year of Detection layer appears to have better than 1 foot precision (actually all 3 layers have this effect). I think this is some kind of artifact but don't know what's going on. Could that explanation be added to the click here for information link that is already on the right hand side?
ExampleOfUltraHighResolution

ROY coefficients

Hello - thanks for an amazing set of tools and documentation! This has all been so helpful.

I noticed the warning about the use of collection 2, and the decision to not use the ROY coefficients for scaling. Looking a bit deeper I noticed the following note:

//NOTE based on analysis of the effects of Roy coefficients for various places around the world

Could you provide any more insight into those use cases around the world? Maybe some studies? Thank you!

Enhanced Vegetation Index in LT?

Hello, I see that EVI is not listed as one of the currently available indices (at the very bottom of this page: https://emapr.github.io/LT-GEE/api.html). When I request EVI in LT, I still get values, though they appear to be much lower than the expected range for forest and possibly missing the initial scaling factor (multiplying bands by 10,000) before the EVI equation.

I would really like to use LandTrendr for EVI time series so any clarification on what values are being produced would be helpful.

year of each disturbance

First of all, congratulation on this very usefull set of tools! I'm interested in obtaining the year of each forest plantation harvest per pixel. So far I have the segmented data (for 'loss' segments) and the number of these segments (getSegmentCount), which may go until 4 in some cases. I was wondering if there is a way of obtaining the years of all these segments as well, by e.g. producing a raster with max(getSegmentCount) number of bands (here 4) where each bands contain a year value of the segment or NaN or 0 in case getSegmentCount < 4.
Any idea of how this could be done? I appriciate all the help.
Cheers,
Javier

GLCM Texture Features as Input of LandTrendr

Thank you for this very useful algorithm!!. I have been using the Time Series Plotter to create time series with different vegetation index. However, I want to explore spatial associations in the land cover and I'm planning to use some texture features from GLCM. Once the annual medoid composition is created, I calculated the texture: Homogeneity for the band 1 of Landsat7 for every annual composition. Nevertheless, every time I try to run the algorithm using this new set the images (homogeneity) I get this error:

"Magnitude: Tile error: Image '0' does not have a 'system:time_start' property"

I share my code for further explanation:
https://code.earthengine.google.com/?scriptPath=users%2Falefoncol%2FScripts%3ALandTrendr%2FLandTrendr-Thesis

Adding EVI to available vegetation indices

Thank you for this very useful algorithm. I have been using the Zonal Time Series Plotter to create NDVI time series, but recent work has shown that EVI may be a more accurate index when it comes to wetland vegetation. EVI (for Landsat 4-7) is calculated as: 2.5 * ((Band 4 – Band 3) / (Band 4 + 6 * Band 3 – 7.5 * Band 1 + 1)). Is this a feature that could be added to LandTrendr.js in order for the index to be available for future LandTrendr scripts?

Move year addition from getSegmentData to getChangeMap

Year of detection is returned from getSegmentData instead of segment start year. getChangeMap WAI, but it should do the addition to calculate year of detection, so that users who want segment information have the correct start year. See #11 for more.

Which version of LandTrendR should we use?

Hello,
First of all I wanted to thank you for the wonderful tools you have developed and for sharing them with us. I have been testing the UI applications for pixel time series, so that I could tune the parameters for running the LandTrendr JavaScript module. However, I am not sure if we can use the functions from the tutorial (https://emapr.github.io/LT-GEE/api.html) with the Landsat collection 2. It seems the LandTrenr API has changed considerably between 2019 and now and I am not sure if we should use the new or the old version, especially if we are not very familiar with GEE yet.
Another question I have is related to my research question. Can we extract every year of disturbance (not just the greatest or newest) from the output of the LandTrenr API? Let´s say, to make a map of cumulative (anthropogenic) disturbance in forest plantations.
Thank you very muchs for your help, and apologies f the questions are too generic.
Mercedes

"Cannot read property 'LandTrendr' of undefined"

Dear Landtrendr team,

great thanks for putting this piece together, I'm sure the combination of Landtrendr and GEE will be a big leap forward in science!

There seems however to be an error, when trying the examples (on different systems with different settings) this error pops up: "Cannot read property 'LandTrendr' of undefined"...

all the best,
Martin

LandTrendr.js not working for NDFI

Hi all,
First, thank you for this implementation; it is beneficial.

I have a question regarding the use of the NDFI index. I am calling the script LandTrendr.js in the GEE code editor as follows:
var ltgee = require('users/attel/Funciones_RS:LTR/LandTrendr_attel.js')

Currently, it is not working; I am unsure if this is intended because something still needs to be figured out.

I have included the 'NDFI': -1 to the indexflipper function , and the script works. However, I am not sure if I see the correct results. They seem correct when I compute the loss, but I am not sure about the gain.

Is there any experience with this?

Thank you very much in advance

image

Missing data from change map API

First of all, thank you for this very useful tool! I am currently trying to do a vegetation cover change analysis in a mining area using LT-GEE. I used the change mapper API to get the year of detection and magnitude of change data from 1999-2019, but when I export the TIFF change image data and analyzed it on QGIS, it seems like it's missing several years of data (for example it didn't detect data from 2001 and 2013). So far I've been trying different parameters for the change parameters for NDVI, but the only difference I got is a different missing year every time I tried a new set of parameters (for example now it's missing 2005 and 2006 instead of 2001 and 2013). I have checked the image collection and I think it already has a complete image from every year. I also have changed the start and end day to one year since the area has no significant seasonal change. May I get any suggestions on what may have caused this and how to solve it? Thank you very much!

This is the code I used

// define collection parameters
var startYear = 1999;
var endYear = 2019;
var startDay = '01-20';
var endDay = '12-20';
var aoi = ee.Geometry(115.61162, -3.38938);
var index = 'NDVI';
var maskThese = ['cloud', 'shadow', 'water'];

// define landtrendr parameters
var runParams = {
maxSegments: 6,
spikeThreshold: 0.9,
vertexCountOvershoot: 3,
preventOneYearRecovery: true,
recoveryThreshold: 0.25,
pvalThreshold: 0.05,
bestModelProportion: 0.75,
minObservationsNeeded: 6
};

// define change parameters
var changeParams = {
delta: 'gain',
sort: 'greatest',
year: {checked:true, start:1999, end:2019},
mag: {checked:true, value:0, operator:'>', dsnr : true},
dur: {checked:true, value:20, operator:'<'},
preval: {checked:true, value:300, operator:'>'},
mmu: {checked:true, value:11},
};

// load the LandTrendr.js module
var ltgee = require('users/emaprlab/public:Modules/LandTrendr.js');

// add index to changeParams object
changeParams.index = index;

// run landtrendr
var lt = ltgee.runLT(startYear, endYear, startDay, endDay, aoi, index, [], runParams, maskThese);

// get the change map layers
var changeImg = ltgee.getChangeMap(lt, changeParams);

var annualSRcollection = ltgee.buildSRcollection(startYear, endYear, startDay, endDay, aoi, maskThese);
print(annualSRcollection);

var nClearCollection = ltgee.buildClearPixelCountCollection(startYear, endYear, startDay, endDay, aoi, maskThese);
print(nClearCollection);

Create indexes

What suggestions and/or precautions should I consider when implementing these index: EVI2, NDWI, SAVI, SR, GDVI1, NDMI, GCVI that have not been implemented?

Migration Landsat Collection 1 to Collection 2

Hello everyone,

I was wondering if there are plans to migrate from the currently used Landsat Collection 1 to Landsat Collection 2.

The currently used image collections will cease to be accessible via GEE mid 2024.

This would break this very valuable tool. Furthermore, a migration would allow detection of disturbances more recent than 2022.

Further information can be found here: https://developers.google.com/earth-engine/landsat_c1_to_c2

The to be depreciated collections are:

Landsat 5: LANDSAT/LT05/C01/T1_SR
Landsat 7: LANDSAT/LE07/C01/T1_SR
Landsat 8: LANDSAT/LC08/C01/T1_SR

Thank you for sharing your thoughts on this.

Best
Lukas

Change mention of DNSR to CNSR in doc pages

DSNR is "disturbance signal to noise ratio" which is described in Cohen et al. (2018), but is applicable to recovery as well and used as a magnitude metric for dist. and rec. in the LT-GEE API, so it should be described in the docs as "change signal to noise ratio" (CSNR).

Errors with Fitted Line for NDVI zonal time series

I've been encountering many instances where the fitted line for my NDVI zonal time series seems completely off.

For example, I am looking at a 40m buffer around a wetland point below, and am using parameters suggested in the literature.
`// my area of interest is a 40m buffer around this point
var aoi = ee.Geometry.Point([-76.2845001, 38.45196685]).buffer(40);

// define parameters
var startYear = 1985;
var endYear = 2019;
var startDay = '06-20';
var endDay = '09-20';
var index = 'NDVI';
var maskThese = ['cloud', 'shadow', 'snow'];
var summaryScale = 1;
var runParams = {
maxSegments: 6,
spikeThreshold: 0.75,
vertexCountOvershoot: 3,
preventOneYearRecovery: true,
recoveryThreshold: 1,
pvalThreshold: 0.1,
bestModelProportion: 0.75,
minObservationsNeeded: 6
};`

The fitted line produced in this instance does not seem to accurately describe the time series trend.
image

In other cases the fitted slope seems correct, but the values fall above or below the original time series values.

image

getSegmentData - Orientation around 0 of spectral values

Hi @jdbcode ,

I am using the getSegmentData(lt, index, delta, right) function with NBR index, and having some troubles in understanding the orientation around zero of the output segments values.

I tried running:
var segInfo = ltgee.getSegmentData(lt, index, 'all')
and got this result for pixel A:
image

Then I tried running:
var segInfo = ltgee.getSegmentData(lt, index, 'all', true)
and got this result for pixel A:
image

For final comparison I tried running:
var segInfo = ltgee.getSegmentData(lt, index, 'loss')
and got this result for pixel A:
image

So what I am wondering is whether the ‘right’ parameter set to ‘true’ is not doing its job here (flipping the values to their natural orientation around zero) or am I not using it correctly?

Thank you!
Best,
Agata

getFittedData() -- returned data can not be saved as an asset

The output from getFittedData() can not be save as an asset in GEE do to its band naming syntax, that leads the band name with a numerical character. The error meassage can be seen below.

Error: Band ID "1999" is invalid. Band IDs must start with a..z or A..Z and must contain only the following characters: a..z, A..Z, 0..9, "_", or "-". Band IDs must be at most 100 characters long.

I am pretty sure the these bands are named like "1999_ftv" or something like that. So the easiest solution I see would be to just flip the name to something like "ftv_1999".

I'll go ahead and look into it.

"Greatest disturbance mapping" user memory limit exceeded

When the changeImg() function defined in "users/emapr/public:Modules/LandTrendr.js" is called and the resulting image is added to a map, it returns a "User memory limit exceeded" error.

I've been having this error in my script for at least a few months but I had thought it was something wrong with my code.

I tried running the "users/emapr/public:Scripts/LandTrendr Examples/LandTrendr Greatest Disturbance Mapping" script and it returned the same error. However, the LandTrendr Change Mapper UI still works.

I can get my script to run correctly if I use the old LandTrendr.js script from https://github.com/eMapR/LT-GEE/blob/master/LandTrendr.js.

question in://------ FUNCTION TO REDUCE COLLECTION TO SINGLE IMAGE PER YEAR BY MEDOID ----

var medoidMosaic = function(inCollection, dummyCollection) {
var imageCount = inCollection.toList(1).length();
---toList(1),Is this one set up wrong?
With the original code, no matter how many images are in the collection, it's only going to return ‘1’.

And your comment after the code says: this is counting the number of images in the collection.
?????

Computed Image is too large when try to extract information from getSegmentData

Hello,

Thank you for providing this powerful tool! It's a wonderful tool that helps me get vegetation cover change. However, I met some problems with "getSegmentData" function.
After I get the segment information by calling getSegmentData, I tried to extract them like max magnitude as training data for my feature collection using sampleRegions. However, it will always return "FetureCollection error: Computed Image is too large".
I've tried to clip my study area but it doesn't work.

Here is my code:
var ltgee = require('users/emaprlab/public:Modules/LandTrendr.js');

// define parameters
var startYear = 2000;
var endYear = 2019;
var startDay = '06-01';
var endDay = '09-30';
var aoi = ee.Geometry.Point(-67.9527,49.2603);

var index = 'NBR';
var ftvList = ['NBR'];
var runParams = {
maxSegments: 6,
spikeThreshold: 0.9,
vertexCountOvershoot: 3,
preventOneYearRecovery: true,
recoveryThreshold: 0.25,
pvalThreshold: 0.05,
bestModelProportion: 0.75,
minObservationsNeeded: 6
};
var maskThese = ['cloud', 'shadow', 'snow'];

// center and zoom the display in case outputs are to be mapped
Map.centerObject(aoi,10);
Map.addLayer(aoi);

// apply LandTrendr.js functions
var lt = ltgee.runLT(startYear, endYear, startDay, endDay, aoi, index, ftvList, runParams);

// get Segmentation data
var segInfo = ltgee.getSegmentData(lt, index, 'all');
var segDelta = segInfo.arraySlice(0, 4, 5).toArray(0);

var sortByThis = segDelta.toArray(0).multiply(-1);
var segInfoSorted = segInfo.arraySort(sortByThis);
var bigDelta = segInfoSorted.arraySlice(1,0,1);
var segMax = bigDelta.arraySlice(0,4,5);

var segMax2 = segMax.arrayProject([0]).arrayFlatten([['segMax']]);

// import traning data
var plots_with_class = ee.FeatureCollection('users/xichun_project/point_select_with_class');
print(plots_with_class);

var bands = ['segMax']
var training = segMax2.select(bands).sampleRegions({
collection: plots_with_class,
properties: ['Class'],
scale: 30
});
print(training);

Thank you in advance :)

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.