Skip to content

Commit

Permalink
update for v0.1.1-alpha release
Browse files Browse the repository at this point in the history
  • Loading branch information
nick-murray committed Feb 4, 2022
1 parent da841a3 commit f6f96b2
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 34 deletions.
25 changes: 10 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion javascript/change_flag.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
5 changes: 2 additions & 3 deletions javascript/covariate_reduce.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
Expand Down Expand Up @@ -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))
Expand Down
8 changes: 4 additions & 4 deletions javascript/covariate_sample.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down Expand Up @@ -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,
Expand Down
25 changes: 16 additions & 9 deletions javascript/tidal_wetland_change_classifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand All @@ -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
Expand Down Expand Up @@ -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

Expand All @@ -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({
Expand Down
4 changes: 2 additions & 2 deletions javascript/tidal_wetland_extent.js
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down

0 comments on commit f6f96b2

Please sign in to comment.