diff --git a/README.md b/README.md index 7b9d5ad..d28188c 100644 --- a/README.md +++ b/README.md @@ -14,21 +14,16 @@ Murray et al. (in submission) Losses and gains of Earth's tidal wetlands. #### Usage The code developed to map tidal wetlands globally in Earth Engine is designed to be deployed separately in Earth Engine in following order: -* Develop covariate layers from Landsat Archive Imagery `javascript/covariate_reduce.js` -* Sample covariate layers using a training library annotated by ecosystem type `javascript/covariate_sample.js` -* Train a Random Forest model for predicting the distribution of tidal wetlands (Stage 1) `javascript/tidal_wetland_extent.js` -* Tidal wetland extent post-processing `javascript/extent_post_processor_mmu.js` -* Identify change flag areas between t1 and t7 `javascript/change_flag.js` and process `javascript/change_post_processor.js` -* Classify the change flat into loss, gain or stable (Stage 2) `javascript/tidal_wetland_change_classifier.js` -* Identify the type of ecosystem lost or gained over the study period (Stage 3) `javascript/tidal_wetland_type.js` - -The result is an image with six bands: -* "loss" -* "lossYear" -* "lossType" -* "gain" -* "gainYear" -* "gainType" +1. Develop covariate layers from Landsat Archive Imagery `javascript/covariate_reduce.js` +2. Sample covariate layers using a training library annotated by ecosystem type `javascript/covariate_sample.js` +3. Train a Random Forest model for predicting the distribution of tidal wetlands (Stage 1) `javascript/tidal_wetland_extent.js` +4. Tidal wetland extent post-processing `javascript/extent_post_processor_mmu.js` +5. Identify change flag areas between t1 and t7 `javascript/change_flag.js` +6. Post process change `javascript/change_post_processor.js` +7. Classify the change flat into loss, gain or stable (Stage 2) `javascript/tidal_wetland_change_classifier.js` +8. Identify the type of ecosystem lost or gained over the study period (Stage 3) `javascript/tidal_wetland_type.js` + +The result is an image with six bands: loss, lossYear, lossType, gain, gainYear, gainType. ![img](figures/wetland_change.jpg) diff --git a/javascript/change_flag.js b/javascript/change_flag.js index 2a85b64..747771c 100644 --- a/javascript/change_flag.js +++ b/javascript/change_flag.js @@ -39,7 +39,7 @@ var makeLossGain = function(y1, y2, year){ var loss = y1.select([1]) .updateMask(y2.select([1]).unmask().lt(1)) .updateMask(gic2001.select([1])) // can only be lost if occurred in 2001 - .updateMask(gic2019.select([1]).unmask().lt(1)) // can only be lost if no occurrence in 2019 + .updateMask(gic2019.select([1]).unmask().lt(1)) // can only be lost if no occurrences in 2019 .rename(['loss']); var lossYear = loss.remap([1],[year]) .rename(['lossYear']).int() diff --git a/javascript/covariate_reduce.js b/javascript/covariate_reduce.js index 704a384..8942f75 100644 --- a/javascript/covariate_reduce.js +++ b/javascript/covariate_reduce.js @@ -4,7 +4,7 @@ var simpleCoastLine = ee.FeatureCollection('projects/UQ_intertidal/dataMasks/simpleNaturalEarthCoastline_v1').first().geometry(); var site = ee.Geometry.Polygon([-180, 60, 0, 60, 180, 60, 180, -60, 10, -60, -180, -60], null, false); -var dataMask = ee.Image('projects/UQ_intertidal/dataMasks/topyBathyEcoMask_300m_v2_0_3'); +var dataMask = ee.Image('projects/UQ_intertidal/dataMasks/topyBathyEcoMask_300m_v2_0_3'); // sets mapping area var startDate = '2017-01-01'; var endDate = '2019-12-31'; var bandSelect = ['green', 'swir1', 'swir2', 'nir', 'red', 'blue']; @@ -133,8 +133,7 @@ var covariates = { var covariateName = 'evi'; // export separately ([awe, ndw, mnd, ndv, evi, nir_1090, gre_1090, swi_1090])) -var assetName = 'projects/UQ_intertidal/covariate_layers/L3_' - .concat(covariateName) +var assetName = 'foo' // set file path .concat('_') .concat(startDate.slice(0,4)) .concat(endDate.slice(0,4)) diff --git a/javascript/covariate_sample.js b/javascript/covariate_sample.js index 56f27d9..2b5b9a3 100644 --- a/javascript/covariate_sample.js +++ b/javascript/covariate_sample.js @@ -3,9 +3,9 @@ */ var trainingSet = ee.FeatureCollection('foo'); // path to training set -var startDate = '2014-01-01'; // Reference period -var endDate = '2016-12-31'; // Reference period -var covariatePath = 'foo', // Covariates path +var startDate = '2014-01-01'; // reference period for sampling +var endDate = '2016-12-31'; // reference period for sampling +var covariatePath = 'foo', // path to covariates var yearString = startDate.slice(0,4) .concat(endDate.slice(0,4)); @@ -47,7 +47,7 @@ var predictorSet = trainingSet.map(sampleCovariates); // export -var assetName = 'foo'; // path and asset name +var assetName = 'foo'; // path and asset name of predictorSet var vars = { startDate:startDate, diff --git a/javascript/tidal_wetland_change_classifier.js b/javascript/tidal_wetland_change_classifier.js index d90aa8a..a6f44c0 100644 --- a/javascript/tidal_wetland_change_classifier.js +++ b/javascript/tidal_wetland_change_classifier.js @@ -2,7 +2,7 @@ * Classify change flags as loss, gain or stable. */ -var changeFlagImage = ee.Image('foo'); // path to change flag image +var changeFlagImage = ee.Image('foo'); // path to changeFlag_pp2 var site = ee.Geometry.Polygon([-180, 60, 0, 60, 180, 60, 180, -60, 10, -60, -180, -60], null, false); var gic2001 = ee.Image('foo'), // import post-processed tw_export (pp) gic2004 = ee.Image('foo'), @@ -11,11 +11,19 @@ var gic2001 = ee.Image('foo'), // import post-processed tw_export (pp) gic2013 = ee.Image('foo'), gic2016 = ee.Image('foo'), gic2019 = ee.Image('foo'); -var covariatePath = 'foo', // Covariates path +var covariatePath = 'foo', // path to covariates folder +var trainingSet = 'foo' // path to loss/gain/stable training data -// Single image from change Flag -var changeFlag = changeFlagImage.select(['loss']).unmask().add(changeFlagImage.select(['gain']).unmask()).gte(1).selfMask(); +// Single image from change Flag +var changeFlag = changeFlagImage + .select(['loss']) + .unmask() + .add(changeFlagImage + .select(['gain']) + .unmask()) + .gte(1) + .selfMask(); var covariateLoader = function(covariateCode, yearString){ var assetPath = covariatePath @@ -48,7 +56,7 @@ var s1_probCollection = ee.ImageCollection([ gic2019.select([0]).addBands(ee.Image(7).int()) ]); -var linearFit = s1_probCollection.reduce(ee.Reducer.linearFit()); // the trend line plus would help with gain, minus with loss +var linearFit = s1_probCollection.reduce(ee.Reducer.linearFit()); var fitTrend = linearFit.select('scale'); // trend @@ -64,13 +72,12 @@ var covariateComposite = covariateLoader('awe', '20172019').subtract(covariateLo var bands = covariateComposite.bandNames(); -var trainingSet = 'foo' // path to loss/gain/stable training data var predictorSet = trainingSet.map(samplePredictors) - .distinct('.geo') // remove spatial duplicates - .distinct('awe_0010') // remove other duplicates + .distinct('.geo') + .distinct('awe_0010') .filter(ee.Filter.neq('awe_min', null)) - .randomColumn('random',1) //add random number //v200 to v202 were seed 1. Now trying seed 2 to see what happens to mangroves in Norfolk. + .randomColumn('random',1) .sort('random'); var classifier = ee.Classifier.smileRandomForest({ diff --git a/javascript/tidal_wetland_extent.js b/javascript/tidal_wetland_extent.js index 3633624..84d0bb7 100644 --- a/javascript/tidal_wetland_extent.js +++ b/javascript/tidal_wetland_extent.js @@ -11,9 +11,9 @@ var globOptions = { endDate: '2019-12-31', outScale: 30, probabilityThreshold: 50, - covariatePath: 'foo', // Covariates path + covariatePath: 'foo', // path to covariate folder landsatCollection: 'C01/T1_SR', - trainingDataID:'foo', // Training data path + trainingDataID:'foo', // path to predictorSet dateGenerated: ee.Date(Date.now()), classLabelList: ['Land', 'Water', 'Tidal Flat', 'Mangrove', 'Saltmarsh', 'Seagrass', 'Aquaculture'], classValueList: [0,1,2,3,5,6,7],