-
Notifications
You must be signed in to change notification settings - Fork 0
/
update_project_database.js
64 lines (55 loc) · 1.84 KB
/
update_project_database.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/**
*
* Adding new shapefiles to the master FeatureCollection asset for Rangeland Explorer
* 1. Upload shapefile to GEE Asset
* 2. Import and set feature properties
* 3. Combine with master feature collection
* 4. Export to Asset
*
*/
// Define the date with which to label the update
var dateLabel = '20231008'
// Import the master featurecollection with existing shapefiles displayed in the app
var old = ee.FeatureCollection('users/zandersamuel/Consult_CSA/CSA_master_20230610')
Map.addLayer(old, {}, 'old')
// Import the new shapefile (uploaded to your GEE Asset)
var new1 = ee.FeatureCollection('users/zandersamuel/Consult_CSA/ERS_Project');
print(new1)
// (Optional)
// Set the feature properties
new1 = new1.map(function(ft){
return ee.Feature(ft.geometry(), {
Name: ft.get('Name'),
Country:ft.get('Country'),
Provnce: ft.get('Province'),
Project: ft.get('Project'),
NGO: ft.get('NGO'),
Cons_ac: ft.get('Cons_ac'),
Farmer_num: '',
Stock_num: '',
Graz_assoc: '',
Year_start: ft.get('Year_start'),
Rainfall: '',
Years_partic: '',
Status: ft.get('Status')
});
});
print(new1)
Map.addLayer(new1, {color:'red'}, 'new1')
// Merge the new and the old
// At this stage, we are only using the Name and Project properties in the app
var combined = old.select(['Name','Project'])
.merge(new1.select(['Name','Project']))
// Check to see the number of polygons is in fact changed
print(old.size(), 'old size')
print(combined, 'combined')
print(combined.size(), 'new size')
Map.addLayer(combined, {}, 'combined', 0)
// Check to see the list of unique projects
print(combined.distinct(['Project']).reduceColumns(ee.Reducer.toList(), ['Project']))
// Export to GEE Asset
Export.table.toAsset({
collection: combined,
assetId: 'Consult_CSA/CSA_master_' + dateLabel,
description:'CSA_master_' + dateLabel
});