-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path03c_patchID_patchSize_formatAsset.js
More file actions
74 lines (62 loc) · 2.23 KB
/
03c_patchID_patchSize_formatAsset.js
File metadata and controls
74 lines (62 loc) · 2.23 KB
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
65
66
67
68
69
70
71
72
73
74
// prepare patch ID and patch size assets as ee.Image
// dhemerson.costa@ipam.org.br
// set version
var collectionId = 101;
var version = 3;
// set patch id folder
var patchID = ee.ImageCollection('projects/mapbiomas-brazil/assets/DEGRADATION/COLLECTION-10/patch-id-v3')
.toBands();
var patchSize = ee.ImageCollection('projects/mapbiomas-brazil/assets/DEGRADATION/COLLECTION-10/patch-size-all-v3')
.toBands();
print(patchSize)
// Set years to be processed
var years_list = [1985, 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
2018, 2019, 2020, 2021, 2022, 2023, 2024];
// define recipes
var recipeID = ee.Image([]);
var recipeSize = ee.Image([]);
// for each year
years_list.forEach(function(year_i) {
// bind patchID
recipeID = recipeID.addBands(
patchID.select('fragment_id_' + year_i + '_b1')
.rename('id_' + year_i)
.selfMask()
.round()
);
// bind patch size
recipeSize = recipeSize.addBands(
patchSize.select('fragment_area_' + year_i + '_b1')
.rename('size_' + year_i)
.selfMask()
.round()
);
});
// format dataType
recipeID = recipeID.int32();
recipeSize = recipeSize.int32();
// inspect
print(recipeID, recipeSize);
Map.addLayer(recipeID.select('id_2024').randomVisualizer(), {}, 'id');
Map.addLayer(recipeSize.select('size_2024'), {palette:['red', 'yellow', 'green'], min: 5, max: 5000}, 'size');
// Export
Export.image.toAsset({
image: recipeID,
description: 'degradation_patch_id_col' + collectionId + '_v' + version,
assetId: 'projects/mapbiomas-brazil/assets/DEGRADATION/COLLECTION-10/public/' + 'degradation_patch_id_col' + collectionId + '_v' + version,
region: patchID.geometry(),
scale: 30,
maxPixels: 1e13,
priority: 999
});
Export.image.toAsset({
image: recipeSize,
description: 'degradation_patch_size_col' + collectionId + '_v' + version,
assetId: 'projects/mapbiomas-brazil/assets/DEGRADATION/COLLECTION-10/public/' + 'degradation_patch_size_col' + collectionId + '_v' + version,
region: patchSize.geometry(),
scale: 30,
maxPixels: 1e13,
priority: 999
});