├── .gitignore ├── misc ├── toolkit.png ├── run-button.png ├── getting-code.png ├── tables-asset.png ├── upload-table.png ├── create-folder.png ├── mapbiomas-icon.png ├── video-tutorial.png ├── accessing-data-1.png ├── accessing-data-2.png ├── accessing-data-3.png ├── accessing-data-4.png ├── accessing-data-5.png ├── accessing-data-6.png ├── accessing-data-7.png ├── accessing-data-8.png └── transitions.md ├── legend-colors ├── mapbiomas-legend-arcmap.lyr ├── mapbiomas-legend-excel.xlsx ├── mapbiomas-legend-qgis.qml └── mapbiomas-legend-collection50.qml ├── .vscode └── settings.json ├── ancillary ├── asset_acl_public.sh ├── mapbiomas-brazil-export-water-data.js ├── mapbiomas-panamazon-export-water-data.js └── mapbiomas-southamerica-export-water-data.js ├── set-asset-public.sh ├── mapbiomas-user-toolkit-mosaics.js ├── mapbiomas-user-toolkit-calculate-area.js ├── README.md ├── prototype └── tabs.js ├── mapbiomas-user-toolkit-pasture.js ├── mapbiomas-user-toolkit-irrigation.js └── mapbiomas-user-toolkit-mining.js /.gitignore: -------------------------------------------------------------------------------- 1 | .vscode -------------------------------------------------------------------------------- /misc/toolkit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapbiomas-brazil/user-toolkit/HEAD/misc/toolkit.png -------------------------------------------------------------------------------- /misc/run-button.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapbiomas-brazil/user-toolkit/HEAD/misc/run-button.png -------------------------------------------------------------------------------- /misc/getting-code.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapbiomas-brazil/user-toolkit/HEAD/misc/getting-code.png -------------------------------------------------------------------------------- /misc/tables-asset.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapbiomas-brazil/user-toolkit/HEAD/misc/tables-asset.png -------------------------------------------------------------------------------- /misc/upload-table.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapbiomas-brazil/user-toolkit/HEAD/misc/upload-table.png -------------------------------------------------------------------------------- /misc/create-folder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapbiomas-brazil/user-toolkit/HEAD/misc/create-folder.png -------------------------------------------------------------------------------- /misc/mapbiomas-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapbiomas-brazil/user-toolkit/HEAD/misc/mapbiomas-icon.png -------------------------------------------------------------------------------- /misc/video-tutorial.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapbiomas-brazil/user-toolkit/HEAD/misc/video-tutorial.png -------------------------------------------------------------------------------- /misc/accessing-data-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapbiomas-brazil/user-toolkit/HEAD/misc/accessing-data-1.png -------------------------------------------------------------------------------- /misc/accessing-data-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapbiomas-brazil/user-toolkit/HEAD/misc/accessing-data-2.png -------------------------------------------------------------------------------- /misc/accessing-data-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapbiomas-brazil/user-toolkit/HEAD/misc/accessing-data-3.png -------------------------------------------------------------------------------- /misc/accessing-data-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapbiomas-brazil/user-toolkit/HEAD/misc/accessing-data-4.png -------------------------------------------------------------------------------- /misc/accessing-data-5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapbiomas-brazil/user-toolkit/HEAD/misc/accessing-data-5.png -------------------------------------------------------------------------------- /misc/accessing-data-6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapbiomas-brazil/user-toolkit/HEAD/misc/accessing-data-6.png -------------------------------------------------------------------------------- /misc/accessing-data-7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapbiomas-brazil/user-toolkit/HEAD/misc/accessing-data-7.png -------------------------------------------------------------------------------- /misc/accessing-data-8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapbiomas-brazil/user-toolkit/HEAD/misc/accessing-data-8.png -------------------------------------------------------------------------------- /legend-colors/mapbiomas-legend-arcmap.lyr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapbiomas-brazil/user-toolkit/HEAD/legend-colors/mapbiomas-legend-arcmap.lyr -------------------------------------------------------------------------------- /legend-colors/mapbiomas-legend-excel.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mapbiomas-brazil/user-toolkit/HEAD/legend-colors/mapbiomas-legend-excel.xlsx -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "workbench.colorCustomizations": { 3 | "activityBar.activeBackground": "#55e40f", 4 | "activityBar.activeBorder": "#4c83f3", 5 | "activityBar.background": "#55e40f", 6 | "activityBar.foreground": "#15202b", 7 | "activityBar.inactiveForeground": "#15202b99", 8 | "activityBarBadge.background": "#4c83f3", 9 | "activityBarBadge.foreground": "#e7e7e7", 10 | "sash.hoverBorder": "#55e40f" 11 | }, 12 | "peacock.color": "#43b40c" 13 | } -------------------------------------------------------------------------------- /ancillary/asset_acl_public.sh: -------------------------------------------------------------------------------- 1 | # Defina a pasta de destino 2 | folder="projects/mapbiomas-territories/assets/TERRITORIES/LULC/BRAZIL/COLLECTION9/WORKSPACE" 3 | 4 | # Liste todos os assets na pasta 5 | assets=$(earthengine ls $folder) 6 | 7 | # Percorra a lista de assets e torne-os públicos 8 | for asset in $assets 9 | do 10 | echo $asset 11 | earthengine acl set public $asset 12 | done 13 | 14 | # Confirme que todos os assets foram tornados públicos 15 | echo "Todos os assets na pasta $folder foram tornados públicos." 16 | -------------------------------------------------------------------------------- /set-asset-public.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Autenticação 4 | # earthengine authenticate 5 | 6 | # Caminho da pasta 7 | folder_path="projects/earthengine-legacy/assets/projects/mapbiomas-raisg/DATOS_AUXILIARES/ESTADISTICAS/COLECCION5/V1" 8 | 9 | # Lista de ativos na pasta 10 | asset_list=$(earthengine ls $folder_path) 11 | echo $asset_list 12 | # Torna cada ativo público 13 | while read -r asset; do 14 | echo "Tornando público: $asset" 15 | earthengine acl set public $asset 16 | done <<< "$asset_list" 17 | 18 | echo "Todos os ativos em $folder_path foram tornados públicos." 19 | -------------------------------------------------------------------------------- /mapbiomas-user-toolkit-mosaics.js: -------------------------------------------------------------------------------- 1 | // 2 | // Define a geometry 3 | var geometry = ee.Geometry.Polygon( 4 | [ 5 | [ 6 | [-55.80975401310168, -6.617795520325061], 7 | [-55.80975401310168, -7.519994257183307], 8 | [-54.93634092716418, -7.519994257183307], 9 | [-54.93634092716418, -6.617795520325061] 10 | ] 11 | ] 12 | ); 13 | 14 | // Do not change the mosaics asset 15 | var asset = 'projects/mapbiomas-workspace/MOSAICOS/workspace-c3'; 16 | 17 | // Choose the biome name: 'AMAZONIA', 'CAATINGA', 'CERRADO', 'MATAATLANTICA', 'PAMPA' or 'PANTANAL' 18 | var biome = 'AMAZONIA'; 19 | 20 | // Define the year of your interest 21 | var year = 2019; 22 | 23 | // Output file name 24 | var fileName = 'mosaic-' + String(year); 25 | 26 | // Look the available band list at the console 27 | var exportBands = [ 28 | "median_blue", 29 | "median_gree", 30 | "median_red", 31 | "median_bir", 32 | "median_swir1", 33 | "median_swir2", 34 | ]; 35 | 36 | // Get the moisac 37 | var mosaic = ee.ImageCollection(asset) 38 | .filterMetadata('biome', 'equals', biome) 39 | .filterMetadata('year', 'equals', year) 40 | .filterBounds(geometry) 41 | .mosaic(); 42 | 43 | // prints all bands available to download 44 | print(mosaic.bandNames()); 45 | 46 | // Shows the mosaic on map 47 | Map.addLayer(mosaic.clip(geometry), 48 | { 49 | bands: 'median_swir1,median_nir,median_red', 50 | gain: '0.08,0.06,0.2', 51 | gamma: 0.75 52 | }, 53 | 54 | 'mapbiomas mosaic' 55 | ); 56 | 57 | // Exports the data to MAPBIOMAS-EXPORT folder in your Google Drive 58 | Export.image.toDrive( 59 | { 60 | 'image': mosaic.int32(), 61 | 'description': fileName, 62 | 'folder': 'MAPBIOMAS-EXPORT', 63 | 'fileNamePrefix': fileName, 64 | 'region': geometry, 65 | 'scale': 30, 66 | 'maxPixels': 1e13, 67 | 'fileFormat': 'GeoTIFF' 68 | } 69 | ); 70 | -------------------------------------------------------------------------------- /ancillary/mapbiomas-brazil-export-water-data.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | 5 | var asset = "projects/mapbiomas-workspace/TRANSVERSAIS/COLECAO8/agua"; 6 | var assetOutput = "projects/mapbiomas-workspace/public/collection8" 7 | var years = [ 8 | 1985, 1986, 1987, 1988, 1989, 1990, 9 | 1991, 1992, 1993, 1994, 1995, 1996, 10 | 1997, 1998, 1999, 2000, 2001, 2002, 11 | 2003, 2004, 2005, 2006, 2007, 2008, 12 | 2009, 2010, 2011, 2012, 2013, 2014, 13 | 2015, 2016, 2017, 2018, 2019, 2020, 14 | 2021, 2022 15 | ]; 16 | 17 | var inputVersion = '1'; 18 | 19 | var region = ee.Geometry.Polygon( 20 | [ 21 | [ 22 | [-74.89726562500002, 7.912024007342442], 23 | [-74.89726562500002, -34.79152285156706], 24 | [-33.06132812500001, -34.79152285156706], 25 | [-33.06132812500001, 7.912024007342442] 26 | ] 27 | ], 28 | null, false 29 | ); 30 | 31 | var annualWater = ee.Image( 32 | years.map( 33 | function (year) { 34 | var assetName = year.toString() + '-' + inputVersion; 35 | 36 | return ee.Image(asset + '/' + assetName).rename('annual_water_coverage_' + year.toString()); 37 | } 38 | ) 39 | ).int8(); 40 | 41 | var waterFrequency = annualWater 42 | .gt(0) 43 | .reduce(ee.Reducer.sum()) 44 | .int8() 45 | .rename("water_frequency_1985_2022"); 46 | 47 | Map.addLayer(annualWater); 48 | Map.addLayer(waterFrequency); 49 | 50 | print(annualWater); 51 | print(waterFrequency); 52 | 53 | Export.image.toAsset({ 54 | image: annualWater, 55 | description: 'mapbiomas_brazil_collection2_annual_water_coverage_v1', 56 | assetId: assetOutput + '/mapbiomas_brazil_collection2_annual_water_coverage_v1', 57 | pyramidingPolicy: { 58 | '.default': 'mode', 59 | }, 60 | region: region, 61 | scale: 30, 62 | maxPixels: 1e13 63 | }); 64 | 65 | Export.image.toAsset({ 66 | image: waterFrequency, 67 | description: 'mapbiomas_brazil_collection2_water_frequency_v1', 68 | assetId: assetOutput + '/mapbiomas_brazil_collection2_water_frequency_v1', 69 | pyramidingPolicy: { 70 | '.default': 'mode', 71 | }, 72 | region: region, 73 | scale: 30, 74 | maxPixels: 1e13 75 | }); -------------------------------------------------------------------------------- /ancillary/mapbiomas-panamazon-export-water-data.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | 5 | var asset = "projects/mapbiomas-raisg/TRANSVERSALES/GTAGUA/COLECCION1/agua"; 6 | var assetOutput = "projects/mapbiomas-raisg/public/collection5" 7 | var years = [ 8 | /* 1985, 1986, 1987, 1988, 1989, 1990, 9 | 1991, 1992, 1993, 1994, 1995, 1996, 10 | 1997, 1998, 1999, */2000, 2001, 2002, 11 | 2003, 2004, 2005, 2006, 2007, 2008, 12 | 2009, 2010, 2011, 2012, 2013, 2014, 13 | 2015, 2016, 2017, 2018, 2019, 2020, 14 | 2021, 2022 15 | ]; 16 | 17 | var inputVersion = '1'; 18 | 19 | var region = ee.Geometry.Polygon( 20 | [ 21 | [ 22 | [-81.23703132331441, 10.371866133558363], 23 | [-81.23703132331441, -21.23542723801477], 24 | [-43.18039069831440, -21.23542723801477], 25 | [-43.18039069831440, 10.371866133558363] 26 | ] 27 | ], 28 | null, false 29 | ); 30 | 31 | var annualWater = ee.Image( 32 | years.map( 33 | function (year) { 34 | var assetName = year.toString() + '-' + inputVersion; 35 | 36 | return ee.Image(asset + '/' + assetName).rename('annual_water_coverage_' + year.toString()); 37 | } 38 | ) 39 | ).int8(); 40 | 41 | var waterFrequency = annualWater 42 | .gt(0) 43 | .reduce(ee.Reducer.sum()) 44 | .int8() 45 | .rename("water_frequency_2000_2022"); 46 | 47 | Map.addLayer(annualWater); 48 | Map.addLayer(waterFrequency); 49 | 50 | print(annualWater); 51 | print(waterFrequency); 52 | 53 | Export.image.toAsset({ 54 | image: annualWater, 55 | description: 'mapbiomas_raisg_panamazonia_collection1_annual_water_coverage_v2', 56 | assetId: assetOutput + '/mapbiomas_raisg_panamazonia_collection1_annual_water_coverage_v2', 57 | pyramidingPolicy: { 58 | '.default': 'mode', 59 | }, 60 | region: region, 61 | scale: 30, 62 | maxPixels: 1e13 63 | }); 64 | 65 | Export.image.toAsset({ 66 | image: waterFrequency, 67 | description: 'mapbiomas_raisg_panamazonia_collection1_water_frequency_v2', 68 | assetId: assetOutput + '/mapbiomas_raisg_panamazonia_collection1_water_frequency_v2', 69 | pyramidingPolicy: { 70 | '.default': 'mode', 71 | }, 72 | region: region, 73 | scale: 30, 74 | maxPixels: 1e13 75 | }); -------------------------------------------------------------------------------- /legend-colors/mapbiomas-legend-qgis.qml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 1 5 | 1 6 | 1 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | None 19 | WholeRaster 20 | Estimated 21 | 0.02 22 | 0.98 23 | 2 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 | 0 56 | 57 | -------------------------------------------------------------------------------- /mapbiomas-user-toolkit-calculate-area.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @description 3 | * calculate area 4 | * 5 | * @author 6 | * João Siqueira 7 | * 8 | */ 9 | 10 | // Asset mapbiomas 11 | var asset = "projects/mapbiomas-workspace/public/collection5/mapbiomas_collection50_integration_v1"; 12 | 13 | // Asset of regions for which you want to calculate statistics 14 | var assetTerritories = "projects/mapbiomas-workspace/AUXILIAR/municipios-2016-raster"; 15 | 16 | // Change the scale if you need. 17 | var scale = 30; 18 | 19 | // Define a list of years to export 20 | var years = [ 21 | '1985', '1986', '1987', '1988', '1989', '1990', '1991', '1992', 22 | '1993', '1994', '1995', '1996', '1997', '1998', '1999', '2000', 23 | '2001', '2002', '2003', '2004', '2005', '2006', '2007', '2008', 24 | '2009', '2010', '2011', '2012', '2013', '2014', '2015', '2016', 25 | '2017', '2018', '2019' 26 | ]; 27 | 28 | // Define a Google Drive output folder 29 | var driverFolder = 'AREA-EXPORT'; 30 | 31 | /** 32 | * 33 | */ 34 | // Territory image 35 | var territory = ee.Image(assetTerritories); 36 | 37 | // LULC mapbiomas image 38 | var mapbiomas = ee.Image(asset).selfMask(); 39 | 40 | // Image area in km2 41 | var pixelArea = ee.Image.pixelArea().divide(1000000); 42 | 43 | // Geometry to export 44 | var geometry = mapbiomas.geometry(); 45 | 46 | /** 47 | * Convert a complex obj to a feature collection 48 | * @param obj 49 | */ 50 | var convert2table = function (obj) { 51 | 52 | obj = ee.Dictionary(obj); 53 | 54 | var territory = obj.get('territory'); 55 | 56 | var classesAndAreas = ee.List(obj.get('groups')); 57 | 58 | var tableRows = classesAndAreas.map( 59 | function (classAndArea) { 60 | classAndArea = ee.Dictionary(classAndArea); 61 | 62 | var classId = classAndArea.get('class'); 63 | var area = classAndArea.get('sum'); 64 | 65 | var tableColumns = ee.Feature(null) 66 | .set('territory', territory) 67 | .set('class', classId) 68 | .set('area', area); 69 | 70 | return tableColumns; 71 | } 72 | ); 73 | 74 | return ee.FeatureCollection(ee.List(tableRows)); 75 | }; 76 | 77 | /** 78 | * Calculate area crossing a cover map (deforestation, mapbiomas) 79 | * and a region map (states, biomes, municipalites) 80 | * @param image 81 | * @param territory 82 | * @param geometry 83 | */ 84 | var calculateArea = function (image, territory, geometry) { 85 | 86 | var reducer = ee.Reducer.sum().group(1, 'class').group(1, 'territory'); 87 | 88 | var territoriesData = pixelArea.addBands(territory).addBands(image) 89 | .reduceRegion({ 90 | reducer: reducer, 91 | geometry: geometry, 92 | scale: scale, 93 | maxPixels: 1e12 94 | }); 95 | 96 | territoriesData = ee.List(territoriesData.get('groups')); 97 | 98 | var areas = territoriesData.map(convert2table); 99 | 100 | areas = ee.FeatureCollection(areas).flatten(); 101 | 102 | return areas; 103 | }; 104 | 105 | // Iterate over years, select the classification and calculate area 106 | var areas = years.map( 107 | function (year) { 108 | var image = mapbiomas.select('classification_' + year); 109 | 110 | var areas = calculateArea(image, territory, geometry); 111 | 112 | // set additional properties 113 | areas = areas.map( 114 | function (feature) { 115 | return feature.set('year', year); 116 | } 117 | ); 118 | 119 | return areas; 120 | } 121 | ); 122 | 123 | // Convert a collection of collections into a single collection 124 | areas = ee.FeatureCollection(areas).flatten(); 125 | 126 | // Export a csv file to Google Drive 127 | Export.table.toDrive({ 128 | collection: areas, 129 | description: 'areas-teste-toolkit', 130 | folder: driverFolder, 131 | fileNamePrefix: 'areas-teste-toolkit', 132 | fileFormat: 'CSV' 133 | }); 134 | -------------------------------------------------------------------------------- /ancillary/mapbiomas-southamerica-export-water-data.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | /** 4 | * 5 | */ 6 | var asset = 'projects/mapbiomas-raisg/TRANSVERSALES/GTAGUA/COLECCION1/agua'; 7 | 8 | var countries = { 9 | 'brazil': { 10 | 'asset': 'projects/mapbiomas-workspace/AUXILIAR/ESTATISTICAS/COLECAO8/VERSAO-1/country-raster', 11 | 'output': '' 12 | }, 13 | // 'bolivia': { 14 | // 'asset': 'projects/mapbiomas-raisg/BOLIVIA/DATOS_AUXILIARES/ESTADISTICAS/COLECCION1/pais-raster', 15 | // 'output': '' 16 | // }, 17 | // 'colombia': { 18 | // 'asset': 'projects/mapbiomas-raisg/COLOMBIA/DATOS_AUXILIARES/ESTADISTICAS/COLECCION1/nivel-politico-1-raster', 19 | // 'output': '' 20 | // }, 21 | // 'ecuador': { 22 | // 'asset': 'projects/mapbiomas-raisg/MAPBIOMAS-ECUADOR/DATOS-AUXILIARES/ESTADISTICAS/COLECCION1/VERSION-2/nivel-politico-1-raster', 23 | // 'output': '' 24 | // }, 25 | // 'peru': { 26 | // 'asset': 'projects/mapbiomas-raisg/MAPBIOMAS-PERU/DATOS-AUXILIARES/ESTADISTICAS/COLECCION2/nivel-politico-1-raster', 27 | // 'output': '' 28 | // }, 29 | // 'venezuela': { 30 | // 'asset': 'projects/mapbiomas-raisg/MAPBIOMAS-VENEZUELA/DATOS-AUXILIARES/ESTADISTICAS/COLECCION1/nivel-politico-1-raster', 31 | // 'output': '' 32 | // }, 33 | }; 34 | 35 | var version = '1'; 36 | 37 | // var assetOutput = 'projects/mapbiomas-public/assets/{country}/collection1/mapbiomas_{country}_collection1_water_v1'; 38 | var assetOutput = 'projects/mapbiomas-public/assets/{country}/collection1/mapbiomas_{country}_collection1_water_v1'; 39 | var assetFrequencyOutput = 'projects/mapbiomas-public/assets/{country}/collection1/mapbiomas_{country}_collection1_water_frequency_v1'; 40 | 41 | var years = [ 42 | '1985', '1986', '1987', '1988', 43 | '1989', '1990', '1991', '1992', 44 | '1993', '1994', '1995', '1996', 45 | '1997', '1998', '1999', '2000', 46 | '2001', '2002', '2003', '2004', 47 | '2005', '2006', '2007', '2008', 48 | '2009', '2010', '2011', '2012', 49 | '2013', '2014', '2015', '2016', 50 | '2017', '2018', '2019', '2020', 51 | '2021', '2022' 52 | ]; 53 | 54 | var palette = require('users/mapbiomas/modules:Palettes.js').get('classification8'); 55 | 56 | var water = years.map( 57 | function (year) { 58 | return ee.Image(asset + '/' + year + '-' + version) 59 | .rename('annual_water_coverage_' + year); 60 | } 61 | ); 62 | 63 | water = ee.Image(water); 64 | 65 | print(water); 66 | 67 | var waterFrequency = water 68 | .gt(0) 69 | .reduce(ee.Reducer.sum()) 70 | .int8() 71 | .rename("water_frequency_1985_2022"); 72 | 73 | Object.keys(countries).forEach( 74 | function (country) { 75 | var assetCountryOutput = assetOutput.replace(/{country}/g, country); 76 | var assetFrequencyCountryOutput = assetFrequencyOutput.replace(/{country}/g, country); 77 | 78 | var assetCountry = ee.Image(countries[country].asset); 79 | 80 | print(assetCountry); 81 | 82 | var waterCountry = water.mask(assetCountry.gt(0)).selfMask(); 83 | var waterFrequencyCountry = waterFrequency.mask(assetCountry.gt(0)).selfMask(); 84 | 85 | // Map.addLayer(waterCountry, { 86 | // 'palette': 'blue', 87 | // 'bands': 'annual_water_coverage_2022', 88 | // 'min': 0, 89 | // 'max': 33 90 | // }, country); 91 | 92 | Map.addLayer(waterFrequencyCountry, { 93 | 'palette': ['white','blue'], 94 | 'bands': 'water_frequency_1985_2022', 95 | 'min': 0, 96 | 'max': 33 97 | }, country + ' frequency'); 98 | 99 | // Export.image.toAsset({ 100 | // 'image': waterCountry.byte(), 101 | // 'description': assetCountryOutput.split('/').reverse()[0], 102 | // 'assetId': assetCountryOutput, 103 | // 'pyramidingPolicy': { '.default': 'mode' }, 104 | // 'region': assetCountry.geometry().buffer(300).bounds(), 105 | // 'scale': 30, 106 | // 'maxPixels': 1e13, 107 | // }); 108 | 109 | Export.image.toAsset({ 110 | 'image': waterFrequencyCountry, 111 | 'description': assetFrequencyCountryOutput.split('/').reverse()[0], 112 | 'assetId': assetFrequencyCountryOutput, 113 | 'pyramidingPolicy': { 114 | '.default': 'mode', 115 | }, 116 | 'region': assetCountry.geometry().buffer(300).bounds(), 117 | 'scale': 30, 118 | 'maxPixels': 1e13 119 | }); 120 | } 121 | ) 122 | -------------------------------------------------------------------------------- /legend-colors/mapbiomas-legend-collection50.qml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 1 5 | 1 6 | 1 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | None 19 | WholeRaster 20 | Estimated 21 | 0.02 22 | 0.98 23 | 2 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 | 0 73 | 74 | -------------------------------------------------------------------------------- /misc/transitions.md: -------------------------------------------------------------------------------- 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 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 |
Year t0Year t1Description
19851986consecutive years
19861987consecutive years
19871988consecutive years
19881989consecutive years
19891990consecutive years
19911992consecutive years
19921993consecutive years
19931994consecutive years
19941995consecutive years
19951996consecutive years
19961997consecutive years
19971998consecutive years
19981999consecutive years
19992000consecutive years
20012002consecutive years
20022003consecutive years
20032004consecutive years
20042005consecutive years
20052006consecutive years
20062007consecutive years
20072008consecutive years
20082009consecutive years
20092010consecutive years
20102011consecutive years
20112012consecutive years
20122013consecutive years
20132014consecutive years
20142015consecutive years
20152016consecutive years
20162017consecutive years
20172018consecutive years
20182019consecutive years
198519905 years
199019955 years
199520005 years
200020055 years
200520105 years
201020155 years
1990200010 years
2000201010 years
2010201910 years*
19852019All collection
20082019Forest Code cutting date
20122019Forest Code year of aproval
19942002Brazil GHG Emissions Inventory
20022010Brazil GHG Emissions Inventory
20102016Brazil GHG Emissions Inventory
20152018Other
20082017Other
19862015Other
20012016Other
265 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 6 | 7 | # About 8 | 9 | User Toolkit to download MapBiomas data with Google Earth Engine. This tutorial is about the script **mapbiomas-user-toolkit-lulc.js** 10 | 11 | # Release History 12 | 13 | * 1.0.0 14 | * Access and download data using user's vector 15 | * 1.1.0 16 | * Updated for collection 4.0 17 | * 1.1.1 18 | * Updated assets 19 | * 1.1.2 20 | * New transitions periods 21 | * 1.1.3 22 | * Updated for collection 4.1 23 | * 1.3.0 24 | * Updated for collection 5.0 25 | * Export a csv file with areas per classe and year 26 | * 1.3.1 27 | * Loads mapbiomas-chaco collection 2.0 28 | * 1.3.2 29 | * Loads mapbiomas-brazil collection 5.0 quality 30 | * 1.4.0 31 | * Loads mapbiomas-atlantic-forest collection 1.0 32 | * 1.5.0 33 | * Loads mapbiomas-pampa collection 1.0 34 | * 1.6.0 35 | * Loads mapbiomas-brazil collection 6.0 36 | * 1.7.0 37 | * Loads mapbiomas-amazon collection 3.0 38 | 39 | 45 | 46 | MapBiomas Brasil | Solved Scholar | Luis Sadeck 47 | 48 | # How to use 49 | 50 |

1. Getting the code

51 |

Access the repository directly in Google Earth Engine. The repository will appear at Reader Session of your scripts tab.

52 | 53 | Markdown Monster icon 56 | 57 |

2. Create a MAPBIOMAS folder

58 | 63 | Markdown Monster icon 66 | 67 |

3. Upload a new table asset

68 | 69 | 77 | Markdown Monster icon 80 | 81 | 85 | Markdown Monster icon 88 | 89 |

4. Accessing the data

90 | 91 | 94 | Markdown Monster icon 97 | 98 | 101 | Markdown Monster icon 104 | 105 | 109 | Markdown Monster icon 112 | 113 | 116 | Markdown Monster icon 119 | 120 | 124 | Markdown Monster icon 127 | 128 | 131 | Markdown Monster icon 134 | 135 |

5. Exporting data

136 | 139 | Markdown Monster icon 142 | 145 | Markdown Monster icon 148 | 149 | 153 | 154 | 155 |

6. Apply the MapBiomas color palette.

156 | 161 | 162 |

7. Transitions dates.

163 | 166 | 167 |

Enjoy!

168 | :smile: 169 | 170 | 171 | -------------------------------------------------------------------------------- /prototype/tabs.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | var App = { 6 | 7 | init: function () { 8 | App.ui.int(); 9 | }, 10 | 11 | ui: { 12 | int: function () { 13 | App.ui.form.panelMain.add(App.ui.form.tabs); 14 | App.ui.form.panelMain.add(App.ui.form.panel1); 15 | 16 | App.ui.form.tab1.add(App.ui.form.checkboxTab1); 17 | App.ui.form.tab2.add(App.ui.form.checkboxTab2); 18 | 19 | App.ui.form.tabs.add(App.ui.form.tab1); 20 | App.ui.form.tabs.add(App.ui.form.tab2); 21 | 22 | ui.root.add(App.ui.form.panelMain); 23 | }, 24 | 25 | form: { 26 | panelMain: ui.Panel(), 27 | 28 | tabs: ui.Panel({ 29 | layout: ui.Panel.Layout.flow('horizontal') 30 | }), 31 | 32 | checkboxTab1: ui.Checkbox({ 33 | 'label': ' Toolkit ', 34 | 'style': { 35 | 'margin': '5px 0px 5px -16px', 36 | 'stretch': 'horizontal', 37 | 'backgroundColor': '#00000000', 38 | }, 39 | 'onChange': function (checked) { 40 | if (checked) { 41 | App.ui.form.checkboxTab2.setValue(false); 42 | App.ui.form.tab1.style().set('border', '1px solid #808080'); 43 | App.ui.form.tab2.style().set('border', '1px solid #80808033'); 44 | 45 | App.ui.form.panelMain.remove(App.ui.form.panel2); 46 | App.ui.form.panelMain.add(App.ui.form.panel1); 47 | } 48 | } 49 | }), 50 | 51 | checkboxTab2: ui.Checkbox({ 52 | 'label': ' Direct Link', 53 | 'style': { 54 | 'margin': '5px 20px 5px -16px', 55 | 'stretch': 'horizontal', 56 | 'backgroundColor': '#00000000', 57 | }, 58 | 'onChange': function (checked) { 59 | if (checked) { 60 | App.ui.form.checkboxTab1.setValue(false); 61 | App.ui.form.tab1.style().set('border', '1px solid #80808033'); 62 | App.ui.form.tab2.style().set('border', '1px solid #808080'); 63 | 64 | App.ui.form.panelMain.remove(App.ui.form.panel1); 65 | App.ui.form.panelMain.add(App.ui.form.panel2); 66 | } 67 | 68 | } 69 | }), 70 | 71 | tab1: ui.Panel({ 72 | 'style': { 73 | 'width': '100px', 74 | 'backgroundColor': '#dddddd00', 75 | 'stretch': 'horizontal', 76 | 'border': '1px solid #808080' 77 | }, 78 | }), 79 | 80 | tab2: ui.Panel({ 81 | 'style': { 82 | 'width': '100px', 83 | 'backgroundColor': '#dddddd00', 84 | 'stretch': 'horizontal', 85 | 'border': '1px solid #80808033', 86 | } 87 | }), 88 | 89 | panel1: ui.Panel({ 90 | widgets: [ui.Label('Painel 1')], 91 | style: { 92 | width: '400px' 93 | } 94 | }), 95 | 96 | panel2: ui.Panel({ 97 | widgets: [ 98 | ui.Label('Brazil'), 99 | ui.Panel({ 100 | widgets: [ 101 | ui.Label({ value: '1985', targetUrl: 'https://storage.googleapis.com/mapbiomas-public/brasil/collection-6/lclu/coverage/brasil_coverage_1985.tif' }), 102 | ui.Label({ value: '1986', targetUrl: 'https://storage.googleapis.com/mapbiomas-public/brasil/collection-6/lclu/coverage/brasil_coverage_1986.tif' }), 103 | ui.Label({ value: '1987', targetUrl: 'https://storage.googleapis.com/mapbiomas-public/brasil/collection-6/lclu/coverage/brasil_coverage_1987.tif' }), 104 | ui.Label({ value: '1988', targetUrl: 'https://storage.googleapis.com/mapbiomas-public/brasil/collection-6/lclu/coverage/brasil_coverage_1988.tif' }), 105 | ui.Label({ value: '1989', targetUrl: 'https://storage.googleapis.com/mapbiomas-public/brasil/collection-6/lclu/coverage/brasil_coverage_1989.tif' }), 106 | ui.Label({ value: '1990', targetUrl: 'https://storage.googleapis.com/mapbiomas-public/brasil/collection-6/lclu/coverage/brasil_coverage_1990.tif' }), 107 | ui.Label({ value: '1991', targetUrl: 'https://storage.googleapis.com/mapbiomas-public/brasil/collection-6/lclu/coverage/brasil_coverage_1991.tif' }), 108 | ui.Label({ value: '1992', targetUrl: 'https://storage.googleapis.com/mapbiomas-public/brasil/collection-6/lclu/coverage/brasil_coverage_1992.tif' }), 109 | ui.Label({ value: '1993', targetUrl: 'https://storage.googleapis.com/mapbiomas-public/brasil/collection-6/lclu/coverage/brasil_coverage_1993.tif' }), 110 | ui.Label({ value: '1994', targetUrl: 'https://storage.googleapis.com/mapbiomas-public/brasil/collection-6/lclu/coverage/brasil_coverage_1994.tif' }), 111 | ui.Label({ value: '1995', targetUrl: 'https://storage.googleapis.com/mapbiomas-public/brasil/collection-6/lclu/coverage/brasil_coverage_1995.tif' }), 112 | ui.Label({ value: '1996', targetUrl: 'https://storage.googleapis.com/mapbiomas-public/brasil/collection-6/lclu/coverage/brasil_coverage_1996.tif' }), 113 | ui.Label({ value: '1997', targetUrl: 'https://storage.googleapis.com/mapbiomas-public/brasil/collection-6/lclu/coverage/brasil_coverage_1997.tif' }), 114 | ui.Label({ value: '1998', targetUrl: 'https://storage.googleapis.com/mapbiomas-public/brasil/collection-6/lclu/coverage/brasil_coverage_1998.tif' }), 115 | ui.Label({ value: '1999', targetUrl: 'https://storage.googleapis.com/mapbiomas-public/brasil/collection-6/lclu/coverage/brasil_coverage_1999.tif' }), 116 | ui.Label({ value: '2000', targetUrl: 'https://storage.googleapis.com/mapbiomas-public/brasil/collection-6/lclu/coverage/brasil_coverage_2000.tif' }), 117 | ui.Label({ value: '2001', targetUrl: 'https://storage.googleapis.com/mapbiomas-public/brasil/collection-6/lclu/coverage/brasil_coverage_2001.tif' }), 118 | ui.Label({ value: '2002', targetUrl: 'https://storage.googleapis.com/mapbiomas-public/brasil/collection-6/lclu/coverage/brasil_coverage_2002.tif' }), 119 | ui.Label({ value: '2003', targetUrl: 'https://storage.googleapis.com/mapbiomas-public/brasil/collection-6/lclu/coverage/brasil_coverage_2003.tif' }), 120 | ui.Label({ value: '2004', targetUrl: 'https://storage.googleapis.com/mapbiomas-public/brasil/collection-6/lclu/coverage/brasil_coverage_2004.tif' }), 121 | ui.Label({ value: '2005', targetUrl: 'https://storage.googleapis.com/mapbiomas-public/brasil/collection-6/lclu/coverage/brasil_coverage_2005.tif' }), 122 | ui.Label({ value: '2006', targetUrl: 'https://storage.googleapis.com/mapbiomas-public/brasil/collection-6/lclu/coverage/brasil_coverage_2006.tif' }), 123 | ui.Label({ value: '2007', targetUrl: 'https://storage.googleapis.com/mapbiomas-public/brasil/collection-6/lclu/coverage/brasil_coverage_2007.tif' }), 124 | ui.Label({ value: '2008', targetUrl: 'https://storage.googleapis.com/mapbiomas-public/brasil/collection-6/lclu/coverage/brasil_coverage_2008.tif' }), 125 | ui.Label({ value: '2009', targetUrl: 'https://storage.googleapis.com/mapbiomas-public/brasil/collection-6/lclu/coverage/brasil_coverage_2009.tif' }), 126 | ui.Label({ value: '2010', targetUrl: 'https://storage.googleapis.com/mapbiomas-public/brasil/collection-6/lclu/coverage/brasil_coverage_2010.tif' }), 127 | ui.Label({ value: '2011', targetUrl: 'https://storage.googleapis.com/mapbiomas-public/brasil/collection-6/lclu/coverage/brasil_coverage_2011.tif' }), 128 | ui.Label({ value: '2012', targetUrl: 'https://storage.googleapis.com/mapbiomas-public/brasil/collection-6/lclu/coverage/brasil_coverage_2012.tif' }), 129 | ui.Label({ value: '2013', targetUrl: 'https://storage.googleapis.com/mapbiomas-public/brasil/collection-6/lclu/coverage/brasil_coverage_2013.tif' }), 130 | ui.Label({ value: '2014', targetUrl: 'https://storage.googleapis.com/mapbiomas-public/brasil/collection-6/lclu/coverage/brasil_coverage_2014.tif' }), 131 | ui.Label({ value: '2015', targetUrl: 'https://storage.googleapis.com/mapbiomas-public/brasil/collection-6/lclu/coverage/brasil_coverage_2015.tif' }), 132 | ui.Label({ value: '2016', targetUrl: 'https://storage.googleapis.com/mapbiomas-public/brasil/collection-6/lclu/coverage/brasil_coverage_2016.tif' }), 133 | ui.Label({ value: '2017', targetUrl: 'https://storage.googleapis.com/mapbiomas-public/brasil/collection-6/lclu/coverage/brasil_coverage_2017.tif' }), 134 | ui.Label({ value: '2018', targetUrl: 'https://storage.googleapis.com/mapbiomas-public/brasil/collection-6/lclu/coverage/brasil_coverage_2018.tif' }), 135 | ui.Label({ value: '2019', targetUrl: 'https://storage.googleapis.com/mapbiomas-public/brasil/collection-6/lclu/coverage/brasil_coverage_2019.tif' }), 136 | ui.Label({ value: '2020', targetUrl: 'https://storage.googleapis.com/mapbiomas-public/brasil/collection-6/lclu/coverage/brasil_coverage_2020.tif' }), 137 | ], 138 | 'layout': ui.Panel.Layout.flow('horizontal', true) 139 | }), 140 | ], 141 | style: { 142 | width: '400px' 143 | } 144 | }), 145 | 146 | } 147 | } 148 | }; 149 | 150 | App.init(); -------------------------------------------------------------------------------- /mapbiomas-user-toolkit-pasture.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @name 3 | * Mapbiomas User Toolkit - Pasture 4 | * 5 | * @description 6 | * This is a support tool for mapbiomas data users. 7 | * 8 | * @author 9 | * João Siqueira 10 | * contato@mapbiomas.org 11 | * 12 | * @version 13 | * 1.0.0 - First release 14 | * 1.1.0 - Pasture Quality - Collection 6.0 15 | * 1.2.0 - Pasture Quality - Collection 7.0 16 | * 1.3.0 - Pasture Quality - Collection 8.0 17 | * 1.4.0 - Pasture Quality - Collection 9.0 18 | * 19 | * @see 20 | * Get the MapBiomas exported data in your "Google Drive/MAPBIOMAS-EXPORT" folder 21 | * Code and Tutorial - https://github.com/mapbiomas-brazil/user-toolkit 22 | */ 23 | 24 | var mapp = require('users/joaovsiqueira1/packages:Mapp.js'); 25 | var legend = require('users/joaovsiqueira1/packages:Legend.js'); 26 | 27 | /** 28 | * @description 29 | * calculate area for mapbiomas map 30 | * 31 | * @author 32 | * João Siqueira 33 | * 34 | */ 35 | var Area = { 36 | 37 | /** 38 | * Convert a complex obj to feature collection 39 | * @param obj 40 | */ 41 | convert2table: function (obj) { 42 | 43 | obj = ee.Dictionary(obj); 44 | 45 | var classesAndAreas = ee.List(obj.get('groups')); 46 | 47 | var tableRows = classesAndAreas.map( 48 | function (classAndArea) { 49 | classAndArea = ee.Dictionary(classAndArea); 50 | 51 | var classId = classAndArea.get('class'); 52 | var area = classAndArea.get('sum'); 53 | 54 | var tableColumns = ee.Feature(null) 55 | .set('class', classId) 56 | .set('area', area); 57 | 58 | return tableColumns; 59 | } 60 | ); 61 | 62 | return ee.FeatureCollection(ee.List(tableRows)); 63 | }, 64 | 65 | /** 66 | * Calculate area crossing a cover map (deforestation, mapbiomas) 67 | * and a region map (states, biomes, municipalites) 68 | * @param image 69 | * @param territory 70 | * @param geometry 71 | * @param scale 72 | * @param factor 73 | */ 74 | calculate: function (object) { 75 | 76 | var reducer = ee.Reducer.sum().group(1, 'class').group(1, 'territory'); 77 | var pixelArea = ee.Image.pixelArea().divide(object.factor); 78 | 79 | var territotiesData = pixelArea.addBands(object.territory).addBands(object.image) 80 | .reduceRegion({ 81 | reducer: reducer, 82 | geometry: object.geometry, 83 | scale: object.scale, 84 | maxPixels: 1e13 85 | }); 86 | 87 | territotiesData = ee.List(territotiesData.get('groups')); 88 | 89 | var areas = territotiesData.map(Area.convert2table); 90 | 91 | areas = ee.FeatureCollection(areas).flatten() 92 | .map( 93 | function (feature) { 94 | return feature.set("unit", object.unit) 95 | } 96 | ); 97 | 98 | return areas; 99 | } 100 | 101 | }; 102 | 103 | /** 104 | * 105 | */ 106 | var App = { 107 | 108 | options: { 109 | 110 | version: '1.4.0', 111 | 112 | logo: { 113 | uri: 'gs://mapbiomas-public/mapbiomas-logos/mapbiomas-logo-horizontal.b64', 114 | base64: null 115 | }, 116 | 117 | statesNames: { 118 | 'None': 'None', 119 | 'Acre': '12', 120 | 'Alagoas': '27', 121 | 'Amazonas': '13', 122 | 'Amapá': '16', 123 | 'Bahia': '29', 124 | 'Ceará': '23', 125 | 'Distrito Federal': '53', 126 | 'Espírito Santo': '32', 127 | 'Goiás': '52', 128 | 'Maranhão': '21', 129 | 'Minas Gerais': '31', 130 | 'Mato Grosso do Sul': '50', 131 | 'Mato Grosso': '51', 132 | 'Pará': '15', 133 | 'Paraíba': '25', 134 | 'Pernambuco': '26', 135 | 'Piauí': '22', 136 | 'Paraná': '41', 137 | 'Rio de Janeiro': '33', 138 | 'Rio Grande do Norte': '24', 139 | 'Rondônia': '11', 140 | 'Roraima': '14', 141 | 'Rio Grande do Sul': '43', 142 | 'Santa Catarina': '42', 143 | 'Sergipe': '28', 144 | 'São Paulo': '35', 145 | 'Tocantins': '17' 146 | }, 147 | 148 | tables: { 149 | 'mapbiomas-brazil': [ 150 | { 151 | 'label': 'Amacro', 152 | 'value': 'projects/mapbiomas-territories/assets/TERRITORIES/LULC/BRAZIL/COLLECTION9/WORKSPACE/AMACRO', 153 | }, 154 | { 155 | 'label': 'Ministry of the Environment priority areas 2018', 156 | 'value': 'projects/mapbiomas-territories/assets/TERRITORIES/LULC/BRAZIL/COLLECTION9/WORKSPACE/AREAS_PRIORITARIAS_DO_MMA_2018', 157 | }, 158 | { 159 | 'label': 'Atlantic Forest Law', 160 | 'value': 'projects/mapbiomas-territories/assets/TERRITORIES/LULC/BRAZIL/COLLECTION9/WORKSPACE/ATLANTIC_FOREST_LAW', 161 | }, 162 | { 163 | 'label': 'Basin Level 1 DNAEE', 164 | 'value': 'projects/mapbiomas-territories/assets/TERRITORIES/LULC/BRAZIL/COLLECTION9/WORKSPACE/BASIN_LEVEL_1_DNAEE', 165 | }, 166 | { 167 | 'label': 'Basin Level 1 PNRH', 168 | 'value': 'projects/mapbiomas-territories/assets/TERRITORIES/LULC/BRAZIL/COLLECTION9/WORKSPACE/BASIN_LEVEL_1_PNRH', 169 | }, 170 | { 171 | 'label': 'Basin Level 2 DNAEE', 172 | 'value': 'projects/mapbiomas-territories/assets/TERRITORIES/LULC/BRAZIL/COLLECTION9/WORKSPACE/BASIN_LEVEL_2_DNAEE', 173 | }, 174 | { 175 | 'label': 'Basin Level 2 PNRH', 176 | 'value': 'projects/mapbiomas-territories/assets/TERRITORIES/LULC/BRAZIL/COLLECTION9/WORKSPACE/BASIN_LEVEL_2_PNRH', 177 | }, 178 | { 179 | 'label': 'Biomes', 180 | 'value': 'projects/mapbiomas-territories/assets/TERRITORIES/LULC/BRAZIL/COLLECTION9/WORKSPACE/BIOMES', 181 | }, 182 | { 183 | 'label': 'Coastal Marine Zone', 184 | 'value': 'projects/mapbiomas-territories/assets/TERRITORIES/LULC/BRAZIL/COLLECTION9/WORKSPACE/COASTAL_MARINE_ZONE', 185 | }, 186 | { 187 | 'label': 'Forest Concessions', 188 | 'value': 'projects/mapbiomas-territories/assets/TERRITORIES/LULC/BRAZIL/COLLECTION9/WORKSPACE/CONCESSOES_FLORESTAIS', 189 | }, 190 | { 191 | 'label': 'DHN250 Level 1', 192 | 'value': 'projects/mapbiomas-territories/assets/TERRITORIES/LULC/BRAZIL/COLLECTION9/WORKSPACE/DHN250_LEVEL_1', 193 | }, 194 | { 195 | 'label': 'DHN250 Level 2', 196 | 'value': 'projects/mapbiomas-territories/assets/TERRITORIES/LULC/BRAZIL/COLLECTION9/WORKSPACE/DHN250_LEVEL_2', 197 | }, 198 | { 199 | 'label': 'DHN250 Level 3', 200 | 'value': 'projects/mapbiomas-territories/assets/TERRITORIES/LULC/BRAZIL/COLLECTION9/WORKSPACE/DHN250_LEVEL_3', 201 | }, 202 | { 203 | 'label': 'Non-Designated Public Forests', 204 | 'value': 'projects/mapbiomas-territories/assets/TERRITORIES/LULC/BRAZIL/COLLECTION9/WORKSPACE/FLORESTAS_PUBLICAS_NAO_DESTINADAS', 205 | }, 206 | { 207 | 'label': 'Geoparques', 208 | 'value': 'projects/mapbiomas-territories/assets/TERRITORIES/LULC/BRAZIL/COLLECTION9/WORKSPACE/GEOPARQUES', 209 | }, 210 | { 211 | 'label': 'Indigenous Territories', 212 | 'value': 'projects/mapbiomas-territories/assets/TERRITORIES/LULC/BRAZIL/COLLECTION9/WORKSPACE/INDIGENOUS_TERRITORIES', 213 | }, 214 | { 215 | 'label': 'Legal Amazon', 216 | 'value': 'projects/mapbiomas-territories/assets/TERRITORIES/LULC/BRAZIL/COLLECTION9/WORKSPACE/LEGAL_AMAZON', 217 | }, 218 | { 219 | 'label': 'Matopiba', 220 | 'value': 'projects/mapbiomas-territories/assets/TERRITORIES/LULC/BRAZIL/COLLECTION9/WORKSPACE/MATOPIBA', 221 | }, 222 | { 223 | 'label': 'Political Level 1', 224 | 'value': 'projects/mapbiomas-territories/assets/TERRITORIES/LULC/BRAZIL/COLLECTION9/WORKSPACE/POLITICAL_LEVEL_1', 225 | }, 226 | { 227 | 'label': 'Political Level 2', 228 | 'value': 'projects/mapbiomas-territories/assets/TERRITORIES/LULC/BRAZIL/COLLECTION9/WORKSPACE/POLITICAL_LEVEL_2', 229 | }, 230 | { 231 | 'label': 'Political Level 3', 232 | 'value': 'projects/mapbiomas-territories/assets/TERRITORIES/LULC/BRAZIL/COLLECTION9/WORKSPACE/POLITICAL_LEVEL_3', 233 | }, 234 | { 235 | 'label': 'Protected Area', 236 | 'value': 'projects/mapbiomas-territories/assets/TERRITORIES/LULC/BRAZIL/COLLECTION9/WORKSPACE/PROTECTED_AREA', 237 | }, 238 | { 239 | 'label': 'Quilombos', 240 | 'value': 'projects/mapbiomas-territories/assets/TERRITORIES/LULC/BRAZIL/COLLECTION9/WORKSPACE/QUILOMBOS', 241 | }, 242 | { 243 | 'label': 'Biosphere Reserve', 244 | 'value': 'projects/mapbiomas-territories/assets/TERRITORIES/LULC/BRAZIL/COLLECTION9/WORKSPACE/RESERVA_DA_BIOSFERA', 245 | }, 246 | { 247 | 'label': 'Semiarid', 248 | 'value': 'projects/mapbiomas-territories/assets/TERRITORIES/LULC/BRAZIL/COLLECTION9/WORKSPACE/SEMIARID', 249 | }, 250 | { 251 | 'label': 'Settlements', 252 | 'value': 'projects/mapbiomas-territories/assets/TERRITORIES/LULC/BRAZIL/COLLECTION9/WORKSPACE/SETTLEMENTS', 253 | }, 254 | { 255 | 'label': 'UGRHS', 256 | 'value': 'projects/mapbiomas-territories/assets/TERRITORIES/LULC/BRAZIL/COLLECTION9/WORKSPACE/UGRHS', 257 | } 258 | ], 259 | }, 260 | 261 | collections: { 262 | 'mapbiomas-brazil': { 263 | 'collection-6.0': { 264 | 'assets': { 265 | 'pasture_quality': 'projects/mapbiomas-workspace/public/collection6/mapbiomas_collection60_pasture_quality_v1', 266 | // 'pasture': '', 267 | }, 268 | 269 | 'periods': { 270 | 'pasture_quality': [ 271 | '2000', '2001', '2002', '2003', 272 | '2004', '2005', '2006', '2007', 273 | '2008', '2009', '2010', '2011', 274 | '2012', '2013', '2014', '2015', 275 | '2016', '2017', '2018', '2019', 276 | '2020' 277 | ], 278 | 'pasture': [ 279 | '1988', '1989', '1990', '1991', 280 | '1992', '1993', '1994', '1995', 281 | '1996', '1997', '1998', '1999', 282 | '2000', '2001', '2002', '2003', 283 | '2004', '2005', '2006', '2007', 284 | '2008', '2009', '2010', '2011', 285 | '2012', '2013', '2014', '2015', 286 | '2016', '2017', 287 | ], 288 | 289 | }, 290 | }, 291 | 292 | 'collection-7.0': { 293 | 'assets': { 294 | 'pasture_quality': 'projects/mapbiomas-workspace/public/collection7/mapbiomas_collection70_pasture_quality_v2', 295 | // 'pasture': '', 296 | }, 297 | 298 | 'periods': { 299 | 'pasture_quality': [ 300 | '2000', '2001', '2002', '2003', 301 | '2004', '2005', '2006', '2007', 302 | '2008', '2009', '2010', '2011', 303 | '2012', '2013', '2014', '2015', 304 | '2016', '2017', '2018', '2019', 305 | '2020', '2021' 306 | ], 307 | 'pasture': [ 308 | '2000', '2001', '2002', '2003', 309 | '2004', '2005', '2006', '2007', 310 | '2008', '2009', '2010', '2011', 311 | '2012', '2013', '2014', '2015', 312 | '2016', '2017', '2018', '2019', 313 | '2020', '2021' 314 | ], 315 | 316 | }, 317 | }, 318 | 319 | 'collection-8.0': { 320 | 'assets': { 321 | 'pasture_quality': 'projects/mapbiomas-workspace/public/collection8/mapbiomas_collection80_pasture_quality_v1', 322 | // 'pasture': '', 323 | }, 324 | 325 | 'periods': { 326 | 'pasture_quality': [ 327 | '2000', '2001', '2002', '2003', 328 | '2004', '2005', '2006', '2007', 329 | '2008', '2009', '2010', '2011', 330 | '2012', '2013', '2014', '2015', 331 | '2016', '2017', '2018', '2019', 332 | '2020', '2021', '2022' 333 | ], 334 | 'pasture': [ 335 | '2000', '2001', '2002', '2003', 336 | '2004', '2005', '2006', '2007', 337 | '2008', '2009', '2010', '2011', 338 | '2012', '2013', '2014', '2015', 339 | '2016', '2017', '2018', '2019', 340 | '2020', '2021', '2022' 341 | ], 342 | 343 | }, 344 | }, 345 | 'collection-9.0': { 346 | 'assets': { 347 | 'pasture_quality': 'projects/mapbiomas-public/assets/brazil/lulc/collection9/mapbiomas_collection90_pasture_quality_v1', 348 | // 'pasture': '', 349 | }, 350 | 351 | 'periods': { 352 | 'pasture_quality': [ 353 | '2000', '2001', '2002', '2003', 354 | '2004', '2005', '2006', '2007', 355 | '2008', '2009', '2010', '2011', 356 | '2012', '2013', '2014', '2015', 357 | '2016', '2017', '2018', '2019', 358 | '2020', '2021', '2022', '2023' 359 | ], 360 | 'pasture': [ 361 | '2000', '2001', '2002', '2003', 362 | '2004', '2005', '2006', '2007', 363 | '2008', '2009', '2010', '2011', 364 | '2012', '2013', '2014', '2015', 365 | '2016', '2017', '2018', '2019', 366 | '2020', '2021', '2022', '2023' 367 | ], 368 | 369 | }, 370 | }, 371 | }, 372 | 373 | }, 374 | 375 | bandsNames: { //TODO: ajustar o nome das bandas no asset publico 376 | 'pasture_quality': 'pasture_quality', 377 | 378 | }, 379 | 380 | dataType: 'pasture_quality', 381 | 382 | data: { 383 | 'pasture_quality': null, 384 | }, 385 | 386 | fileDimensions: { 387 | 'pasture_quality': 256 * 512, 388 | // 'pasture': 256 * 124, 389 | }, 390 | 391 | ranges: { 392 | 'pasture_quality': { 393 | 'min': 1, 394 | 'max': 3 395 | }, 396 | 'pasture': { 397 | 'min': 0, 398 | 'max': 1 //TODO: ajustar os params min e max para visualização 399 | }, 400 | 401 | }, 402 | 403 | palette: { 404 | 'pasture_quality': [ 405 | '#A61C00', // 1. Low 406 | '#FDAE61', // 2. Medium 407 | '#2D7BB6', // 3. High 408 | ], 409 | 410 | 'pasture': [ 411 | '#ffffff', 412 | '#ffd738', 413 | ], 414 | 415 | }, 416 | 417 | vector: null, 418 | activeFeature: null, 419 | activeName: '', 420 | 421 | taskid: 1, 422 | 423 | bufferDistance: 0, 424 | 425 | className: { 426 | 427 | 'pasture_quality': { 428 | 1: 'Severe degradation', 429 | 2: 'Moderate degradation', 430 | 3: 'Not degraded', 431 | }, 432 | 433 | }, 434 | 435 | legend: { 436 | params: { 437 | "title": 'Legend', 438 | "layers": [ 439 | ['#A61C00', 1, 'Low'], 440 | ['#FDAE61', 2, 'Medium'], 441 | ['#2D7BB6', 3, 'High'], 442 | ], 443 | "style": { 444 | "backgroundColor": "#ffffff", 445 | "color": "#212121" 446 | }, 447 | "orientation": "vertical" 448 | } 449 | } 450 | }, 451 | 452 | init: function () { 453 | 454 | this.ui.init(); 455 | 456 | }, 457 | 458 | setVersion: function () { 459 | 460 | App.ui.form.labelTitle.setValue('MapBiomas User Toolkit - Pasture ' + App.options.version); 461 | 462 | }, 463 | 464 | startMap: function (year) { 465 | 466 | Map.centerObject(App.options.data.pasture_quality, 5); 467 | 468 | var imageLayer = ui.Map.Layer({ 469 | 'eeObject': App.options.data.pasture_quality, 470 | 'visParams': { 471 | 'bands': ['pasture_quality_' + year], 472 | 'palette': App.options.palette.pasture_quality, 473 | 'min': App.options.ranges.pasture_quality.min, 474 | 'max': App.options.ranges.pasture_quality.max, 475 | 'format': 'png' 476 | }, 477 | 'name': 'Pasture', 478 | 'shown': true, 479 | 'opacity': 1.0 480 | }); 481 | 482 | App.ui.clear(); 483 | 484 | Map.add(imageLayer); 485 | 486 | }, 487 | 488 | formatName: function (name) { 489 | 490 | var formated = name 491 | .toLowerCase() 492 | .replace(/á/g, 'a') 493 | .replace(/à/g, 'a') 494 | .replace(/â/g, 'a') 495 | .replace(/ã/g, 'a') 496 | .replace(/ä/g, 'a') 497 | .replace(/ª/g, 'a') 498 | .replace(/é/g, 'e') 499 | .replace(/ê/g, 'e') 500 | .replace(/í/g, 'i') 501 | .replace(/ó/g, 'o') 502 | .replace(/ô/g, 'o') 503 | .replace(/õ/g, 'o') 504 | .replace(/ú/g, 'u') 505 | .replace(/û/g, 'u') 506 | .replace(/ũ/g, 'u') 507 | .replace(/ç/g, 'c') 508 | .replace(/ñ/g, 'n') 509 | .replace(/&/g, '') 510 | .replace(/@/g, '') 511 | .replace(/ /g, '') 512 | .replace(/["'()\/]/g, ''); 513 | 514 | return formated; 515 | }, 516 | 517 | ui: { 518 | 519 | init: function () { 520 | 521 | this.form.init(); 522 | 523 | }, 524 | 525 | clear: function () { 526 | Map.clear(); 527 | 528 | Map.setOptions({ 529 | 'styles': { 530 | 'Dark': mapp.getStyle('Dark') 531 | } 532 | }); 533 | }, 534 | 535 | setMapbiomasRegion: function (regionName) { 536 | 537 | App.ui.loadCollectionList(regionName); 538 | App.ui.loadTablesNames(regionName); 539 | 540 | }, 541 | 542 | setDataType: function (dataType) { 543 | 544 | App.options.dataType = dataType; 545 | 546 | }, 547 | 548 | loadCollectionList: function (regionName) { 549 | 550 | App.ui.form.selectCollection.setPlaceholder('loading collections...'); 551 | 552 | App.ui.form.selectCollection = ui.Select({ 553 | 'items': Object.keys(App.options.collections[regionName]).reverse(), 554 | 'placeholder': 'select collection', 555 | 'onChange': function (collectioName) { 556 | ee.Number(1).evaluate( 557 | function (a) { 558 | 559 | App.options.data.pasture_quality = ee.Image( 560 | App.options.collections[regionName][collectioName].assets.pasture_quality); 561 | 562 | var year = App.options.collections[regionName][collectioName] 563 | .periods.pasture_quality.slice(-1)[0]; 564 | 565 | App.startMap(year); 566 | } 567 | ); 568 | 569 | App.ui.loadingBox(); 570 | }, 571 | 'style': { 572 | 'stretch': 'horizontal' 573 | } 574 | }); 575 | 576 | App.ui.form.panelCollection.widgets() 577 | .set(1, App.ui.form.selectCollection); 578 | 579 | }, 580 | 581 | loadTablesNames: function (regionName) { 582 | 583 | App.ui.form.selectRegion.setPlaceholder('loading tables names...'); 584 | 585 | var roots = ee.data.getAssetRoots() 586 | .map( 587 | function (obj) { 588 | return obj.id; 589 | }); 590 | 591 | var allTablesNames; 592 | 593 | /** 594 | * Skip the error msg if MAPBIOMAS folder is not found 595 | */ 596 | try { 597 | var tablesNames = ee.data.getList({ 598 | 'id': roots[0] + '/MAPBIOMAS' 599 | }).map( 600 | function (obj) { 601 | return obj.id; 602 | }); 603 | var allTablesNames = App.options.tables[regionName].concat(tablesNames); 604 | } 605 | catch (e) { 606 | var allTablesNames = App.options.tables[regionName]; 607 | } 608 | 609 | App.ui.form.selectFeatureCollections = ui.Select({ 610 | 'items': allTablesNames, 611 | 'placeholder': 'select table', 612 | 'onChange': function (tableName) { 613 | if (tableName != 'None') { 614 | App.options.activeName = tableName; 615 | App.ui.form.panelStates.remove(App.ui.form.labelStates); 616 | App.ui.form.panelStates.remove(App.ui.form.selectStates); 617 | ee.Number(1).evaluate( 618 | function (a) { 619 | var collectioName = App.ui.form.selectCollection.getValue(); 620 | 621 | App.ui.loadTable(tableName); 622 | 623 | App.ui.makeLayersList( 624 | tableName.split('/').slice(-1)[0], 625 | App.options.activeFeature, 626 | App.options.collections[regionName][collectioName] 627 | .periods[App.options.dataType] 628 | ); 629 | 630 | App.ui.loadPropertiesNames(); 631 | 632 | App.ui.form.selectDataType.setDisabled(false); 633 | } 634 | ); 635 | 636 | App.ui.loadingBox(); 637 | } 638 | }, 639 | 'style': { 640 | 'stretch': 'horizontal' 641 | } 642 | }); 643 | 644 | App.ui.form.panelFeatureCollections.widgets() 645 | .set(1, App.ui.form.selectFeatureCollections); 646 | 647 | }, 648 | 649 | loadTableStates: function (tableName) { 650 | 651 | var state = App.ui.form.selectStates.getValue(); 652 | 653 | App.options.table = ee.FeatureCollection(tableName) 654 | .filterMetadata('UF', 'equals', parseInt(App.options.statesNames[state], 10)); 655 | 656 | App.options.activeFeature = App.options.table; 657 | 658 | Map.centerObject(App.options.activeFeature); 659 | 660 | App.ui.clear(); 661 | 662 | Map.addLayer(App.options.activeFeature.style({ 663 | color: 'ff0000', 664 | width: 1, 665 | fillColor: 'ff000033', 666 | }), {}, 667 | tableName.split('/')[3], 668 | true); 669 | 670 | }, 671 | 672 | loadTable: function (tableName) { 673 | 674 | App.options.table = ee.FeatureCollection(tableName); 675 | 676 | App.options.activeFeature = App.options.table; 677 | 678 | // Map.centerObject(App.options.activeFeature); 679 | 680 | App.ui.clear(); 681 | 682 | Map.addLayer(App.options.activeFeature.style({ 683 | color: 'ff0000', 684 | width: 1, 685 | fillColor: 'ff000033', 686 | }), {}, 687 | tableName.split('/')[3], 688 | true); 689 | 690 | }, 691 | 692 | loadPropertiesNames: function () { 693 | 694 | App.ui.form.selectProperties.setPlaceholder('loading tables names...'); 695 | 696 | ee.Feature(App.options.table.first()) 697 | .propertyNames() 698 | .evaluate( 699 | function (propertyNames) { 700 | 701 | // print(propertyNames); 702 | 703 | App.ui.form.selectProperties = ui.Select({ 704 | 'items': propertyNames, 705 | 'placeholder': 'select property', 706 | 'onChange': function (propertyName) { 707 | if (propertyName != 'None') { 708 | App.options.propertyName = propertyName; 709 | 710 | ee.Number(1).evaluate( 711 | function (a) { 712 | App.ui.loadFeatureNames(propertyName); 713 | App.ui.form.selectDataType.setDisabled(false); 714 | } 715 | ); 716 | 717 | } 718 | }, 719 | 'style': { 720 | 'stretch': 'horizontal' 721 | } 722 | }); 723 | 724 | App.ui.form.panelProperties.widgets() 725 | .set(1, App.ui.form.selectProperties); 726 | } 727 | ); 728 | 729 | }, 730 | 731 | loadFeatureNames: function () { 732 | 733 | App.ui.form.selectFeature.setPlaceholder('loading feature names...'); 734 | 735 | App.options.table.sort(App.options.propertyName) 736 | .reduceColumns(ee.Reducer.toList(), [App.options.propertyName]) 737 | .get('list') 738 | .evaluate( 739 | function (featureNameList) { 740 | 741 | App.ui.form.selectFeature = ui.Select({ 742 | 'items': featureNameList, 743 | 'placeholder': 'select feature', 744 | 'onChange': function (featureName) { 745 | if (featureName != 'None') { 746 | App.options.featureName = featureName; 747 | 748 | ee.Number(1).evaluate( 749 | function (a) { 750 | var regionName = App.ui.form.selectRegion.getValue(); 751 | var collectionName = App.ui.form.selectCollection.getValue(); 752 | 753 | App.ui.loadFeature(featureName); 754 | 755 | App.ui.makeLayersList( 756 | featureName, 757 | App.options.activeFeature, 758 | App.options.collections[regionName][collectionName] 759 | .periods[App.options.dataType]); 760 | App.ui.form.selectDataType.setDisabled(false); 761 | } 762 | ); 763 | 764 | App.ui.loadingBox(); 765 | } 766 | }, 767 | 'style': { 768 | 'stretch': 'horizontal' 769 | } 770 | }); 771 | 772 | App.ui.form.panelFeature.widgets() 773 | .set(1, App.ui.form.selectFeature); 774 | } 775 | ); 776 | 777 | }, 778 | 779 | loadFeature: function (name) { 780 | 781 | App.options.activeFeature = App.options.table 782 | .filterMetadata(App.options.propertyName, 'equals', name); 783 | 784 | Map.centerObject(App.options.activeFeature); 785 | 786 | App.ui.clear(); 787 | 788 | Map.addLayer(App.options.activeFeature.style({ 789 | color: 'ff0000', 790 | width: 1, 791 | fillColor: 'ff000033', 792 | }), {}, 793 | name, 794 | true); 795 | 796 | }, 797 | 798 | addImageLayer: function (period, label, region) { 799 | 800 | 801 | var image = App.options.data[App.options.dataType] 802 | .select([App.options.bandsNames[App.options.dataType] + '_' + period]) 803 | .clip(region); 804 | 805 | var imageLayer = ui.Map.Layer({ 806 | 'eeObject': image.selfMask(), 807 | 'visParams': { 808 | 'palette': App.options.palette[App.options.dataType], 809 | 'min': App.options.ranges[App.options.dataType].min, 810 | 'max': App.options.ranges[App.options.dataType].max, 811 | 'format': 'png' 812 | }, 813 | 'name': label, 814 | 'shown': true, 815 | 'opacity': 1.0 816 | }); 817 | 818 | Map.layers().insert( 819 | Map.layers().length() - 1, 820 | imageLayer 821 | ); 822 | 823 | }, 824 | 825 | removeImageLayer: function (label) { 826 | 827 | for (var i = 0; i < Map.layers().length(); i++) { 828 | 829 | var layer = Map.layers().get(i); 830 | 831 | if (label === layer.get('name')) { 832 | Map.remove(layer); 833 | } 834 | } 835 | 836 | }, 837 | 838 | manageLayers: function (checked, period, label, region) { 839 | 840 | if (checked) { 841 | App.ui.addImageLayer(period, label, region); 842 | } else { 843 | App.ui.removeImageLayer(label); 844 | } 845 | 846 | }, 847 | 848 | makeLayersList: function (regionName, region, periods) { 849 | // print(regionName, region, periods) 850 | App.ui.form.panelLayersList.clear(); 851 | 852 | periods.forEach( 853 | 854 | function (period, index, array) { 855 | App.ui.form.panelLayersList.add( 856 | ui.Checkbox({ 857 | "label": regionName + ' ' + period, 858 | "value": false, 859 | "onChange": function (checked) { 860 | 861 | App.ui.manageLayers(checked, period, regionName + ' ' + period, region); 862 | 863 | }, 864 | "disabled": false, 865 | "style": { 866 | 'padding': '2px', 867 | 'stretch': 'horizontal', 868 | 'backgroundColor': '#dddddd', 869 | 'fontSize': '12px' 870 | } 871 | }) 872 | ); 873 | 874 | } 875 | ); 876 | 877 | }, 878 | 879 | loadingBox: function () { 880 | App.ui.form.loadingBox = ui.Panel(); 881 | App.ui.form.loadingBox.add(ui.Label('Loading...')); 882 | 883 | Map.add(App.ui.form.loadingBox); 884 | }, 885 | 886 | export2Drive: function () { 887 | 888 | var layers = App.ui.form.panelLayersList.widgets(); 889 | 890 | var regionName = App.ui.form.selectRegion.getValue(); 891 | var collectionName = App.ui.form.selectCollection.getValue(); 892 | 893 | var featureName = App.formatName(App.ui.form.selectFeature.getValue() || ''); 894 | 895 | var bandIds = []; 896 | 897 | for (var i = 0; i < layers.length(); i++) { 898 | 899 | var selected = layers.get(i).getValue(); 900 | 901 | if (selected) { 902 | 903 | var period = App.options.collections[regionName][collectionName] 904 | .periods[App.options.dataType][i]; 905 | 906 | var fileName = [regionName, collectionName, App.options.dataType, featureName, period].join('-'); 907 | 908 | fileName = fileName.replace(/--/g, '-').replace(/--/g, '-').replace('.', '').replace('_', '-'); 909 | fileName = App.formatName(fileName); 910 | 911 | var data = App.options.data[App.options.dataType] 912 | .select([App.options.bandsNames[App.options.dataType] + '_' + period]); 913 | 914 | var region = App.options.activeFeature.geometry(); 915 | 916 | if (App.options.bufferDistance !== 0) { 917 | data = data.clip(App.options.activeFeature.geometry().buffer(App.options.bufferDistance)); 918 | region = region.buffer(App.options.bufferDistance); 919 | } else { 920 | data = data.clip(App.options.activeFeature.geometry()); 921 | } 922 | 923 | region = region.bounds(); 924 | 925 | Export.image.toDrive({ 926 | image: data, 927 | description: fileName, 928 | folder: 'MAPBIOMAS-EXPORT', 929 | fileNamePrefix: fileName, 930 | region: region, 931 | scale: 30, 932 | maxPixels: 1e13, 933 | fileFormat: 'GeoTIFF', 934 | fileDimensions: App.options.fileDimensions[App.options.dataType], 935 | }); 936 | 937 | bandIds.push(App.options.bandsNames[App.options.dataType] + '_' + period); 938 | } 939 | } 940 | 941 | // Export table 942 | var territory = ee.Image().paint({ 943 | 'featureCollection': ee.FeatureCollection(App.options.activeFeature), 944 | 'color': 1 945 | }); 946 | 947 | var geometry = App.options.activeFeature.geometry().bounds(); 948 | 949 | var areas = bandIds.map( 950 | function (band) { 951 | 952 | var image = App.options.data[App.options.dataType].select(band); 953 | 954 | var area = Area.calculate({ 955 | "image": image, 956 | "territory": territory, 957 | "geometry": geometry, 958 | "scale": 30, 959 | "factor": 1000000, 960 | "unit": 'kilometers^2' 961 | }); 962 | 963 | area = ee.FeatureCollection(area).map( 964 | function (feature) { 965 | 966 | var className = ee.Dictionary(App.options.className[App.options.dataType]) 967 | .get(ee.Number(feature.get('class'))); 968 | 969 | return feature 970 | .set('class_name', className) 971 | .set('band', band); 972 | } 973 | ); 974 | 975 | return area; 976 | } 977 | ); 978 | 979 | areas = ee.FeatureCollection(areas).flatten(); 980 | // print(areas); 981 | 982 | var tableName = [regionName, collectionName, App.options.dataType, featureName, 'area'].join('-'); 983 | 984 | tableName = tableName.replace(/--/g, '-').replace(/--/g, '-').replace('.', '').replace('_', '-'); 985 | tableName = App.formatName(tableName); 986 | 987 | Export.table.toDrive({ 988 | 'collection': areas, 989 | 'description': tableName, 990 | 'folder': 'MAPBIOMAS-EXPORT', 991 | 'fileNamePrefix': tableName, 992 | 'fileFormat': 'CSV' 993 | }); 994 | 995 | }, 996 | 997 | form: { 998 | 999 | init: function () { 1000 | 1001 | var blob = ee.Blob(App.options.logo.uri); 1002 | 1003 | blob.string().evaluate( 1004 | function (str) { 1005 | str = str.replace(/\n/g, ''); 1006 | App.options.logo.base64 = ui.Label({ 1007 | imageUrl: str, 1008 | }); 1009 | App.ui.form.panelLogo.add(App.options.logo.base64); 1010 | } 1011 | ); 1012 | 1013 | App.ui.form.panelMain.add(App.ui.form.panelLogo); 1014 | App.ui.form.panelMain.add(App.ui.form.labelTitle); 1015 | App.ui.form.panelMain.add(App.ui.form.labelSubtitle); 1016 | App.ui.form.panelMain.add(App.ui.form.labelLink); 1017 | 1018 | App.ui.form.panelRegion.add(App.ui.form.labelRegion); 1019 | App.ui.form.panelRegion.add(App.ui.form.selectRegion); 1020 | 1021 | App.ui.form.panelCollection.add(App.ui.form.labelCollection); 1022 | App.ui.form.panelCollection.add(App.ui.form.selectCollection); 1023 | 1024 | App.ui.form.panelFeatureCollections.add(App.ui.form.labelTables); 1025 | App.ui.form.panelFeatureCollections.add(App.ui.form.selectFeatureCollections); 1026 | 1027 | App.ui.form.panelProperties.add(App.ui.form.labelProperties); 1028 | App.ui.form.panelProperties.add(App.ui.form.selectProperties); 1029 | 1030 | App.ui.form.panelFeature.add(App.ui.form.labelFeature); 1031 | App.ui.form.panelFeature.add(App.ui.form.selectFeature); 1032 | 1033 | App.ui.form.panelDataType.add(App.ui.form.labelDataType); 1034 | App.ui.form.panelDataType.add(App.ui.form.selectDataType); 1035 | 1036 | App.ui.form.panelBuffer.add(App.ui.form.labelBuffer); 1037 | App.ui.form.panelBuffer.add(App.ui.form.selectBuffer); 1038 | 1039 | App.ui.form.panelLegend.add(legend.getLegend(App.options.legend.params)); 1040 | 1041 | // this.panelMain.add(this.panelType); 1042 | App.ui.form.panelMain.add(App.ui.form.panelRegion); 1043 | App.ui.form.panelMain.add(App.ui.form.panelCollection); 1044 | App.ui.form.panelMain.add(App.ui.form.panelFeatureCollections); 1045 | App.ui.form.panelMain.add(App.ui.form.panelStates); 1046 | App.ui.form.panelMain.add(App.ui.form.panelProperties); 1047 | App.ui.form.panelMain.add(App.ui.form.panelFeature); 1048 | App.ui.form.panelMain.add(App.ui.form.panelDataType); 1049 | App.ui.form.panelMain.add(App.ui.form.panelLegend); 1050 | App.ui.form.panelMain.add(App.ui.form.panelBuffer); 1051 | 1052 | App.ui.form.panelMain.add(App.ui.form.labelLayers); 1053 | App.ui.form.panelMain.add(App.ui.form.panelLayersList); 1054 | 1055 | App.ui.form.panelMain.add(App.ui.form.buttonExport2Drive); 1056 | App.ui.form.panelMain.add(App.ui.form.labelNotes); 1057 | 1058 | ui.root.add(App.ui.form.panelMain); 1059 | 1060 | }, 1061 | 1062 | panelMain: ui.Panel({ 1063 | 'layout': ui.Panel.Layout.flow('vertical'), 1064 | 'style': { 1065 | 'width': '360px', 1066 | 'position': 'bottom-left', 1067 | 'margin': '0px 0px 0px 0px', 1068 | }, 1069 | }), 1070 | 1071 | panelLogo: ui.Panel({ 1072 | 'layout': ui.Panel.Layout.flow('vertical'), 1073 | 'style': { 1074 | 'stretch': 'horizontal', 1075 | 'margin': '10px 0px 5px 15px', 1076 | }, 1077 | }), 1078 | 1079 | panelStates: ui.Panel({ 1080 | 'layout': ui.Panel.Layout.flow('vertical'), 1081 | 'style': { 1082 | 'stretch': 'horizontal' 1083 | }, 1084 | }), 1085 | 1086 | panelRegion: ui.Panel({ 1087 | 'layout': ui.Panel.Layout.flow('vertical'), 1088 | 'style': { 1089 | 'stretch': 'horizontal' 1090 | }, 1091 | }), 1092 | 1093 | panelCollection: ui.Panel({ 1094 | 'layout': ui.Panel.Layout.flow('vertical'), 1095 | 'style': { 1096 | 'stretch': 'horizontal' 1097 | }, 1098 | }), 1099 | 1100 | panelFeatureCollections: ui.Panel({ 1101 | 'layout': ui.Panel.Layout.flow('vertical'), 1102 | 'style': { 1103 | 'stretch': 'horizontal' 1104 | }, 1105 | }), 1106 | 1107 | panelProperties: ui.Panel({ 1108 | 'layout': ui.Panel.Layout.flow('vertical'), 1109 | 'style': { 1110 | 'stretch': 'horizontal' 1111 | }, 1112 | }), 1113 | 1114 | panelFeature: ui.Panel({ 1115 | 'layout': ui.Panel.Layout.flow('vertical'), 1116 | 'style': { 1117 | 'stretch': 'horizontal' 1118 | }, 1119 | }), 1120 | 1121 | panelDataType: ui.Panel({ 1122 | 'layout': ui.Panel.Layout.flow('vertical'), 1123 | 'style': { 1124 | 'stretch': 'horizontal' 1125 | }, 1126 | }), 1127 | 1128 | panelLegend: ui.Panel({ 1129 | 'layout': ui.Panel.Layout.flow('vertical'), 1130 | 'style': { 1131 | 'stretch': 'vertical', 1132 | 'position': 'bottom-left' 1133 | }, 1134 | }), 1135 | 1136 | panelBuffer: ui.Panel({ 1137 | 'layout': ui.Panel.Layout.flow('vertical'), 1138 | 'style': { 1139 | 'stretch': 'horizontal' 1140 | }, 1141 | }), 1142 | 1143 | panelLayersList: ui.Panel({ 1144 | 'layout': ui.Panel.Layout.flow('vertical'), 1145 | 'style': { 1146 | 'height': '200px', 1147 | 'stretch': 'vertical', 1148 | 'backgroundColor': '#cccccc', 1149 | }, 1150 | }), 1151 | 1152 | labelRegion: ui.Label('Region', { 1153 | // 'fontWeight': 'bold', 1154 | // 'padding': '1px', 1155 | 'fontSize': '16px' 1156 | }), 1157 | 1158 | labelCollection: ui.Label('Collection', { 1159 | // 'fontWeight': 'bold', 1160 | // 'padding': '1px', 1161 | 'fontSize': '16px' 1162 | }), 1163 | 1164 | labelTitle: ui.Label('MapBiomas User Toolkit - Pasture ', { 1165 | 'fontWeight': 'bold', 1166 | // 'padding': '1px', 1167 | 'fontSize': '16px' 1168 | }), 1169 | 1170 | labelSubtitle: ui.Label('Pasture Collection 9.0', { 1171 | // 'fontWeight': 'bold', 1172 | // 'padding': '1px', 1173 | 'fontSize': '14px' 1174 | }), 1175 | 1176 | labelLink: ui.Label('Legend codes', { 1177 | // 'fontWeight': 'bold', 1178 | // 'padding': '1px', 1179 | 'fontSize': '10px' 1180 | }, 1181 | 'https://mapbiomas.org/codigos-de-legenda?cama_set_language=pt-BR' 1182 | ), 1183 | 1184 | labelType: ui.Label('Type:', { 1185 | // 'padding': '1px', 1186 | 'fontSize': '16px' 1187 | }), 1188 | 1189 | labelTables: ui.Label('Tables:', { 1190 | // 'padding': '1px', 1191 | 'fontSize': '16px' 1192 | }), 1193 | 1194 | labelProperties: ui.Label('Properties:', { 1195 | // 'padding': '1px', 1196 | 'fontSize': '16px' 1197 | }), 1198 | 1199 | labelFeature: ui.Label('Features:', { 1200 | // 'padding': '1px', 1201 | 'fontSize': '16px' 1202 | }), 1203 | 1204 | labelDataType: ui.Label('Data Type:', { 1205 | // 'padding': '1px', 1206 | 'fontSize': '16px' 1207 | }), 1208 | 1209 | labelBuffer: ui.Label('Buffer:', { 1210 | // 'padding': '1px', 1211 | 'fontSize': '16px' 1212 | }), 1213 | 1214 | labelLayers: ui.Label('Layers:', { 1215 | // 'padding': '1px', 1216 | 'fontSize': '16px' 1217 | }), 1218 | 1219 | labelNotes: ui.Label('Go to TASK tab in the up-rght corner and click RUN', { 1220 | // 'padding': '1px', 1221 | 'fontSize': '16px' 1222 | }), 1223 | 1224 | labelStates: ui.Label('States:', { 1225 | // 'padding': '1px', 1226 | 'fontSize': '16px' 1227 | }), 1228 | 1229 | selectName: ui.Select({ 1230 | 'items': ['None'], 1231 | 'placeholder': 'None', 1232 | 'style': { 1233 | 'stretch': 'horizontal' 1234 | } 1235 | }), 1236 | 1237 | selectCollection: ui.Select({ 1238 | 'items': [], 1239 | 'placeholder': 'None', 1240 | 'style': { 1241 | 'stretch': 'horizontal' 1242 | }, 1243 | }), 1244 | 1245 | selectRegion: ui.Select({ 1246 | 'items': [ 1247 | // 'mapbiomas-amazon', 1248 | // 'mapbiomas-atlantic-forest', 1249 | 'mapbiomas-brazil', 1250 | // 'mapbiomas-chaco', 1251 | // 'mapbiomas-indonesia', 1252 | // 'mapbiomas-pampa', 1253 | ], 1254 | 'placeholder': 'None', 1255 | 'style': { 1256 | 'stretch': 'horizontal' 1257 | }, 1258 | 'onChange': function (region) { 1259 | 1260 | ee.Number(1).evaluate( 1261 | function (a) { 1262 | App.ui.setMapbiomasRegion(region); 1263 | } 1264 | ); 1265 | 1266 | }, 1267 | }), 1268 | 1269 | selectFeatureCollections: ui.Select({ 1270 | 'items': ['None'], 1271 | 'placeholder': 'None', 1272 | 'style': { 1273 | 'stretch': 'horizontal' 1274 | } 1275 | }), 1276 | 1277 | selectFeature: ui.Select({ 1278 | 'items': ['None'], 1279 | 'placeholder': 'None', 1280 | 'style': { 1281 | 'stretch': 'horizontal' 1282 | } 1283 | }), 1284 | 1285 | selectProperties: ui.Select({ 1286 | 'items': ['None'], 1287 | 'placeholder': 'None', 1288 | 'style': { 1289 | 'stretch': 'horizontal' 1290 | } 1291 | }), 1292 | 1293 | selectDataType: ui.Select({ 1294 | 'items': [ 1295 | 'pasture_quality', 1296 | // 'pasture', 1297 | ], 1298 | 'placeholder': 'Data type', 1299 | 'style': { 1300 | 'stretch': 'horizontal' 1301 | }, 1302 | 'disabled': true, 1303 | 'onChange': function (dataType) { 1304 | 1305 | var regionName = App.ui.form.selectRegion.getValue(); 1306 | var collectionName = App.ui.form.selectCollection.getValue(); 1307 | 1308 | App.ui.setDataType(dataType); 1309 | 1310 | App.ui.makeLayersList( 1311 | App.options.activeName.split('/').slice(-1)[0], 1312 | App.options.activeFeature, 1313 | App.options.collections[regionName][collectionName].periods[dataType]); 1314 | 1315 | }, 1316 | }), 1317 | 1318 | selectBuffer: ui.Select({ 1319 | 'items': [ 1320 | 'None', 1321 | '1km', 1322 | '2km', 1323 | '3km', 1324 | '4km', 1325 | '5km', 1326 | ], 1327 | 'placeholder': 'None', 1328 | 'style': { 1329 | 'stretch': 'horizontal' 1330 | }, 1331 | 'onChange': function (distance) { 1332 | var distances = { 1333 | 'None': 0, 1334 | '1km': 1000, 1335 | '2km': 2000, 1336 | '3km': 3000, 1337 | '4km': 4000, 1338 | '5km': 5000, 1339 | }; 1340 | 1341 | App.options.bufferDistance = distances[distance]; 1342 | }, 1343 | }), 1344 | 1345 | selectStates: ui.Select({ 1346 | 'items': [ 1347 | 'None', 'Acre', 'Alagoas', 'Amazonas', 'Amapá', 'Bahia', 1348 | 'Ceará', 'Distrito Federal', 'Espírito Santo', 'Goiás', 'Maranhão', 1349 | 'Minas Gerais', 'Mato Grosso do Sul', 'Mato Grosso', 'Pará', 'Paraíba', 1350 | 'Pernambuco', 'Piauí', 'Paraná', 'Rio de Janeiro', 'Rio Grande do Norte', 1351 | 'Rondônia', 'Roraima', 'Rio Grande do Sul', 'Santa Catarina', 'Sergipe', 1352 | 'São Paulo', 'Tocantins' 1353 | ], 1354 | 'placeholder': 'select state', 1355 | 'onChange': function (state) { 1356 | if (state != 'None') { 1357 | 1358 | ee.Number(1).evaluate( 1359 | function (a) { 1360 | App.ui.loadTableStates(App.options.activeName); 1361 | App.ui.makeLayersList(App.options.activeName.split('/')[3], App.options.activeFeature, App.options.periods[App.options.dataType]); 1362 | App.ui.loadPropertiesNames(); 1363 | App.ui.form.selectDataType.setDisabled(false); 1364 | } 1365 | ); 1366 | 1367 | App.ui.loadingBox(); 1368 | } 1369 | }, 1370 | 'style': { 1371 | 'stretch': 'horizontal' 1372 | } 1373 | }), 1374 | 1375 | buttonExport2Drive: ui.Button({ 1376 | "label": "Export images to Google Drive", 1377 | "onClick": function () { 1378 | App.ui.export2Drive(); 1379 | }, 1380 | "disabled": false, 1381 | "style": { 1382 | // 'padding': '2px', 1383 | 'stretch': 'horizontal' 1384 | } 1385 | }), 1386 | 1387 | }, 1388 | } 1389 | }; 1390 | 1391 | App.init(); 1392 | 1393 | App.setVersion(); -------------------------------------------------------------------------------- /mapbiomas-user-toolkit-irrigation.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @name 3 | * Mapbiomas User Toolkit Download 4 | * 5 | * @description 6 | * This is a support tool for mapbiomas data users. 7 | * 8 | * @author 9 | * João Siqueira 10 | * contato@mapbiomas.org 11 | * 12 | * @version 13 | * 1.0.0 - First release 14 | * 1.1.0 - Irrigated Agriculture - Collection 6.0 15 | * 1.2.0 - Irrigated Agriculture - Collection 7.0 16 | * 1.3.0 - Irrigated Agriculture - Collection 8.0 17 | * 1.3.1 - Minor issues 18 | * 1.4.0 - Irrigated Agriculture - Collection 8.0 19 | * 20 | * @see 21 | * Get the MapBiomas exported data in your "Google Drive/MAPBIOMAS-EXPORT" folder 22 | * Code and Tutorial - https://github.com/mapbiomas-brazil/user-toolkit 23 | */ 24 | 25 | var palettes = require('users/mapbiomas/modules:Palettes.js'); 26 | var logos = require('users/mapbiomas/modules:Logos.js'); 27 | var mapp = require('users/joaovsiqueira1/packages:Mapp.js'); 28 | var legend = require('users/joaovsiqueira1/packages:Legend.js'); 29 | 30 | /** 31 | * @description 32 | * calculate area for mapbiomas map 33 | * 34 | * @author 35 | * João Siqueira 36 | * 37 | */ 38 | var Area = { 39 | 40 | /** 41 | * Convert a complex obj to feature collection 42 | * @param obj 43 | */ 44 | convert2table: function (obj) { 45 | 46 | obj = ee.Dictionary(obj); 47 | 48 | var classesAndAreas = ee.List(obj.get('groups')); 49 | 50 | var tableRows = classesAndAreas.map( 51 | function (classAndArea) { 52 | classAndArea = ee.Dictionary(classAndArea); 53 | 54 | var classId = classAndArea.get('class'); 55 | var area = classAndArea.get('sum'); 56 | 57 | var tableColumns = ee.Feature(null) 58 | .set('class', classId) 59 | .set('area', area); 60 | 61 | return tableColumns; 62 | } 63 | ); 64 | 65 | return ee.FeatureCollection(ee.List(tableRows)); 66 | }, 67 | 68 | /** 69 | * Calculate area crossing a cover map (deforestation, mapbiomas) 70 | * and a region map (states, biomes, municipalites) 71 | * @param image 72 | * @param territory 73 | * @param geometry 74 | * @param scale 75 | * @param factor 76 | */ 77 | calculate: function (object) { 78 | 79 | var reducer = ee.Reducer.sum().group(1, 'class').group(1, 'territory'); 80 | var pixelArea = ee.Image.pixelArea().divide(object.factor); 81 | 82 | var territotiesData = pixelArea.addBands(object.territory).addBands(object.image) 83 | .reduceRegion({ 84 | reducer: reducer, 85 | geometry: object.geometry, 86 | scale: object.scale, 87 | maxPixels: 1e13 88 | }); 89 | 90 | territotiesData = ee.List(territotiesData.get('groups')); 91 | 92 | var areas = territotiesData.map(Area.convert2table); 93 | 94 | areas = ee.FeatureCollection(areas).flatten() 95 | .map( 96 | function (feature) { 97 | return feature.set("unit", object.unit) 98 | } 99 | ); 100 | 101 | return areas; 102 | } 103 | 104 | }; 105 | 106 | /** 107 | * 108 | */ 109 | var App = { 110 | 111 | options: { 112 | 113 | version: '1.4.0', 114 | 115 | logo: { 116 | uri: 'gs://mapbiomas-public/mapbiomas-logos/mapbiomas-logo-horizontal.b64', 117 | base64: null 118 | }, 119 | 120 | statesNames: { 121 | 'None': 'None', 122 | 'Acre': '12', 123 | 'Alagoas': '27', 124 | 'Amazonas': '13', 125 | 'Amapá': '16', 126 | 'Bahia': '29', 127 | 'Ceará': '23', 128 | 'Distrito Federal': '53', 129 | 'Espírito Santo': '32', 130 | 'Goiás': '52', 131 | 'Maranhão': '21', 132 | 'Minas Gerais': '31', 133 | 'Mato Grosso do Sul': '50', 134 | 'Mato Grosso': '51', 135 | 'Pará': '15', 136 | 'Paraíba': '25', 137 | 'Pernambuco': '26', 138 | 'Piauí': '22', 139 | 'Paraná': '41', 140 | 'Rio de Janeiro': '33', 141 | 'Rio Grande do Norte': '24', 142 | 'Rondônia': '11', 143 | 'Roraima': '14', 144 | 'Rio Grande do Sul': '43', 145 | 'Santa Catarina': '42', 146 | 'Sergipe': '28', 147 | 'São Paulo': '35', 148 | 'Tocantins': '17' 149 | }, 150 | 151 | tables: { 152 | 'mapbiomas-brazil': [ 153 | { 154 | 'label': 'Amacro', 155 | 'value': 'projects/mapbiomas-territories/assets/TERRITORIES/LULC/BRAZIL/COLLECTION9/WORKSPACE/AMACRO', 156 | }, 157 | { 158 | 'label': 'Ministry of the Environment priority areas 2018', 159 | 'value': 'projects/mapbiomas-territories/assets/TERRITORIES/LULC/BRAZIL/COLLECTION9/WORKSPACE/AREAS_PRIORITARIAS_DO_MMA_2018', 160 | }, 161 | { 162 | 'label': 'Atlantic Forest Law', 163 | 'value': 'projects/mapbiomas-territories/assets/TERRITORIES/LULC/BRAZIL/COLLECTION9/WORKSPACE/ATLANTIC_FOREST_LAW', 164 | }, 165 | { 166 | 'label': 'Basin Level 1 DNAEE', 167 | 'value': 'projects/mapbiomas-territories/assets/TERRITORIES/LULC/BRAZIL/COLLECTION9/WORKSPACE/BASIN_LEVEL_1_DNAEE', 168 | }, 169 | { 170 | 'label': 'Basin Level 1 PNRH', 171 | 'value': 'projects/mapbiomas-territories/assets/TERRITORIES/LULC/BRAZIL/COLLECTION9/WORKSPACE/BASIN_LEVEL_1_PNRH', 172 | }, 173 | { 174 | 'label': 'Basin Level 2 DNAEE', 175 | 'value': 'projects/mapbiomas-territories/assets/TERRITORIES/LULC/BRAZIL/COLLECTION9/WORKSPACE/BASIN_LEVEL_2_DNAEE', 176 | }, 177 | { 178 | 'label': 'Basin Level 2 PNRH', 179 | 'value': 'projects/mapbiomas-territories/assets/TERRITORIES/LULC/BRAZIL/COLLECTION9/WORKSPACE/BASIN_LEVEL_2_PNRH', 180 | }, 181 | { 182 | 'label': 'Biomes', 183 | 'value': 'projects/mapbiomas-territories/assets/TERRITORIES/LULC/BRAZIL/COLLECTION9/WORKSPACE/BIOMES', 184 | }, 185 | { 186 | 'label': 'Coastal Marine Zone', 187 | 'value': 'projects/mapbiomas-territories/assets/TERRITORIES/LULC/BRAZIL/COLLECTION9/WORKSPACE/COASTAL_MARINE_ZONE', 188 | }, 189 | { 190 | 'label': 'Forest Concessions', 191 | 'value': 'projects/mapbiomas-territories/assets/TERRITORIES/LULC/BRAZIL/COLLECTION9/WORKSPACE/CONCESSOES_FLORESTAIS', 192 | }, 193 | { 194 | 'label': 'DHN250 Level 1', 195 | 'value': 'projects/mapbiomas-territories/assets/TERRITORIES/LULC/BRAZIL/COLLECTION9/WORKSPACE/DHN250_LEVEL_1', 196 | }, 197 | { 198 | 'label': 'DHN250 Level 2', 199 | 'value': 'projects/mapbiomas-territories/assets/TERRITORIES/LULC/BRAZIL/COLLECTION9/WORKSPACE/DHN250_LEVEL_2', 200 | }, 201 | { 202 | 'label': 'DHN250 Level 3', 203 | 'value': 'projects/mapbiomas-territories/assets/TERRITORIES/LULC/BRAZIL/COLLECTION9/WORKSPACE/DHN250_LEVEL_3', 204 | }, 205 | { 206 | 'label': 'Non-Designated Public Forests', 207 | 'value': 'projects/mapbiomas-territories/assets/TERRITORIES/LULC/BRAZIL/COLLECTION9/WORKSPACE/FLORESTAS_PUBLICAS_NAO_DESTINADAS', 208 | }, 209 | { 210 | 'label': 'Geoparques', 211 | 'value': 'projects/mapbiomas-territories/assets/TERRITORIES/LULC/BRAZIL/COLLECTION9/WORKSPACE/GEOPARQUES', 212 | }, 213 | { 214 | 'label': 'Indigenous Territories', 215 | 'value': 'projects/mapbiomas-territories/assets/TERRITORIES/LULC/BRAZIL/COLLECTION9/WORKSPACE/INDIGENOUS_TERRITORIES', 216 | }, 217 | { 218 | 'label': 'Legal Amazon', 219 | 'value': 'projects/mapbiomas-territories/assets/TERRITORIES/LULC/BRAZIL/COLLECTION9/WORKSPACE/LEGAL_AMAZON', 220 | }, 221 | { 222 | 'label': 'Matopiba', 223 | 'value': 'projects/mapbiomas-territories/assets/TERRITORIES/LULC/BRAZIL/COLLECTION9/WORKSPACE/MATOPIBA', 224 | }, 225 | { 226 | 'label': 'Political Level 1', 227 | 'value': 'projects/mapbiomas-territories/assets/TERRITORIES/LULC/BRAZIL/COLLECTION9/WORKSPACE/POLITICAL_LEVEL_1', 228 | }, 229 | { 230 | 'label': 'Political Level 2', 231 | 'value': 'projects/mapbiomas-territories/assets/TERRITORIES/LULC/BRAZIL/COLLECTION9/WORKSPACE/POLITICAL_LEVEL_2', 232 | }, 233 | { 234 | 'label': 'Political Level 3', 235 | 'value': 'projects/mapbiomas-territories/assets/TERRITORIES/LULC/BRAZIL/COLLECTION9/WORKSPACE/POLITICAL_LEVEL_3', 236 | }, 237 | { 238 | 'label': 'Protected Area', 239 | 'value': 'projects/mapbiomas-territories/assets/TERRITORIES/LULC/BRAZIL/COLLECTION9/WORKSPACE/PROTECTED_AREA', 240 | }, 241 | { 242 | 'label': 'Quilombos', 243 | 'value': 'projects/mapbiomas-territories/assets/TERRITORIES/LULC/BRAZIL/COLLECTION9/WORKSPACE/QUILOMBOS', 244 | }, 245 | { 246 | 'label': 'Biosphere Reserve', 247 | 'value': 'projects/mapbiomas-territories/assets/TERRITORIES/LULC/BRAZIL/COLLECTION9/WORKSPACE/RESERVA_DA_BIOSFERA', 248 | }, 249 | { 250 | 'label': 'Semiarid', 251 | 'value': 'projects/mapbiomas-territories/assets/TERRITORIES/LULC/BRAZIL/COLLECTION9/WORKSPACE/SEMIARID', 252 | }, 253 | { 254 | 'label': 'Settlements', 255 | 'value': 'projects/mapbiomas-territories/assets/TERRITORIES/LULC/BRAZIL/COLLECTION9/WORKSPACE/SETTLEMENTS', 256 | }, 257 | { 258 | 'label': 'UGRHS', 259 | 'value': 'projects/mapbiomas-territories/assets/TERRITORIES/LULC/BRAZIL/COLLECTION9/WORKSPACE/UGRHS', 260 | } 261 | ], 262 | }, 263 | 264 | collections: { 265 | 'mapbiomas-brazil': { 266 | 'collection-6.0': { 267 | 'assets': { 268 | 'irrigated_agriculture': 'projects/mapbiomas-workspace/public/collection6/mapbiomas_collection60_irrigated_agriculture_v1', 269 | // 'agriculture': '', 270 | }, 271 | 272 | 'periods': { 273 | 'irrigated_agriculture': [ 274 | '1985', '1986', '1987', '1988', 275 | '1989', '1990', '1991', '1992', 276 | '1993', '1994', '1995', '1996', 277 | '1997', '1998', '1999', '2000', 278 | '2001', '2002', '2003', '2004', 279 | '2005', '2006', '2007', '2008', 280 | '2009', '2010', '2011', '2012', 281 | '2013', '2014', '2015', '2016', 282 | '2017', '2018', '2019', '2020' 283 | ], 284 | 'agriculture': [ 285 | '1985', '1986', '1987', '1988', 286 | '1989', '1990', '1991', '1992', 287 | '1993', '1994', '1995', '1996', 288 | '1997', '1998', '1999', '2000', 289 | '2001', '2002', '2003', '2004', 290 | '2005', '2006', '2007', '2008', 291 | '2009', '2010', '2011', '2012', 292 | '2013', '2014', '2015', '2016', 293 | '2017', '2018', '2019', '2020' 294 | ], 295 | 296 | }, 297 | }, 298 | 'collection-7.0': { 299 | 'assets': { 300 | 'irrigated_agriculture': 'projects/mapbiomas-workspace/public/collection7/mapbiomas_collection70_irrigated_agriculture_v3', 301 | // 'agriculture': '', 302 | }, 303 | 304 | 'periods': { 305 | 'irrigated_agriculture': [ 306 | '1985', '1986', '1987', '1988', 307 | '1989', '1990', '1991', '1992', 308 | '1993', '1994', '1995', '1996', 309 | '1997', '1998', '1999', '2000', 310 | '2001', '2002', '2003', '2004', 311 | '2005', '2006', '2007', '2008', 312 | '2009', '2010', '2011', '2012', 313 | '2013', '2014', '2015', '2016', 314 | '2017', '2018', '2019', '2020', 315 | '2021' 316 | ], 317 | 'agriculture': [ 318 | '1985', '1986', '1987', '1988', 319 | '1989', '1990', '1991', '1992', 320 | '1993', '1994', '1995', '1996', 321 | '1997', '1998', '1999', '2000', 322 | '2001', '2002', '2003', '2004', 323 | '2005', '2006', '2007', '2008', 324 | '2009', '2010', '2011', '2012', 325 | '2013', '2014', '2015', '2016', 326 | '2017', '2018', '2019', '2020', 327 | '2021' 328 | ], 329 | 330 | }, 331 | }, 332 | 'collection-8.0': { 333 | 'assets': { 334 | 'irrigated_agriculture': 'projects/mapbiomas-workspace/public/collection8/mapbiomas_collection80_irrigated_agriculture_v1', 335 | // 'agriculture': '', 336 | }, 337 | 338 | 'periods': { 339 | 'irrigated_agriculture': [ 340 | '1985', '1986', '1987', '1988', 341 | '1989', '1990', '1991', '1992', 342 | '1993', '1994', '1995', '1996', 343 | '1997', '1998', '1999', '2000', 344 | '2001', '2002', '2003', '2004', 345 | '2005', '2006', '2007', '2008', 346 | '2009', '2010', '2011', '2012', 347 | '2013', '2014', '2015', '2016', 348 | '2017', '2018', '2019', '2020', 349 | '2021', '2022' 350 | ], 351 | 'agriculture': [ 352 | '1985', '1986', '1987', '1988', 353 | '1989', '1990', '1991', '1992', 354 | '1993', '1994', '1995', '1996', 355 | '1997', '1998', '1999', '2000', 356 | '2001', '2002', '2003', '2004', 357 | '2005', '2006', '2007', '2008', 358 | '2009', '2010', '2011', '2012', 359 | '2013', '2014', '2015', '2016', 360 | '2017', '2018', '2019', '2020', 361 | '2021', '2022' 362 | ], 363 | 364 | }, 365 | }, 366 | 'collection-9.0': { 367 | 'assets': { 368 | 'irrigated_agriculture': 'projects/mapbiomas-public/assets/brazil/lulc/collection9/mapbiomas_collection90_irrigated_agriculture_v1', 369 | // 'agriculture': '', 370 | }, 371 | 372 | 'periods': { 373 | 'irrigated_agriculture': [ 374 | '1985', '1986', '1987', '1988', 375 | '1989', '1990', '1991', '1992', 376 | '1993', '1994', '1995', '1996', 377 | '1997', '1998', '1999', '2000', 378 | '2001', '2002', '2003', '2004', 379 | '2005', '2006', '2007', '2008', 380 | '2009', '2010', '2011', '2012', 381 | '2013', '2014', '2015', '2016', 382 | '2017', '2018', '2019', '2020', 383 | '2021', '2022', '2023' 384 | ], 385 | 'agriculture': [ 386 | '1985', '1986', '1987', '1988', 387 | '1989', '1990', '1991', '1992', 388 | '1993', '1994', '1995', '1996', 389 | '1997', '1998', '1999', '2000', 390 | '2001', '2002', '2003', '2004', 391 | '2005', '2006', '2007', '2008', 392 | '2009', '2010', '2011', '2012', 393 | '2013', '2014', '2015', '2016', 394 | '2017', '2018', '2019', '2020', 395 | '2021', '2022', '2023' 396 | ], 397 | 398 | }, 399 | }, 400 | }, 401 | 402 | }, 403 | 404 | bandsNames: { //TODO: ajustar o nome das bandas no asset publico 405 | 'irrigated_agriculture': 'irrigated_agriculture', 406 | 407 | }, 408 | 409 | dataType: 'irrigated_agriculture', 410 | 411 | data: { 412 | 'irrigated_agriculture': null, 413 | }, 414 | 415 | fileDimensions: { 416 | 'irrigated_agriculture': 256 * 124, 417 | // 'agriculture': 256 * 124, 418 | }, 419 | 420 | ranges: { 421 | 'irrigated_agriculture': { 422 | 'min': 1, 423 | 'max': 3 424 | }, 425 | 'agriculture': { 426 | 'min': 0, 427 | 'max': 1 //TODO: ajustar os params min e max para visualização 428 | }, 429 | 430 | }, 431 | 432 | palette: { 433 | 'irrigated_agriculture': [ 434 | '#F605E9', // 1. Irrigation center pivot 435 | '#3D0841', // 2. Irrigated rice 436 | '#8B1DB9', // 3. Other irrigation systems 437 | ], 438 | 439 | 'agriculture': [ 440 | '#ffffff', 441 | '#f500d0', 442 | ], 443 | 444 | }, 445 | 446 | vector: null, 447 | activeFeature: null, 448 | activeName: '', 449 | 450 | taskid: 1, 451 | 452 | bufferDistance: 0, 453 | 454 | className: { 455 | 456 | 'irrigated_agriculture': { 457 | 1: 'Irrigation center pivot', 458 | 2: 'Irrigated rice', 459 | 3: 'Other irrigation systems', 460 | }, 461 | 462 | }, 463 | 464 | legend: { 465 | params: { 466 | "title": 'Legend', 467 | "layers": [ 468 | ['#F605E9', 1, 'Irrigation center pivot',], 469 | ['#3D0841', 2, 'Irrigated rice',], 470 | ['#8B1DB9', 3, 'Other irrigation systems',], 471 | ], 472 | "style": { 473 | "backgroundColor": "#ffffff", 474 | "color": "#212121" 475 | }, 476 | "orientation": "vertical" 477 | } 478 | } 479 | }, 480 | 481 | init: function () { 482 | 483 | this.ui.init(); 484 | 485 | }, 486 | 487 | setVersion: function () { 488 | 489 | App.ui.form.labelTitle.setValue('MapBiomas User Toolkit ' + App.options.version); 490 | 491 | }, 492 | 493 | startMap: function (year) { 494 | 495 | Map.centerObject(App.options.data.irrigated_agriculture, 5); 496 | 497 | var imageLayer = ui.Map.Layer({ 498 | 'eeObject': App.options.data.irrigated_agriculture, 499 | 'visParams': { 500 | 'bands': ['irrigated_agriculture_' + year], 501 | 'palette': App.options.palette.irrigated_agriculture, 502 | 'min': App.options.ranges.irrigated_agriculture.min, 503 | 'max': App.options.ranges.irrigated_agriculture.max, 504 | 'format': 'png' 505 | }, 506 | 'name': 'Irrigated Agriculture', 507 | 'shown': true, 508 | 'opacity': 1.0 509 | }); 510 | 511 | App.ui.clear(); 512 | 513 | Map.add(imageLayer); 514 | 515 | }, 516 | 517 | formatName: function (name) { 518 | 519 | var formated = name 520 | .toLowerCase() 521 | .replace(/á/g, 'a') 522 | .replace(/à/g, 'a') 523 | .replace(/â/g, 'a') 524 | .replace(/ã/g, 'a') 525 | .replace(/ä/g, 'a') 526 | .replace(/ª/g, 'a') 527 | .replace(/é/g, 'e') 528 | .replace(/ê/g, 'e') 529 | .replace(/í/g, 'i') 530 | .replace(/ó/g, 'o') 531 | .replace(/ô/g, 'o') 532 | .replace(/õ/g, 'o') 533 | .replace(/ú/g, 'u') 534 | .replace(/û/g, 'u') 535 | .replace(/ũ/g, 'u') 536 | .replace(/ç/g, 'c') 537 | .replace(/ñ/g, 'n') 538 | .replace(/&/g, '') 539 | .replace(/@/g, '') 540 | .replace(/ /g, '') 541 | .replace(/["'()\/]/g, ''); 542 | 543 | return formated; 544 | }, 545 | 546 | ui: { 547 | 548 | init: function () { 549 | 550 | this.form.init(); 551 | 552 | }, 553 | 554 | clear: function () { 555 | Map.clear(); 556 | 557 | Map.setOptions({ 558 | 'styles': { 559 | 'Dark': mapp.getStyle('Dark') 560 | } 561 | }); 562 | }, 563 | 564 | setMapbiomasRegion: function (regionName) { 565 | 566 | App.ui.loadCollectionList(regionName); 567 | App.ui.loadTablesNames(regionName); 568 | 569 | }, 570 | 571 | setDataType: function (dataType) { 572 | 573 | App.options.dataType = dataType; 574 | 575 | }, 576 | 577 | loadCollectionList: function (regionName) { 578 | 579 | App.ui.form.selectCollection.setPlaceholder('loading collections...'); 580 | 581 | App.ui.form.selectCollection = ui.Select({ 582 | 'items': Object.keys(App.options.collections[regionName]).reverse(), 583 | 'placeholder': 'select collection', 584 | 'onChange': function (collectioName) { 585 | ee.Number(1).evaluate( 586 | function (a) { 587 | 588 | App.options.data.irrigated_agriculture = ee.Image( 589 | App.options.collections[regionName][collectioName].assets.irrigated_agriculture) 590 | .divide(100).byte(); 591 | 592 | var year = App.options.collections[regionName][collectioName] 593 | .periods.irrigated_agriculture.slice(-1)[0]; 594 | 595 | App.startMap(year); 596 | } 597 | ); 598 | 599 | App.ui.loadingBox(); 600 | }, 601 | 'style': { 602 | 'stretch': 'horizontal' 603 | } 604 | }); 605 | 606 | App.ui.form.panelCollection.widgets() 607 | .set(1, App.ui.form.selectCollection); 608 | 609 | }, 610 | 611 | loadTablesNames: function (regionName) { 612 | 613 | App.ui.form.selectRegion.setPlaceholder('loading tables names...'); 614 | 615 | var roots = ee.data.getAssetRoots() 616 | .map( 617 | function (obj) { 618 | return obj.id; 619 | }); 620 | 621 | var allTablesNames; 622 | 623 | /** 624 | * Skip the error msg if MAPBIOMAS folder is not found 625 | */ 626 | try { 627 | var tablesNames = ee.data.getList({ 628 | 'id': roots[0] + '/MAPBIOMAS' 629 | }).map( 630 | function (obj) { 631 | return obj.id; 632 | }); 633 | var allTablesNames = App.options.tables[regionName].concat(tablesNames); 634 | } 635 | catch (e) { 636 | var allTablesNames = App.options.tables[regionName]; 637 | } 638 | 639 | App.ui.form.selectFeatureCollections = ui.Select({ 640 | 'items': allTablesNames, 641 | 'placeholder': 'select table', 642 | 'onChange': function (tableName) { 643 | if (tableName != 'None') { 644 | App.options.activeName = tableName; 645 | App.ui.form.panelStates.remove(App.ui.form.labelStates); 646 | App.ui.form.panelStates.remove(App.ui.form.selectStates); 647 | ee.Number(1).evaluate( 648 | function (a) { 649 | var collectioName = App.ui.form.selectCollection.getValue(); 650 | 651 | App.ui.loadTable(tableName); 652 | 653 | App.ui.makeLayersList( 654 | tableName.split('/').slice(-1)[0], 655 | App.options.activeFeature, 656 | App.options.collections[regionName][collectioName] 657 | .periods[App.options.dataType] 658 | ); 659 | 660 | App.ui.loadPropertiesNames(); 661 | 662 | App.ui.form.selectDataType.setDisabled(false); 663 | } 664 | ); 665 | 666 | App.ui.loadingBox(); 667 | } 668 | }, 669 | 'style': { 670 | 'stretch': 'horizontal' 671 | } 672 | }); 673 | 674 | App.ui.form.panelFeatureCollections.widgets() 675 | .set(1, App.ui.form.selectFeatureCollections); 676 | 677 | }, 678 | 679 | loadTableStates: function (tableName) { 680 | 681 | var state = App.ui.form.selectStates.getValue(); 682 | 683 | App.options.table = ee.FeatureCollection(tableName) 684 | .filterMetadata('UF', 'equals', parseInt(App.options.statesNames[state], 10)); 685 | 686 | App.options.activeFeature = App.options.table; 687 | 688 | Map.centerObject(App.options.activeFeature); 689 | 690 | App.ui.clear(); 691 | 692 | Map.addLayer(App.options.activeFeature.style({ 693 | color: 'ff0000', 694 | width: 1, 695 | fillColor: 'ff000033', 696 | }), {}, 697 | tableName.split('/')[3], 698 | true); 699 | 700 | }, 701 | 702 | loadTable: function (tableName) { 703 | 704 | App.options.table = ee.FeatureCollection(tableName); 705 | 706 | App.options.activeFeature = App.options.table; 707 | 708 | // Map.centerObject(App.options.activeFeature); 709 | 710 | App.ui.clear(); 711 | 712 | Map.addLayer(App.options.activeFeature.style({ 713 | color: 'ff0000', 714 | width: 1, 715 | fillColor: 'ff000033', 716 | }), {}, 717 | tableName.split('/')[3], 718 | true); 719 | 720 | }, 721 | 722 | loadPropertiesNames: function () { 723 | 724 | App.ui.form.selectProperties.setPlaceholder('loading tables names...'); 725 | 726 | ee.Feature(App.options.table.first()) 727 | .propertyNames() 728 | .evaluate( 729 | function (propertyNames) { 730 | 731 | // print(propertyNames); 732 | 733 | App.ui.form.selectProperties = ui.Select({ 734 | 'items': propertyNames, 735 | 'placeholder': 'select property', 736 | 'onChange': function (propertyName) { 737 | if (propertyName != 'None') { 738 | App.options.propertyName = propertyName; 739 | 740 | ee.Number(1).evaluate( 741 | function (a) { 742 | App.ui.loadFeatureNames(propertyName); 743 | App.ui.form.selectDataType.setDisabled(false); 744 | } 745 | ); 746 | 747 | } 748 | }, 749 | 'style': { 750 | 'stretch': 'horizontal' 751 | } 752 | }); 753 | 754 | App.ui.form.panelProperties.widgets() 755 | .set(1, App.ui.form.selectProperties); 756 | } 757 | ); 758 | 759 | }, 760 | 761 | loadFeatureNames: function () { 762 | 763 | App.ui.form.selectFeature.setPlaceholder('loading feature names...'); 764 | 765 | App.options.table.sort(App.options.propertyName) 766 | .reduceColumns(ee.Reducer.toList(), [App.options.propertyName]) 767 | .get('list') 768 | .evaluate( 769 | function (featureNameList) { 770 | 771 | App.ui.form.selectFeature = ui.Select({ 772 | 'items': featureNameList, 773 | 'placeholder': 'select feature', 774 | 'onChange': function (featureName) { 775 | if (featureName != 'None') { 776 | App.options.featureName = featureName; 777 | 778 | ee.Number(1).evaluate( 779 | function (a) { 780 | var regionName = App.ui.form.selectRegion.getValue(); 781 | var collectionName = App.ui.form.selectCollection.getValue(); 782 | 783 | App.ui.loadFeature(featureName); 784 | 785 | App.ui.makeLayersList( 786 | featureName, 787 | App.options.activeFeature, 788 | App.options.collections[regionName][collectionName] 789 | .periods[App.options.dataType]); 790 | App.ui.form.selectDataType.setDisabled(false); 791 | } 792 | ); 793 | 794 | App.ui.loadingBox(); 795 | } 796 | }, 797 | 'style': { 798 | 'stretch': 'horizontal' 799 | } 800 | }); 801 | 802 | App.ui.form.panelFeature.widgets() 803 | .set(1, App.ui.form.selectFeature); 804 | } 805 | ); 806 | 807 | }, 808 | 809 | loadFeature: function (name) { 810 | 811 | App.options.activeFeature = App.options.table 812 | .filterMetadata(App.options.propertyName, 'equals', name); 813 | 814 | Map.centerObject(App.options.activeFeature); 815 | 816 | App.ui.clear(); 817 | 818 | Map.addLayer(App.options.activeFeature.style({ 819 | color: 'ff0000', 820 | width: 1, 821 | fillColor: 'ff000033', 822 | }), {}, 823 | name, 824 | true); 825 | 826 | }, 827 | 828 | addImageLayer: function (period, label, region) { 829 | 830 | 831 | var image = App.options.data[App.options.dataType] 832 | .select([App.options.bandsNames[App.options.dataType] + '_' + period]) 833 | .clip(region); 834 | 835 | var imageLayer = ui.Map.Layer({ 836 | 'eeObject': image.selfMask(), 837 | 'visParams': { 838 | 'palette': App.options.palette[App.options.dataType], 839 | 'min': App.options.ranges[App.options.dataType].min, 840 | 'max': App.options.ranges[App.options.dataType].max, 841 | 'format': 'png' 842 | }, 843 | 'name': label, 844 | 'shown': true, 845 | 'opacity': 1.0 846 | }); 847 | 848 | Map.layers().insert( 849 | Map.layers().length() - 1, 850 | imageLayer 851 | ); 852 | 853 | }, 854 | 855 | removeImageLayer: function (label) { 856 | 857 | for (var i = 0; i < Map.layers().length(); i++) { 858 | 859 | var layer = Map.layers().get(i); 860 | 861 | if (label === layer.get('name')) { 862 | Map.remove(layer); 863 | } 864 | } 865 | 866 | }, 867 | 868 | manageLayers: function (checked, period, label, region) { 869 | 870 | if (checked) { 871 | App.ui.addImageLayer(period, label, region); 872 | } else { 873 | App.ui.removeImageLayer(label); 874 | } 875 | 876 | }, 877 | 878 | makeLayersList: function (regionName, region, periods) { 879 | // print(regionName, region, periods) 880 | App.ui.form.panelLayersList.clear(); 881 | 882 | periods.forEach( 883 | 884 | function (period, index, array) { 885 | App.ui.form.panelLayersList.add( 886 | ui.Checkbox({ 887 | "label": regionName + ' ' + period, 888 | "value": false, 889 | "onChange": function (checked) { 890 | 891 | App.ui.manageLayers(checked, period, regionName + ' ' + period, region); 892 | 893 | }, 894 | "disabled": false, 895 | "style": { 896 | 'padding': '2px', 897 | 'stretch': 'horizontal', 898 | 'backgroundColor': '#dddddd', 899 | 'fontSize': '12px' 900 | } 901 | }) 902 | ); 903 | 904 | } 905 | ); 906 | 907 | }, 908 | 909 | loadingBox: function () { 910 | App.ui.form.loadingBox = ui.Panel(); 911 | App.ui.form.loadingBox.add(ui.Label('Loading...')); 912 | 913 | Map.add(App.ui.form.loadingBox); 914 | }, 915 | 916 | export2Drive: function () { 917 | 918 | var layers = App.ui.form.panelLayersList.widgets(); 919 | 920 | var regionName = App.ui.form.selectRegion.getValue(); 921 | var collectionName = App.ui.form.selectCollection.getValue(); 922 | 923 | var featureName = App.formatName(App.ui.form.selectFeature.getValue() || ''); 924 | 925 | var bandIds = []; 926 | 927 | for (var i = 0; i < layers.length(); i++) { 928 | 929 | var selected = layers.get(i).getValue(); 930 | 931 | if (selected) { 932 | 933 | var period = App.options.collections[regionName][collectionName] 934 | .periods[App.options.dataType][i]; 935 | 936 | var fileName = [regionName, collectionName, App.options.dataType, featureName, period].join('-'); 937 | 938 | fileName = fileName.replace(/--/g, '-').replace(/--/g, '-').replace('.', '').replace('_', '-'); 939 | fileName = App.formatName(fileName); 940 | 941 | var data = App.options.data[App.options.dataType] 942 | .select([App.options.bandsNames[App.options.dataType] + '_' + period]); 943 | 944 | var region = App.options.activeFeature.geometry(); 945 | 946 | if (App.options.bufferDistance !== 0) { 947 | data = data.clip(App.options.activeFeature.geometry().buffer(App.options.bufferDistance)); 948 | region = region.buffer(App.options.bufferDistance); 949 | } else { 950 | data = data.clip(App.options.activeFeature.geometry()); 951 | } 952 | 953 | region = region.bounds(); 954 | 955 | Export.image.toDrive({ 956 | image: data, 957 | description: fileName, 958 | folder: 'MAPBIOMAS-EXPORT', 959 | fileNamePrefix: fileName, 960 | region: region, 961 | scale: 30, 962 | maxPixels: 1e13, 963 | fileFormat: 'GeoTIFF', 964 | fileDimensions: App.options.fileDimensions[App.options.dataType], 965 | }); 966 | 967 | bandIds.push(App.options.bandsNames[App.options.dataType] + '_' + period); 968 | } 969 | } 970 | 971 | // Export table 972 | var territory = ee.Image().paint({ 973 | 'featureCollection': ee.FeatureCollection(App.options.activeFeature), 974 | 'color': 1 975 | }); 976 | 977 | var geometry = App.options.activeFeature.geometry().bounds(); 978 | 979 | var areas = bandIds.map( 980 | function (band) { 981 | 982 | var image = App.options.data[App.options.dataType].select(band); 983 | 984 | var area = Area.calculate({ 985 | "image": image, 986 | "territory": territory, 987 | "geometry": geometry, 988 | "scale": 30, 989 | "factor": 1000000, 990 | "unit": 'kilometers^2' 991 | }); 992 | 993 | area = ee.FeatureCollection(area).map( 994 | function (feature) { 995 | 996 | var className = ee.Dictionary(App.options.className[App.options.dataType]) 997 | .get(ee.Number(feature.get('class'))); 998 | 999 | return feature 1000 | .set('class_name', className) 1001 | .set('band', band); 1002 | } 1003 | ); 1004 | 1005 | return area; 1006 | } 1007 | ); 1008 | 1009 | areas = ee.FeatureCollection(areas).flatten(); 1010 | // print(areas); 1011 | 1012 | var tableName = [regionName, collectionName, App.options.dataType, featureName, 'area'].join('-'); 1013 | 1014 | tableName = tableName.replace(/--/g, '-').replace(/--/g, '-').replace('.', '').replace('_', '-'); 1015 | tableName = App.formatName(tableName); 1016 | 1017 | Export.table.toDrive({ 1018 | 'collection': areas, 1019 | 'description': tableName, 1020 | 'folder': 'MAPBIOMAS-EXPORT', 1021 | 'fileNamePrefix': tableName, 1022 | 'fileFormat': 'CSV' 1023 | }); 1024 | 1025 | }, 1026 | 1027 | form: { 1028 | 1029 | init: function () { 1030 | 1031 | var blob = ee.Blob(App.options.logo.uri); 1032 | 1033 | blob.string().evaluate( 1034 | function (str) { 1035 | str = str.replace(/\n/g, ''); 1036 | App.options.logo.base64 = ui.Label({ 1037 | imageUrl: str, 1038 | }); 1039 | App.ui.form.panelLogo.add(App.options.logo.base64); 1040 | } 1041 | ); 1042 | 1043 | this.panelMain.add(this.panelLogo); 1044 | this.panelMain.add(this.labelTitle); 1045 | this.panelMain.add(this.labelSubtitle); 1046 | // this.panelMain.add(this.labelLink); 1047 | 1048 | this.panelRegion.add(this.labelRegion); 1049 | this.panelRegion.add(this.selectRegion); 1050 | 1051 | this.panelCollection.add(this.labelCollection); 1052 | this.panelCollection.add(this.selectCollection); 1053 | 1054 | this.panelFeatureCollections.add(this.labelTables); 1055 | this.panelFeatureCollections.add(this.selectFeatureCollections); 1056 | 1057 | this.panelProperties.add(this.labelProperties); 1058 | this.panelProperties.add(this.selectProperties); 1059 | 1060 | this.panelFeature.add(this.labelFeature); 1061 | this.panelFeature.add(this.selectFeature); 1062 | 1063 | this.panelDataType.add(this.labelDataType); 1064 | this.panelDataType.add(this.selectDataType); 1065 | 1066 | this.panelBuffer.add(this.labelBuffer); 1067 | this.panelBuffer.add(this.selectBuffer); 1068 | 1069 | this.panelLegend.add(legend.getLegend(App.options.legend.params)); 1070 | 1071 | // this.panelMain.add(this.panelType); 1072 | this.panelMain.add(this.panelRegion); 1073 | this.panelMain.add(this.panelCollection); 1074 | this.panelMain.add(this.panelFeatureCollections); 1075 | this.panelMain.add(this.panelStates); 1076 | this.panelMain.add(this.panelProperties); 1077 | this.panelMain.add(this.panelFeature); 1078 | this.panelMain.add(this.panelDataType); 1079 | this.panelMain.add(this.panelLegend); 1080 | this.panelMain.add(this.panelBuffer); 1081 | 1082 | this.panelMain.add(this.labelLayers); 1083 | this.panelMain.add(this.panelLayersList); 1084 | 1085 | this.panelMain.add(this.buttonExport2Drive); 1086 | this.panelMain.add(this.labelNotes); 1087 | 1088 | ui.root.add(this.panelMain); 1089 | 1090 | }, 1091 | 1092 | panelMain: ui.Panel({ 1093 | 'layout': ui.Panel.Layout.flow('vertical'), 1094 | 'style': { 1095 | 'width': '360px', 1096 | 'position': 'bottom-left', 1097 | 'margin': '0px 0px 0px 0px', 1098 | }, 1099 | }), 1100 | 1101 | panelLogo: ui.Panel({ 1102 | 'layout': ui.Panel.Layout.flow('vertical'), 1103 | 'style': { 1104 | 'stretch': 'horizontal', 1105 | 'margin': '10px 0px 5px 15px', 1106 | }, 1107 | }), 1108 | 1109 | panelStates: ui.Panel({ 1110 | 'layout': ui.Panel.Layout.flow('vertical'), 1111 | 'style': { 1112 | 'stretch': 'horizontal' 1113 | }, 1114 | }), 1115 | 1116 | panelRegion: ui.Panel({ 1117 | 'layout': ui.Panel.Layout.flow('vertical'), 1118 | 'style': { 1119 | 'stretch': 'horizontal' 1120 | }, 1121 | }), 1122 | 1123 | panelCollection: ui.Panel({ 1124 | 'layout': ui.Panel.Layout.flow('vertical'), 1125 | 'style': { 1126 | 'stretch': 'horizontal' 1127 | }, 1128 | }), 1129 | 1130 | panelFeatureCollections: ui.Panel({ 1131 | 'layout': ui.Panel.Layout.flow('vertical'), 1132 | 'style': { 1133 | 'stretch': 'horizontal' 1134 | }, 1135 | }), 1136 | 1137 | panelProperties: ui.Panel({ 1138 | 'layout': ui.Panel.Layout.flow('vertical'), 1139 | 'style': { 1140 | 'stretch': 'horizontal' 1141 | }, 1142 | }), 1143 | 1144 | panelFeature: ui.Panel({ 1145 | 'layout': ui.Panel.Layout.flow('vertical'), 1146 | 'style': { 1147 | 'stretch': 'horizontal' 1148 | }, 1149 | }), 1150 | 1151 | panelDataType: ui.Panel({ 1152 | 'layout': ui.Panel.Layout.flow('vertical'), 1153 | 'style': { 1154 | 'stretch': 'horizontal' 1155 | }, 1156 | }), 1157 | 1158 | panelLegend: ui.Panel({ 1159 | 'layout': ui.Panel.Layout.flow('vertical'), 1160 | 'style': { 1161 | 'stretch': 'vertical', 1162 | 'position': 'bottom-left' 1163 | }, 1164 | }), 1165 | 1166 | panelBuffer: ui.Panel({ 1167 | 'layout': ui.Panel.Layout.flow('vertical'), 1168 | 'style': { 1169 | 'stretch': 'horizontal' 1170 | }, 1171 | }), 1172 | 1173 | panelLayersList: ui.Panel({ 1174 | 'layout': ui.Panel.Layout.flow('vertical'), 1175 | 'style': { 1176 | 'height': '200px', 1177 | 'stretch': 'vertical', 1178 | 'backgroundColor': '#cccccc', 1179 | }, 1180 | }), 1181 | 1182 | labelRegion: ui.Label('Region', { 1183 | // 'fontWeight': 'bold', 1184 | // 'padding': '1px', 1185 | 'fontSize': '16px' 1186 | }), 1187 | 1188 | labelCollection: ui.Label('Collection', { 1189 | // 'fontWeight': 'bold', 1190 | // 'padding': '1px', 1191 | 'fontSize': '16px' 1192 | }), 1193 | 1194 | labelTitle: ui.Label('MapBiomas User Toolkit', { 1195 | 'fontWeight': 'bold', 1196 | // 'padding': '1px', 1197 | 'fontSize': '16px' 1198 | }), 1199 | 1200 | labelSubtitle: ui.Label('Agriculture', { 1201 | // 'fontWeight': 'bold', 1202 | // 'padding': '1px', 1203 | 'fontSize': '14px' 1204 | }), 1205 | 1206 | labelLink: ui.Label('Legend codes', { 1207 | // 'fontWeight': 'bold', 1208 | // 'padding': '1px', 1209 | 'fontSize': '10px' 1210 | }, 1211 | 'https://mapbiomas.org/codigos-de-legenda?cama_set_language=pt-BR' 1212 | ), 1213 | 1214 | labelType: ui.Label('Type:', { 1215 | // 'padding': '1px', 1216 | 'fontSize': '16px' 1217 | }), 1218 | 1219 | labelTables: ui.Label('Tables:', { 1220 | // 'padding': '1px', 1221 | 'fontSize': '16px' 1222 | }), 1223 | 1224 | labelProperties: ui.Label('Properties:', { 1225 | // 'padding': '1px', 1226 | 'fontSize': '16px' 1227 | }), 1228 | 1229 | labelFeature: ui.Label('Features:', { 1230 | // 'padding': '1px', 1231 | 'fontSize': '16px' 1232 | }), 1233 | 1234 | labelDataType: ui.Label('Data Type:', { 1235 | // 'padding': '1px', 1236 | 'fontSize': '16px' 1237 | }), 1238 | 1239 | labelBuffer: ui.Label('Buffer:', { 1240 | // 'padding': '1px', 1241 | 'fontSize': '16px' 1242 | }), 1243 | 1244 | labelLayers: ui.Label('Layers:', { 1245 | // 'padding': '1px', 1246 | 'fontSize': '16px' 1247 | }), 1248 | 1249 | labelNotes: ui.Label('Go to TASK tab in the up-rght corner and click RUN', { 1250 | // 'padding': '1px', 1251 | 'fontSize': '16px' 1252 | }), 1253 | 1254 | labelStates: ui.Label('States:', { 1255 | // 'padding': '1px', 1256 | 'fontSize': '16px' 1257 | }), 1258 | 1259 | selectName: ui.Select({ 1260 | 'items': ['None'], 1261 | 'placeholder': 'None', 1262 | 'style': { 1263 | 'stretch': 'horizontal' 1264 | } 1265 | }), 1266 | 1267 | selectCollection: ui.Select({ 1268 | 'items': [], 1269 | 'placeholder': 'None', 1270 | 'style': { 1271 | 'stretch': 'horizontal' 1272 | }, 1273 | }), 1274 | 1275 | selectRegion: ui.Select({ 1276 | 'items': [ 1277 | // 'mapbiomas-amazon', 1278 | // 'mapbiomas-atlantic-forest', 1279 | 'mapbiomas-brazil', 1280 | // 'mapbiomas-chaco', 1281 | // 'mapbiomas-indonesia', 1282 | // 'mapbiomas-pampa', 1283 | ], 1284 | 'placeholder': 'None', 1285 | 'style': { 1286 | 'stretch': 'horizontal' 1287 | }, 1288 | 'onChange': function (region) { 1289 | 1290 | ee.Number(1).evaluate( 1291 | function (a) { 1292 | App.ui.setMapbiomasRegion(region); 1293 | } 1294 | ); 1295 | 1296 | }, 1297 | }), 1298 | 1299 | selectFeatureCollections: ui.Select({ 1300 | 'items': ['None'], 1301 | 'placeholder': 'None', 1302 | 'style': { 1303 | 'stretch': 'horizontal' 1304 | } 1305 | }), 1306 | 1307 | selectFeature: ui.Select({ 1308 | 'items': ['None'], 1309 | 'placeholder': 'None', 1310 | 'style': { 1311 | 'stretch': 'horizontal' 1312 | } 1313 | }), 1314 | 1315 | selectProperties: ui.Select({ 1316 | 'items': ['None'], 1317 | 'placeholder': 'None', 1318 | 'style': { 1319 | 'stretch': 'horizontal' 1320 | } 1321 | }), 1322 | 1323 | selectDataType: ui.Select({ 1324 | 'items': [ 1325 | 'irrigated_agriculture', 1326 | // 'agriculture', 1327 | ], 1328 | 'placeholder': 'Data type', 1329 | 'style': { 1330 | 'stretch': 'horizontal' 1331 | }, 1332 | 'disabled': true, 1333 | 'onChange': function (dataType) { 1334 | 1335 | var regionName = App.ui.form.selectRegion.getValue(); 1336 | var collectionName = App.ui.form.selectCollection.getValue(); 1337 | 1338 | App.ui.setDataType(dataType); 1339 | 1340 | App.ui.makeLayersList( 1341 | App.options.activeName.split('/').slice(-1)[0], 1342 | App.options.activeFeature, 1343 | App.options.collections[regionName][collectionName].periods[dataType]); 1344 | 1345 | }, 1346 | }), 1347 | 1348 | selectBuffer: ui.Select({ 1349 | 'items': [ 1350 | 'None', 1351 | '1km', 1352 | '2km', 1353 | '3km', 1354 | '4km', 1355 | '5km', 1356 | ], 1357 | 'placeholder': 'None', 1358 | 'style': { 1359 | 'stretch': 'horizontal' 1360 | }, 1361 | 'onChange': function (distance) { 1362 | var distances = { 1363 | 'None': 0, 1364 | '1km': 1000, 1365 | '2km': 2000, 1366 | '3km': 3000, 1367 | '4km': 4000, 1368 | '5km': 5000, 1369 | }; 1370 | 1371 | App.options.bufferDistance = distances[distance]; 1372 | }, 1373 | }), 1374 | 1375 | selectStates: ui.Select({ 1376 | 'items': [ 1377 | 'None', 'Acre', 'Alagoas', 'Amazonas', 'Amapá', 'Bahia', 1378 | 'Ceará', 'Distrito Federal', 'Espírito Santo', 'Goiás', 'Maranhão', 1379 | 'Minas Gerais', 'Mato Grosso do Sul', 'Mato Grosso', 'Pará', 'Paraíba', 1380 | 'Pernambuco', 'Piauí', 'Paraná', 'Rio de Janeiro', 'Rio Grande do Norte', 1381 | 'Rondônia', 'Roraima', 'Rio Grande do Sul', 'Santa Catarina', 'Sergipe', 1382 | 'São Paulo', 'Tocantins' 1383 | ], 1384 | 'placeholder': 'select state', 1385 | 'onChange': function (state) { 1386 | if (state != 'None') { 1387 | 1388 | ee.Number(1).evaluate( 1389 | function (a) { 1390 | App.ui.loadTableStates(App.options.activeName); 1391 | App.ui.makeLayersList(App.options.activeName.split('/')[3], App.options.activeFeature, App.options.periods[App.options.dataType]); 1392 | App.ui.loadPropertiesNames(); 1393 | App.ui.form.selectDataType.setDisabled(false); 1394 | } 1395 | ); 1396 | 1397 | App.ui.loadingBox(); 1398 | } 1399 | }, 1400 | 'style': { 1401 | 'stretch': 'horizontal' 1402 | } 1403 | }), 1404 | 1405 | buttonExport2Drive: ui.Button({ 1406 | "label": "Export images to Google Drive", 1407 | "onClick": function () { 1408 | App.ui.export2Drive(); 1409 | }, 1410 | "disabled": false, 1411 | "style": { 1412 | // 'padding': '2px', 1413 | 'stretch': 'horizontal' 1414 | } 1415 | }), 1416 | 1417 | }, 1418 | } 1419 | }; 1420 | 1421 | App.init(); 1422 | 1423 | App.setVersion(); -------------------------------------------------------------------------------- /mapbiomas-user-toolkit-mining.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @name 3 | * Mapbiomas User Toolkit Download 4 | * 5 | * @description 6 | * This is a support tool for mapbiomas data users. 7 | * 8 | * @author 9 | * João Siqueira 10 | * contato@mapbiomas.org 11 | * 12 | * @version 13 | * 1.0.0 - First release 14 | * 1.1.0 - Loads mapbiomas-brazil collection 7.0 mining data 15 | * 1.2.0 - Loads mapbiomas-brazil collection 8.0 mining data 16 | * 1.3.0 - Loads mapbiomas-brazil collection 9.0 mining data 17 | * 18 | * @see 19 | * Get the MapBiomas exported data in your "Google Drive/MAPBIOMAS-EXPORT" folder 20 | * Code and Tutorial - https://github.com/mapbiomas-brazil/user-toolkit 21 | */ 22 | 23 | var palettes = require('users/mapbiomas/modules:Palettes.js'); 24 | var logos = require('users/mapbiomas/modules:Logos.js'); 25 | var mapp = require('users/joaovsiqueira1/packages:Mapp.js'); 26 | var legend = require('users/joaovsiqueira1/packages:Legend.js'); 27 | 28 | /** 29 | * @description 30 | * calculate area for mapbiomas map 31 | * 32 | * @author 33 | * João Siqueira 34 | * 35 | */ 36 | var Area = { 37 | 38 | /** 39 | * Convert a complex obj to feature collection 40 | * @param obj 41 | */ 42 | convert2table: function (obj) { 43 | 44 | obj = ee.Dictionary(obj); 45 | 46 | var classesAndAreas = ee.List(obj.get('groups')); 47 | 48 | var tableRows = classesAndAreas.map( 49 | function (classAndArea) { 50 | classAndArea = ee.Dictionary(classAndArea); 51 | 52 | var classId = classAndArea.get('class'); 53 | var area = classAndArea.get('sum'); 54 | 55 | var tableColumns = ee.Feature(null) 56 | .set('class', classId) 57 | .set('area', area); 58 | 59 | return tableColumns; 60 | } 61 | ); 62 | 63 | return ee.FeatureCollection(ee.List(tableRows)); 64 | }, 65 | 66 | /** 67 | * Calculate area crossing a cover map (deforestation, mapbiomas) 68 | * and a region map (states, biomes, municipalites) 69 | * @param image 70 | * @param territory 71 | * @param geometry 72 | * @param scale 73 | * @param factor 74 | */ 75 | calculate: function (object) { 76 | 77 | var reducer = ee.Reducer.sum().group(1, 'class').group(1, 'territory'); 78 | var pixelArea = ee.Image.pixelArea().divide(object.factor); 79 | 80 | var territotiesData = pixelArea.addBands(object.territory).addBands(object.image) 81 | .reduceRegion({ 82 | reducer: reducer, 83 | geometry: object.geometry, 84 | scale: object.scale, 85 | maxPixels: 1e13 86 | }); 87 | 88 | territotiesData = ee.List(territotiesData.get('groups')); 89 | 90 | var areas = territotiesData.map(Area.convert2table); 91 | 92 | areas = ee.FeatureCollection(areas).flatten() 93 | .map( 94 | function (feature) { 95 | return feature.set("unit", object.unit) 96 | } 97 | ); 98 | 99 | return areas; 100 | } 101 | 102 | }; 103 | 104 | /** 105 | * 106 | */ 107 | var App = { 108 | 109 | options: { 110 | 111 | version: '1.3.0', 112 | 113 | logo: { 114 | uri: 'gs://mapbiomas-public/mapbiomas-logos/mapbiomas-logo-horizontal.b64', 115 | base64: null 116 | }, 117 | 118 | statesNames: { 119 | 'None': 'None', 120 | 'Acre': '12', 121 | 'Alagoas': '27', 122 | 'Amazonas': '13', 123 | 'Amapá': '16', 124 | 'Bahia': '29', 125 | 'Ceará': '23', 126 | 'Distrito Federal': '53', 127 | 'Espírito Santo': '32', 128 | 'Goiás': '52', 129 | 'Maranhão': '21', 130 | 'Minas Gerais': '31', 131 | 'Mato Grosso do Sul': '50', 132 | 'Mato Grosso': '51', 133 | 'Pará': '15', 134 | 'Paraíba': '25', 135 | 'Pernambuco': '26', 136 | 'Piauí': '22', 137 | 'Paraná': '41', 138 | 'Rio de Janeiro': '33', 139 | 'Rio Grande do Norte': '24', 140 | 'Rondônia': '11', 141 | 'Roraima': '14', 142 | 'Rio Grande do Sul': '43', 143 | 'Santa Catarina': '42', 144 | 'Sergipe': '28', 145 | 'São Paulo': '35', 146 | 'Tocantins': '17' 147 | }, 148 | 149 | tables: { 150 | 'mapbiomas-brazil': [ 151 | { 152 | 'label': 'Amacro', 153 | 'value': 'projects/mapbiomas-territories/assets/TERRITORIES/LULC/BRAZIL/COLLECTION9/WORKSPACE/AMACRO', 154 | }, 155 | { 156 | 'label': 'Ministry of the Environment priority areas 2018', 157 | 'value': 'projects/mapbiomas-territories/assets/TERRITORIES/LULC/BRAZIL/COLLECTION9/WORKSPACE/AREAS_PRIORITARIAS_DO_MMA_2018', 158 | }, 159 | { 160 | 'label': 'Atlantic Forest Law', 161 | 'value': 'projects/mapbiomas-territories/assets/TERRITORIES/LULC/BRAZIL/COLLECTION9/WORKSPACE/ATLANTIC_FOREST_LAW', 162 | }, 163 | { 164 | 'label': 'Basin Level 1 DNAEE', 165 | 'value': 'projects/mapbiomas-territories/assets/TERRITORIES/LULC/BRAZIL/COLLECTION9/WORKSPACE/BASIN_LEVEL_1_DNAEE', 166 | }, 167 | { 168 | 'label': 'Basin Level 1 PNRH', 169 | 'value': 'projects/mapbiomas-territories/assets/TERRITORIES/LULC/BRAZIL/COLLECTION9/WORKSPACE/BASIN_LEVEL_1_PNRH', 170 | }, 171 | { 172 | 'label': 'Basin Level 2 DNAEE', 173 | 'value': 'projects/mapbiomas-territories/assets/TERRITORIES/LULC/BRAZIL/COLLECTION9/WORKSPACE/BASIN_LEVEL_2_DNAEE', 174 | }, 175 | { 176 | 'label': 'Basin Level 2 PNRH', 177 | 'value': 'projects/mapbiomas-territories/assets/TERRITORIES/LULC/BRAZIL/COLLECTION9/WORKSPACE/BASIN_LEVEL_2_PNRH', 178 | }, 179 | { 180 | 'label': 'Biomes', 181 | 'value': 'projects/mapbiomas-territories/assets/TERRITORIES/LULC/BRAZIL/COLLECTION9/WORKSPACE/BIOMES', 182 | }, 183 | { 184 | 'label': 'Coastal Marine Zone', 185 | 'value': 'projects/mapbiomas-territories/assets/TERRITORIES/LULC/BRAZIL/COLLECTION9/WORKSPACE/COASTAL_MARINE_ZONE', 186 | }, 187 | { 188 | 'label': 'Forest Concessions', 189 | 'value': 'projects/mapbiomas-territories/assets/TERRITORIES/LULC/BRAZIL/COLLECTION9/WORKSPACE/CONCESSOES_FLORESTAIS', 190 | }, 191 | { 192 | 'label': 'DHN250 Level 1', 193 | 'value': 'projects/mapbiomas-territories/assets/TERRITORIES/LULC/BRAZIL/COLLECTION9/WORKSPACE/DHN250_LEVEL_1', 194 | }, 195 | { 196 | 'label': 'DHN250 Level 2', 197 | 'value': 'projects/mapbiomas-territories/assets/TERRITORIES/LULC/BRAZIL/COLLECTION9/WORKSPACE/DHN250_LEVEL_2', 198 | }, 199 | { 200 | 'label': 'DHN250 Level 3', 201 | 'value': 'projects/mapbiomas-territories/assets/TERRITORIES/LULC/BRAZIL/COLLECTION9/WORKSPACE/DHN250_LEVEL_3', 202 | }, 203 | { 204 | 'label': 'Non-Designated Public Forests', 205 | 'value': 'projects/mapbiomas-territories/assets/TERRITORIES/LULC/BRAZIL/COLLECTION9/WORKSPACE/FLORESTAS_PUBLICAS_NAO_DESTINADAS', 206 | }, 207 | { 208 | 'label': 'Geoparques', 209 | 'value': 'projects/mapbiomas-territories/assets/TERRITORIES/LULC/BRAZIL/COLLECTION9/WORKSPACE/GEOPARQUES', 210 | }, 211 | { 212 | 'label': 'Indigenous Territories', 213 | 'value': 'projects/mapbiomas-territories/assets/TERRITORIES/LULC/BRAZIL/COLLECTION9/WORKSPACE/INDIGENOUS_TERRITORIES', 214 | }, 215 | { 216 | 'label': 'Legal Amazon', 217 | 'value': 'projects/mapbiomas-territories/assets/TERRITORIES/LULC/BRAZIL/COLLECTION9/WORKSPACE/LEGAL_AMAZON', 218 | }, 219 | { 220 | 'label': 'Matopiba', 221 | 'value': 'projects/mapbiomas-territories/assets/TERRITORIES/LULC/BRAZIL/COLLECTION9/WORKSPACE/MATOPIBA', 222 | }, 223 | { 224 | 'label': 'Political Level 1', 225 | 'value': 'projects/mapbiomas-territories/assets/TERRITORIES/LULC/BRAZIL/COLLECTION9/WORKSPACE/POLITICAL_LEVEL_1', 226 | }, 227 | { 228 | 'label': 'Political Level 2', 229 | 'value': 'projects/mapbiomas-territories/assets/TERRITORIES/LULC/BRAZIL/COLLECTION9/WORKSPACE/POLITICAL_LEVEL_2', 230 | }, 231 | { 232 | 'label': 'Political Level 3', 233 | 'value': 'projects/mapbiomas-territories/assets/TERRITORIES/LULC/BRAZIL/COLLECTION9/WORKSPACE/POLITICAL_LEVEL_3', 234 | }, 235 | { 236 | 'label': 'Protected Area', 237 | 'value': 'projects/mapbiomas-territories/assets/TERRITORIES/LULC/BRAZIL/COLLECTION9/WORKSPACE/PROTECTED_AREA', 238 | }, 239 | { 240 | 'label': 'Quilombos', 241 | 'value': 'projects/mapbiomas-territories/assets/TERRITORIES/LULC/BRAZIL/COLLECTION9/WORKSPACE/QUILOMBOS', 242 | }, 243 | { 244 | 'label': 'Biosphere Reserve', 245 | 'value': 'projects/mapbiomas-territories/assets/TERRITORIES/LULC/BRAZIL/COLLECTION9/WORKSPACE/RESERVA_DA_BIOSFERA', 246 | }, 247 | { 248 | 'label': 'Semiarid', 249 | 'value': 'projects/mapbiomas-territories/assets/TERRITORIES/LULC/BRAZIL/COLLECTION9/WORKSPACE/SEMIARID', 250 | }, 251 | { 252 | 'label': 'Settlements', 253 | 'value': 'projects/mapbiomas-territories/assets/TERRITORIES/LULC/BRAZIL/COLLECTION9/WORKSPACE/SETTLEMENTS', 254 | }, 255 | { 256 | 'label': 'UGRHS', 257 | 'value': 'projects/mapbiomas-territories/assets/TERRITORIES/LULC/BRAZIL/COLLECTION9/WORKSPACE/UGRHS', 258 | } 259 | ], 260 | }, 261 | 262 | collections: { 263 | 'mapbiomas-brazil': { 264 | 'collection-6.0': { 265 | 'assets': { 266 | 'mined_substance': 'projects/mapbiomas-workspace/public/collection6/mapbiomas_collection60_mined_substance_v1', 267 | }, 268 | 269 | 'periods': { 270 | 'mined_substance': [ 271 | '1985', '1986', '1987', '1988', 272 | '1989', '1990', '1991', '1992', 273 | '1993', '1994', '1995', '1996', 274 | '1997', '1998', '1999', '2000', 275 | '2001', '2002', '2003', '2004', 276 | '2005', '2006', '2007', '2008', 277 | '2009', '2010', '2011', '2012', 278 | '2013', '2014', '2015', '2016', 279 | '2017', '2018', '2019', '2020' 280 | ], 281 | }, 282 | }, 283 | 'collection-7.0': { 284 | 'assets': { 285 | 'mined_substance': 'projects/mapbiomas-workspace/public/collection7/mapbiomas_collection70_mined_substance_v1', 286 | }, 287 | 288 | 'periods': { 289 | 'mined_substance': [ 290 | '1985', '1986', '1987', '1988', 291 | '1989', '1990', '1991', '1992', 292 | '1993', '1994', '1995', '1996', 293 | '1997', '1998', '1999', '2000', 294 | '2001', '2002', '2003', '2004', 295 | '2005', '2006', '2007', '2008', 296 | '2009', '2010', '2011', '2012', 297 | '2013', '2014', '2015', '2016', 298 | '2017', '2018', '2019', '2020', 299 | '2021' 300 | ], 301 | }, 302 | }, 303 | 'collection-8.0': { 304 | 'assets': { 305 | 'mined_substance': 'projects/mapbiomas-workspace/public/collection8/mapbiomas_collection80_mined_substance_v1', 306 | }, 307 | 308 | 'periods': { 309 | 'mined_substance': [ 310 | '1985', '1986', '1987', '1988', 311 | '1989', '1990', '1991', '1992', 312 | '1993', '1994', '1995', '1996', 313 | '1997', '1998', '1999', '2000', 314 | '2001', '2002', '2003', '2004', 315 | '2005', '2006', '2007', '2008', 316 | '2009', '2010', '2011', '2012', 317 | '2013', '2014', '2015', '2016', 318 | '2017', '2018', '2019', '2020', 319 | '2021', '2022' 320 | ], 321 | }, 322 | }, 323 | 'collection-9.0': { 324 | 'assets': { 325 | 'mined_substance': 'projects/mapbiomas-public/assets/brazil/lulc/collection9/mapbiomas_collection90_mined_substance_v1', 326 | }, 327 | 328 | 'periods': { 329 | 'mined_substance': [ 330 | '1985', '1986', '1987', '1988', 331 | '1989', '1990', '1991', '1992', 332 | '1993', '1994', '1995', '1996', 333 | '1997', '1998', '1999', '2000', 334 | '2001', '2002', '2003', '2004', 335 | '2005', '2006', '2007', '2008', 336 | '2009', '2010', '2011', '2012', 337 | '2013', '2014', '2015', '2016', 338 | '2017', '2018', '2019', '2020', 339 | '2021', '2022', '2023' 340 | ], 341 | }, 342 | }, 343 | }, 344 | 345 | }, 346 | 347 | bandsNames: { 348 | 'mined_substance': 'mined_substance', 349 | 350 | }, 351 | 352 | dataType: 'mined_substance', 353 | 354 | data: { 355 | 'mined_substance': null, 356 | }, 357 | 358 | fileDimensions: { 359 | 'mined_substance': 256 * 256, 360 | }, 361 | 362 | ranges: { 363 | 'mined_substance': { 364 | 'min': 101, 365 | 'max': 301 366 | }, 367 | }, 368 | 369 | sldStyle: '\ 370 | \ 371 | \ 372 | \ 373 | \ 374 | \ 375 | \ 376 | \ 377 | \ 378 | \ 379 | \ 380 | \ 381 | \ 382 | \ 383 | \ 384 | \ 385 | \ 386 | \ 387 | \ 388 | \ 389 | \ 390 | \ 391 | \ 392 | \ 393 | \ 394 | \ 395 | \ 396 | \ 397 | \ 398 | \ 399 | \ 400 | \ 401 | \ 402 | \ 403 | \ 404 | \ 405 | \ 406 | \ 407 | \ 408 | \ 409 | \ 410 | \ 411 | \ 412 | \ 413 | \ 414 | \ 415 | \ 416 | \ 417 | \ 418 | \ 419 | ', 420 | 421 | palette: { 422 | 'mined_substance': [ 423 | '#f4a582', //101 424 | '#f4a582', //102 425 | '#f4a582', //103 426 | '#f4a582', //104 427 | '#f4a582', //105 428 | '#f4a582', //106 429 | '#f4a582', //107 430 | '#f4a582', //108 431 | '#f4a582', //109 432 | '#f4a582', //110 433 | '#f4a582', //111 434 | '#f4a582', //112 435 | '#f4a582', //113 436 | '#f4a582', //114 437 | '#f4a582', //115 438 | '#92c5de', //116 439 | '#92c5de', //117 440 | '#92c5de', //118 441 | '#92c5de', //119 442 | '#92c5de', //120 443 | '#92c5de', //121 444 | '#92c5de', //122 445 | '#0571b0', //123 446 | '#0571b0', //124 447 | '#0571b0', //125 448 | '#ca0020', //126 449 | '#ca0020', //127 450 | '#ca0020', //128 451 | '#ca0020', //129 452 | '#f4a582', //130 453 | '#e66101', //214 454 | '#e66101', //215 455 | '#fdb863', //216 456 | '#fdb863', //217 457 | '#b2abd2', //223 458 | '#b2abd2', //224 459 | '#b2abd2', //225 460 | '#5e3c99', //226 461 | '#3caea3', //301 462 | 463 | ], 464 | }, 465 | 466 | vector: null, 467 | activeFeature: null, 468 | activeName: '', 469 | 470 | taskid: 1, 471 | 472 | bufferDistance: 0, 473 | 474 | className: { 475 | 476 | 'mined_substance': { 477 | 101: '2. Industrial/2.2 Metálicas/Metálicas', 478 | 102: '2. Industrial/2.2 Metálicas/2.2.01 Ferro', 479 | 103: '2. Industrial/2.2 Metálicas/2.2.02 Manganês', 480 | 104: '2. Industrial/2.2 Metálicas/2.2.03 Níquel', 481 | 105: '2. Industrial/2.2 Metálicas/2.2.04 Amianto', 482 | 106: '2. Industrial/2.2 Metálicas/2.2.05 Molibidênio', 483 | 107: '2. Industrial/2.2 Metálicas/2.2.06 Titânio', 484 | 108: '2. Industrial/2.2 Metálicas/2.2.07 Cromo', 485 | 109: '2. Industrial/2.2 Metálicas/2.2.08 Cobre', 486 | 110: '2. Industrial/2.2 Metálicas/2.2.09 Alumínio', 487 | 111: '2. Industrial/2.2 Metálicas/2.2.10 Magnésio', 488 | 112: '2. Industrial/2.2 Metálicas/2.2.11 Bário', 489 | 113: '2. Industrial/2.2 Metálicas/2.2.12 Níobio', 490 | 114: '2. Industrial/2.2 Metálicas/2.2.13 Estanho', 491 | 115: '2. Industrial/2.2 Metálicas/2.2.14 Ouro', 492 | 130: '2. Industrial/2.2 Metálicas/2.2.15 Zinco', 493 | 116: '2. Industrial/2.3 Não Metálicas/Não Metálicas', 494 | 117: '2. Industrial/2.3 Não Metálicas/2.3.01 Minerais Classe 2', 495 | 118: '2. Industrial/2.3 Não Metálicas/2.3.02 Fluor', 496 | 119: '2. Industrial/2.3 Não Metálicas/2.3.03 Fósforo', 497 | 120: '2. Industrial/2.3 Não Metálicas/2.3.04 Gráfita', 498 | 121: '2. Industrial/2.3 Não Metálicas/2.3.05 Silício', 499 | 122: '2. Industrial/2.3 Não Metálicas/2.3.06 Calcário', 500 | 123: '2. Industrial/2.4 Não Identificado/Não Identificado', 501 | 502 | 124: '2. Industrial/2.4 Pedras Preciosas & Rochas Ornamentais/Pedras Preciosas', 503 | 125: '2. Industrial/2.4 Pedras Preciosas & Rochas Ornamentais/Rochas Ornamentais', 504 | 505 | 126: '2. Industrial/2.1 Energéticas/Energéticas', 506 | 127: '2. Industrial/2.1 Energéticas/2.1.01 Carvão mineral', 507 | 128: '2. Industrial/2.1 Energéticas/2.1.02 Urânio', 508 | 129: '2. Industrial/2.1 Energéticas/2.1.03 Gás natural e petróleo', 509 | 201: '1. Garimpo/1.1 Metálicas/Metálicas', 510 | 202: '1. Garimpo/1.1 Metálicas/1.1.03 Outros', 511 | 214: '1. Garimpo/1.1 Metálicas/1.1.02 Estanho', 512 | 215: '1. Garimpo/1.1 Metálicas/1.1.01 Ouro', 513 | 216: '1. Garimpo/1.2 Não Metálicas/Não Metálicas', 514 | 217: '1. Garimpo/1.2 Não Metálicas/1.2.01 Minerais Classe 2', 515 | 218: '1. Garimpo/1.2 Não Metálicas/1.2.02 Outros', 516 | 223: '1. Garimpo/1.3 Pedras Preciosas & Rochas Ornamentais/Pedras Preciosas & Rochas Ornamentais', 517 | 224: '1. Garimpo/1.3 Pedras Preciosas & Rochas Ornamentais/1.3.01 Pedras preciosas', 518 | 225: '1. Garimpo/1.3 Pedras Preciosas & Rochas Ornamentais/1.3.02 Rochas Ornamentais', 519 | 226: '1. Garimpo/1.4 Não Identificado/Não Identificado', 520 | 301: '3. Outros/Outros/Outros', 521 | }, 522 | 523 | }, 524 | 525 | legend: { 526 | params: [ 527 | { 528 | "title": '1. Garimpo', 529 | "layers": [ 530 | ['#e66101', null, '1.1 Metálicas'], 531 | ['#fdb863', null, '1.2 Não Metálicas'], 532 | ['#b2abd2', null, '1.3 Pedras Preciosas & Rochas Ornamentais'], 533 | ['#5e3c99', null, '1.4 Não Identificado'], 534 | ], 535 | "style": { 536 | "backgroundColor": "#ffffff", 537 | "color": "#212121" 538 | }, 539 | "orientation": "vertical" 540 | }, 541 | { 542 | "title": '2. Industrial', 543 | "layers": [ 544 | ['#f4a582', null, '2.2 Metálicas'], 545 | ['#92c5de', null, '2.3 Não Metálicas'], 546 | ['#ca0020', null, '2.1 Energéticas'], 547 | ], 548 | "style": { 549 | "backgroundColor": "#ffffff", 550 | "color": "#212121" 551 | }, 552 | "orientation": "vertical" 553 | }, 554 | { 555 | "title": '3. Outros', 556 | "layers": [ 557 | ['#3caea3', null, '3.1 Outros'], 558 | ], 559 | "style": { 560 | "backgroundColor": "#ffffff", 561 | "color": "#212121" 562 | }, 563 | "orientation": "vertical" 564 | }, 565 | ] 566 | } 567 | }, 568 | 569 | init: function () { 570 | 571 | this.ui.init(); 572 | 573 | }, 574 | 575 | setVersion: function () { 576 | 577 | App.ui.form.labelTitle.setValue('MapBiomas User Toolkit ' + App.options.version); 578 | 579 | }, 580 | 581 | startMap: function (year) { 582 | 583 | Map.centerObject(App.options.data.mined_substance, 5); 584 | 585 | var imageLayer = ui.Map.Layer({ 586 | 'eeObject': App.options.data.mined_substance 587 | .select('mined_substance_' + year) 588 | .sldStyle(App.options.sldStyle), 589 | 'visParams': { 590 | // 'bands': ['mined_substance_' + year], 591 | // 'palette': App.options.palette.mined_substance, 592 | // 'min': App.options.ranges.mined_substance.min, 593 | // 'max': App.options.ranges.mined_substance.max, 594 | 'format': 'png' 595 | }, 596 | 'name': 'Mined Substance', 597 | 'shown': true, 598 | 'opacity': 1.0 599 | }); 600 | 601 | App.ui.clear(); 602 | 603 | Map.setOptions({ 604 | 'styles': { 605 | 'Dark': mapp.getStyle('Dark') 606 | } 607 | }); 608 | 609 | Map.add(imageLayer); 610 | 611 | }, 612 | 613 | formatName: function (name) { 614 | 615 | var formated = name 616 | .toLowerCase() 617 | .replace(/á/g, 'a') 618 | .replace(/à/g, 'a') 619 | .replace(/â/g, 'a') 620 | .replace(/ã/g, 'a') 621 | .replace(/ä/g, 'a') 622 | .replace(/ª/g, 'a') 623 | .replace(/é/g, 'e') 624 | .replace(/ê/g, 'e') 625 | .replace(/í/g, 'i') 626 | .replace(/ó/g, 'o') 627 | .replace(/ô/g, 'o') 628 | .replace(/õ/g, 'o') 629 | .replace(/ú/g, 'u') 630 | .replace(/û/g, 'u') 631 | .replace(/ũ/g, 'u') 632 | .replace(/ç/g, 'c') 633 | .replace(/ñ/g, 'n') 634 | .replace(/&/g, '') 635 | .replace(/@/g, '') 636 | .replace(/ /g, '') 637 | .replace(/["'()\/]/g, ''); 638 | 639 | return formated; 640 | }, 641 | 642 | ui: { 643 | 644 | init: function () { 645 | 646 | this.form.init(); 647 | 648 | }, 649 | 650 | clear: function () { 651 | Map.clear(); 652 | 653 | Map.setOptions({ 654 | 'styles': { 655 | 'Dark': mapp.getStyle('Dark') 656 | } 657 | }); 658 | }, 659 | 660 | setMapbiomasRegion: function (regionName) { 661 | 662 | App.ui.loadCollectionList(regionName); 663 | App.ui.loadTablesNames(regionName); 664 | 665 | }, 666 | 667 | setDataType: function (dataType) { 668 | 669 | App.options.dataType = dataType; 670 | 671 | }, 672 | 673 | loadCollectionList: function (regionName) { 674 | 675 | App.ui.form.selectCollection.setPlaceholder('loading collections...'); 676 | 677 | App.ui.form.selectCollection = ui.Select({ 678 | 'items': Object.keys(App.options.collections[regionName]).reverse(), 679 | 'placeholder': 'select collection', 680 | 'onChange': function (collectioName) { 681 | ee.Number(1).evaluate( 682 | function (a) { 683 | 684 | App.options.data.mined_substance = ee.Image( 685 | App.options.collections[regionName][collectioName].assets.mined_substance); 686 | 687 | var year = App.options.collections[regionName][collectioName] 688 | .periods.mined_substance.slice(-1)[0]; 689 | 690 | App.startMap(year); 691 | } 692 | ); 693 | 694 | App.ui.loadingBox(); 695 | }, 696 | 'style': { 697 | 'stretch': 'horizontal' 698 | } 699 | }); 700 | 701 | App.ui.form.panelCollection.widgets() 702 | .set(1, App.ui.form.selectCollection); 703 | 704 | }, 705 | 706 | loadTablesNames: function (regionName) { 707 | 708 | App.ui.form.selectRegion.setPlaceholder('loading tables names...'); 709 | 710 | var roots = ee.data.getAssetRoots() 711 | .map( 712 | function (obj) { 713 | return obj.id; 714 | }); 715 | 716 | var allTablesNames; 717 | 718 | /** 719 | * Skip the error msg if MAPBIOMAS folder is not found 720 | */ 721 | try { 722 | var tablesNames = ee.data.getList({ 723 | 'id': roots[0] + '/MAPBIOMAS' 724 | }).map( 725 | function (obj) { 726 | return obj.id; 727 | }); 728 | var allTablesNames = App.options.tables[regionName].concat(tablesNames); 729 | } 730 | catch (e) { 731 | var allTablesNames = App.options.tables[regionName]; 732 | } 733 | 734 | App.ui.form.selectFeatureCollections = ui.Select({ 735 | 'items': allTablesNames, 736 | 'placeholder': 'select table', 737 | 'onChange': function (tableName) { 738 | if (tableName != 'None') { 739 | App.options.activeName = tableName; 740 | App.ui.form.panelStates.remove(App.ui.form.labelStates); 741 | App.ui.form.panelStates.remove(App.ui.form.selectStates); 742 | ee.Number(1).evaluate( 743 | function (a) { 744 | var collectioName = App.ui.form.selectCollection.getValue(); 745 | 746 | App.ui.loadTable(tableName); 747 | 748 | App.ui.makeLayersList( 749 | tableName.split('/').slice(-1)[0], 750 | App.options.activeFeature, 751 | App.options.collections[regionName][collectioName] 752 | .periods[App.options.dataType] 753 | ); 754 | 755 | App.ui.loadPropertiesNames(); 756 | 757 | App.ui.form.selectDataType.setDisabled(false); 758 | } 759 | ); 760 | 761 | App.ui.loadingBox(); 762 | } 763 | }, 764 | 'style': { 765 | 'stretch': 'horizontal' 766 | } 767 | }); 768 | 769 | App.ui.form.panelFeatureCollections.widgets() 770 | .set(1, App.ui.form.selectFeatureCollections); 771 | 772 | }, 773 | 774 | loadTableStates: function (tableName) { 775 | 776 | var state = App.ui.form.selectStates.getValue(); 777 | 778 | App.options.table = ee.FeatureCollection(tableName) 779 | .filterMetadata('UF', 'equals', parseInt(App.options.statesNames[state], 10)); 780 | 781 | App.options.activeFeature = App.options.table; 782 | 783 | Map.centerObject(App.options.activeFeature); 784 | 785 | App.ui.clear(); 786 | 787 | Map.addLayer(App.options.activeFeature.style({ 788 | color: 'ff0000', 789 | width: 1, 790 | fillColor: 'ff000033', 791 | }), {}, 792 | tableName.split('/')[3], 793 | true); 794 | 795 | }, 796 | 797 | loadTable: function (tableName) { 798 | 799 | App.options.table = ee.FeatureCollection(tableName); 800 | 801 | App.options.activeFeature = App.options.table; 802 | 803 | Map.centerObject(App.options.activeFeature); 804 | 805 | App.ui.clear(); 806 | 807 | Map.addLayer(App.options.activeFeature.style({ 808 | color: 'ff0000', 809 | width: 1, 810 | fillColor: 'ff000033', 811 | }), {}, 812 | tableName.split('/')[3], 813 | true); 814 | 815 | }, 816 | 817 | loadPropertiesNames: function () { 818 | 819 | App.ui.form.selectProperties.setPlaceholder('loading tables names...'); 820 | 821 | ee.Feature(App.options.table.first()) 822 | .propertyNames() 823 | .evaluate( 824 | function (propertyNames) { 825 | 826 | // print(propertyNames); 827 | 828 | App.ui.form.selectProperties = ui.Select({ 829 | 'items': propertyNames, 830 | 'placeholder': 'select property', 831 | 'onChange': function (propertyName) { 832 | if (propertyName != 'None') { 833 | App.options.propertyName = propertyName; 834 | 835 | ee.Number(1).evaluate( 836 | function (a) { 837 | App.ui.loadFeatureNames(propertyName); 838 | App.ui.form.selectDataType.setDisabled(false); 839 | } 840 | ); 841 | 842 | } 843 | }, 844 | 'style': { 845 | 'stretch': 'horizontal' 846 | } 847 | }); 848 | 849 | App.ui.form.panelProperties.widgets() 850 | .set(1, App.ui.form.selectProperties); 851 | } 852 | ); 853 | 854 | }, 855 | 856 | loadFeatureNames: function () { 857 | 858 | App.ui.form.selectFeature.setPlaceholder('loading feature names...'); 859 | 860 | App.options.table.sort(App.options.propertyName) 861 | .reduceColumns(ee.Reducer.toList(), [App.options.propertyName]) 862 | .get('list') 863 | .evaluate( 864 | function (featureNameList) { 865 | 866 | App.ui.form.selectFeature = ui.Select({ 867 | 'items': featureNameList, 868 | 'placeholder': 'select feature', 869 | 'onChange': function (featureName) { 870 | if (featureName != 'None') { 871 | App.options.featureName = featureName; 872 | 873 | ee.Number(1).evaluate( 874 | function (a) { 875 | var regionName = App.ui.form.selectRegion.getValue(); 876 | var collectionName = App.ui.form.selectCollection.getValue(); 877 | 878 | App.ui.loadFeature(featureName); 879 | 880 | App.ui.makeLayersList( 881 | featureName, 882 | App.options.activeFeature, 883 | App.options.collections[regionName][collectionName] 884 | .periods[App.options.dataType]); 885 | App.ui.form.selectDataType.setDisabled(false); 886 | } 887 | ); 888 | 889 | App.ui.loadingBox(); 890 | } 891 | }, 892 | 'style': { 893 | 'stretch': 'horizontal' 894 | } 895 | }); 896 | 897 | App.ui.form.panelFeature.widgets() 898 | .set(1, App.ui.form.selectFeature); 899 | } 900 | ); 901 | 902 | }, 903 | 904 | loadFeature: function (name) { 905 | 906 | App.options.activeFeature = App.options.table 907 | .filterMetadata(App.options.propertyName, 'equals', name); 908 | 909 | Map.centerObject(App.options.activeFeature); 910 | 911 | App.ui.clear(); 912 | 913 | Map.addLayer(App.options.activeFeature.style({ 914 | color: 'ff0000', 915 | width: 1, 916 | fillColor: 'ff000033', 917 | }), {}, 918 | name, 919 | true); 920 | 921 | }, 922 | 923 | addImageLayer: function (period, label, region) { 924 | 925 | 926 | var image = App.options.data[App.options.dataType] 927 | .select([App.options.bandsNames[App.options.dataType] + '_' + period]) 928 | .clip(region); 929 | 930 | var imageLayer = ui.Map.Layer({ 931 | 'eeObject': image.selfMask().sldStyle(App.options.sldStyle), 932 | 'visParams': { 933 | // 'palette': App.options.palette[App.options.dataType], 934 | // 'min': App.options.ranges[App.options.dataType].min, 935 | // 'max': App.options.ranges[App.options.dataType].max, 936 | 'format': 'png' 937 | }, 938 | 'name': label, 939 | 'shown': true, 940 | 'opacity': 1.0 941 | }); 942 | 943 | Map.layers().insert( 944 | Map.layers().length() - 1, 945 | imageLayer 946 | ); 947 | 948 | }, 949 | 950 | removeImageLayer: function (label) { 951 | 952 | for (var i = 0; i < Map.layers().length(); i++) { 953 | 954 | var layer = Map.layers().get(i); 955 | 956 | if (label === layer.get('name')) { 957 | Map.remove(layer); 958 | } 959 | } 960 | 961 | }, 962 | 963 | manageLayers: function (checked, period, label, region) { 964 | 965 | if (checked) { 966 | App.ui.addImageLayer(period, label, region); 967 | } else { 968 | App.ui.removeImageLayer(label); 969 | } 970 | 971 | }, 972 | 973 | makeLayersList: function (regionName, region, periods) { 974 | // print(regionName, region, periods) 975 | App.ui.form.panelLayersList.clear(); 976 | 977 | periods.forEach( 978 | 979 | function (period, index, array) { 980 | App.ui.form.panelLayersList.add( 981 | ui.Checkbox({ 982 | "label": regionName + ' ' + period, 983 | "value": false, 984 | "onChange": function (checked) { 985 | 986 | App.ui.manageLayers(checked, period, regionName + ' ' + period, region); 987 | 988 | }, 989 | "disabled": false, 990 | "style": { 991 | 'padding': '2px', 992 | 'stretch': 'horizontal', 993 | 'backgroundColor': '#dddddd', 994 | 'fontSize': '12px' 995 | } 996 | }) 997 | ); 998 | 999 | } 1000 | ); 1001 | 1002 | }, 1003 | 1004 | loadingBox: function () { 1005 | App.ui.form.loadingBox = ui.Panel(); 1006 | App.ui.form.loadingBox.add(ui.Label('Loading...')); 1007 | 1008 | Map.add(App.ui.form.loadingBox); 1009 | }, 1010 | 1011 | export2Drive: function () { 1012 | 1013 | var layers = App.ui.form.panelLayersList.widgets(); 1014 | 1015 | var regionName = App.ui.form.selectRegion.getValue(); 1016 | var collectionName = App.ui.form.selectCollection.getValue(); 1017 | 1018 | var featureName = App.formatName(App.ui.form.selectFeature.getValue() || ''); 1019 | 1020 | var bandIds = []; 1021 | 1022 | for (var i = 0; i < layers.length(); i++) { 1023 | 1024 | var selected = layers.get(i).getValue(); 1025 | 1026 | if (selected) { 1027 | 1028 | var period = App.options.collections[regionName][collectionName] 1029 | .periods[App.options.dataType][i]; 1030 | 1031 | var fileName = [regionName, collectionName, App.options.dataType, featureName, period].join('-'); 1032 | 1033 | fileName = fileName.replace(/--/g, '-').replace(/--/g, '-').replace('.', '').replace('_', '-'); 1034 | fileName = App.formatName(fileName); 1035 | 1036 | var data = App.options.data[App.options.dataType] 1037 | .select([App.options.bandsNames[App.options.dataType] + '_' + period]); 1038 | 1039 | var region = App.options.activeFeature.geometry(); 1040 | 1041 | if (App.options.bufferDistance !== 0) { 1042 | data = data.clip(App.options.activeFeature.geometry().buffer(App.options.bufferDistance)); 1043 | region = region.buffer(App.options.bufferDistance); 1044 | } else { 1045 | data = data.clip(App.options.activeFeature.geometry()); 1046 | } 1047 | 1048 | region = region.bounds(); 1049 | 1050 | Export.image.toDrive({ 1051 | image: data, 1052 | description: fileName, 1053 | folder: 'MAPBIOMAS-EXPORT', 1054 | fileNamePrefix: fileName, 1055 | region: region, 1056 | scale: 30, 1057 | maxPixels: 1e13, 1058 | fileFormat: 'GeoTIFF', 1059 | fileDimensions: App.options.fileDimensions[App.options.dataType], 1060 | }); 1061 | 1062 | bandIds.push(App.options.bandsNames[App.options.dataType] + '_' + period); 1063 | } 1064 | } 1065 | 1066 | // Export table 1067 | var territory = ee.Image().paint({ 1068 | 'featureCollection': ee.FeatureCollection(App.options.activeFeature), 1069 | 'color': 1 1070 | }); 1071 | 1072 | var geometry = App.options.activeFeature.geometry().bounds(); 1073 | 1074 | var areas = bandIds.map( 1075 | function (band) { 1076 | 1077 | var image = App.options.data[App.options.dataType].select(band); 1078 | 1079 | var area = Area.calculate({ 1080 | "image": image, 1081 | "territory": territory, 1082 | "geometry": geometry, 1083 | "scale": 30, 1084 | "factor": 1000000, 1085 | "unit": 'kilometers^2' 1086 | }); 1087 | 1088 | area = ee.FeatureCollection(area).map( 1089 | function (feature) { 1090 | 1091 | var className = ee.Dictionary(App.options.className[App.options.dataType]) 1092 | .get(ee.Number(feature.get('class'))); 1093 | 1094 | return feature 1095 | .set('class_name', className) 1096 | .set('band', band); 1097 | } 1098 | ); 1099 | 1100 | return area; 1101 | } 1102 | ); 1103 | 1104 | areas = ee.FeatureCollection(areas).flatten(); 1105 | // print(areas); 1106 | 1107 | var tableName = [regionName, collectionName, App.options.dataType, featureName, 'area'].join('-'); 1108 | 1109 | tableName = tableName.replace(/--/g, '-').replace(/--/g, '-').replace('.', '').replace('_', '-'); 1110 | tableName = App.formatName(tableName); 1111 | 1112 | Export.table.toDrive({ 1113 | 'collection': areas, 1114 | 'description': tableName, 1115 | 'folder': 'MAPBIOMAS-EXPORT', 1116 | 'fileNamePrefix': tableName, 1117 | 'fileFormat': 'CSV', 1118 | 'selectors': [ 1119 | 'class_name', 1120 | 'class', 1121 | 'band', 1122 | 'area', 1123 | 'unit' 1124 | ] 1125 | }); 1126 | 1127 | }, 1128 | 1129 | form: { 1130 | 1131 | init: function () { 1132 | 1133 | var blob = ee.Blob(App.options.logo.uri); 1134 | 1135 | blob.string().evaluate( 1136 | function (str) { 1137 | str = str.replace(/\n/g, ''); 1138 | App.options.logo.base64 = ui.Label({ 1139 | imageUrl: str, 1140 | }); 1141 | App.ui.form.panelLogo.add(App.options.logo.base64); 1142 | } 1143 | ); 1144 | 1145 | App.ui.form.panelMain.add(App.ui.form.panelLogo); 1146 | 1147 | App.ui.form.panelMain.add(App.ui.form.labelTitle); 1148 | App.ui.form.panelMain.add(App.ui.form.labelSubtitle); 1149 | App.ui.form.panelMain.add(App.ui.form.labelLink); 1150 | 1151 | App.ui.form.panelMain.add(App.ui.form.tabs); 1152 | App.ui.form.panelMain.add(App.ui.form.panel1); 1153 | 1154 | App.ui.form.tab1.add(App.ui.form.checkboxTab1); 1155 | App.ui.form.tab2.add(App.ui.form.checkboxTab2); 1156 | 1157 | App.ui.form.tabs.add(App.ui.form.tab1); 1158 | App.ui.form.tabs.add(App.ui.form.tab2); 1159 | 1160 | App.ui.form.panelRegion.add(App.ui.form.labelRegion); 1161 | App.ui.form.panelRegion.add(App.ui.form.selectRegion); 1162 | 1163 | App.ui.form.panelCollection.add(App.ui.form.labelCollection); 1164 | App.ui.form.panelCollection.add(App.ui.form.selectCollection); 1165 | 1166 | App.ui.form.panelFeatureCollections.add(App.ui.form.labelTables); 1167 | App.ui.form.panelFeatureCollections.add(App.ui.form.selectFeatureCollections); 1168 | 1169 | App.ui.form.panelProperties.add(App.ui.form.labelProperties); 1170 | App.ui.form.panelProperties.add(App.ui.form.selectProperties); 1171 | 1172 | App.ui.form.panelFeature.add(App.ui.form.labelFeature); 1173 | App.ui.form.panelFeature.add(App.ui.form.selectFeature); 1174 | 1175 | App.ui.form.panelDataType.add(App.ui.form.labelDataType); 1176 | App.ui.form.panelDataType.add(App.ui.form.selectDataType); 1177 | 1178 | App.ui.form.panelBuffer.add(App.ui.form.labelBuffer); 1179 | App.ui.form.panelBuffer.add(App.ui.form.selectBuffer); 1180 | 1181 | App.ui.form.panelLegend.add(legend.getLegend(App.options.legend.params[0])); 1182 | App.ui.form.panelLegend.add(legend.getLegend(App.options.legend.params[1])); 1183 | App.ui.form.panelLegend.add(legend.getLegend(App.options.legend.params[2])); 1184 | 1185 | // this.panelMain.add(this.panelType); 1186 | App.ui.form.panel1.add(App.ui.form.panelRegion); 1187 | App.ui.form.panel1.add(App.ui.form.panelCollection); 1188 | App.ui.form.panel1.add(App.ui.form.panelFeatureCollections); 1189 | App.ui.form.panel1.add(App.ui.form.panelStates); 1190 | App.ui.form.panel1.add(App.ui.form.panelProperties); 1191 | App.ui.form.panel1.add(App.ui.form.panelFeature); 1192 | App.ui.form.panel1.add(App.ui.form.panelDataType); 1193 | App.ui.form.panel1.add(App.ui.form.panelLegend); 1194 | App.ui.form.panel1.add(App.ui.form.panelBuffer); 1195 | 1196 | App.ui.form.panel1.add(App.ui.form.labelLayers); 1197 | App.ui.form.panel1.add(App.ui.form.panelLayersList); 1198 | 1199 | App.ui.form.panel1.add(App.ui.form.buttonExport2Drive); 1200 | App.ui.form.panel1.add(App.ui.form.labelNotes); 1201 | 1202 | ui.root.add(App.ui.form.panelMain); 1203 | 1204 | }, 1205 | 1206 | panelMain: ui.Panel({ 1207 | 'layout': ui.Panel.Layout.flow('vertical'), 1208 | 'style': { 1209 | 'width': '360px', 1210 | 'position': 'bottom-left', 1211 | 'margin': '0px 0px 0px 0px', 1212 | }, 1213 | }), 1214 | 1215 | panelLogo: ui.Panel({ 1216 | 'layout': ui.Panel.Layout.flow('vertical'), 1217 | 'style': { 1218 | 'stretch': 'horizontal', 1219 | 'margin': '10px 0px 5px 15px', 1220 | }, 1221 | }), 1222 | 1223 | panelStates: ui.Panel({ 1224 | 'layout': ui.Panel.Layout.flow('vertical'), 1225 | 'style': { 1226 | 'stretch': 'horizontal' 1227 | }, 1228 | }), 1229 | 1230 | panelRegion: ui.Panel({ 1231 | 'layout': ui.Panel.Layout.flow('vertical'), 1232 | 'style': { 1233 | 'stretch': 'horizontal' 1234 | }, 1235 | }), 1236 | 1237 | panelCollection: ui.Panel({ 1238 | 'layout': ui.Panel.Layout.flow('vertical'), 1239 | 'style': { 1240 | 'stretch': 'horizontal' 1241 | }, 1242 | }), 1243 | 1244 | panelFeatureCollections: ui.Panel({ 1245 | 'layout': ui.Panel.Layout.flow('vertical'), 1246 | 'style': { 1247 | 'stretch': 'horizontal' 1248 | }, 1249 | }), 1250 | 1251 | panelProperties: ui.Panel({ 1252 | 'layout': ui.Panel.Layout.flow('vertical'), 1253 | 'style': { 1254 | 'stretch': 'horizontal' 1255 | }, 1256 | }), 1257 | 1258 | panelFeature: ui.Panel({ 1259 | 'layout': ui.Panel.Layout.flow('vertical'), 1260 | 'style': { 1261 | 'stretch': 'horizontal' 1262 | }, 1263 | }), 1264 | 1265 | panelDataType: ui.Panel({ 1266 | 'layout': ui.Panel.Layout.flow('vertical'), 1267 | 'style': { 1268 | 'stretch': 'horizontal' 1269 | }, 1270 | }), 1271 | 1272 | panelLegend: ui.Panel({ 1273 | 'layout': ui.Panel.Layout.flow('vertical'), 1274 | 'style': { 1275 | 'stretch': 'vertical', 1276 | 'position': 'bottom-left' 1277 | }, 1278 | }), 1279 | 1280 | panelBuffer: ui.Panel({ 1281 | 'layout': ui.Panel.Layout.flow('vertical'), 1282 | 'style': { 1283 | 'stretch': 'horizontal' 1284 | }, 1285 | }), 1286 | 1287 | panelLayersList: ui.Panel({ 1288 | 'layout': ui.Panel.Layout.flow('vertical'), 1289 | 'style': { 1290 | 'height': '200px', 1291 | 'stretch': 'vertical', 1292 | 'backgroundColor': '#cccccc', 1293 | }, 1294 | }), 1295 | 1296 | labelRegion: ui.Label('Region', { 1297 | // 'fontWeight': 'bold', 1298 | // 'padding': '1px', 1299 | 'fontSize': '16px' 1300 | }), 1301 | 1302 | labelCollection: ui.Label('Collection', { 1303 | // 'fontWeight': 'bold', 1304 | // 'padding': '1px', 1305 | 'fontSize': '16px' 1306 | }), 1307 | 1308 | labelTitle: ui.Label('MapBiomas User Toolkit', { 1309 | 'fontWeight': 'bold', 1310 | // 'padding': '1px', 1311 | 'fontSize': '16px' 1312 | }), 1313 | 1314 | labelSubtitle: ui.Label('Mining', { 1315 | // 'fontWeight': 'bold', 1316 | // 'padding': '1px', 1317 | 'fontSize': '14px' 1318 | }), 1319 | 1320 | labelLink: ui.Label('Legend codes', { 1321 | // 'fontWeight': 'bold', 1322 | // 'padding': '1px', 1323 | 'fontSize': '10px' 1324 | }, 1325 | 'https://mapbiomas.org/codigos-de-legenda?cama_set_language=pt-BR' 1326 | ), 1327 | 1328 | labelType: ui.Label('Type:', { 1329 | // 'padding': '1px', 1330 | 'fontSize': '16px' 1331 | }), 1332 | 1333 | labelTables: ui.Label('Tables:', { 1334 | // 'padding': '1px', 1335 | 'fontSize': '16px' 1336 | }), 1337 | 1338 | labelProperties: ui.Label('Properties:', { 1339 | // 'padding': '1px', 1340 | 'fontSize': '16px' 1341 | }), 1342 | 1343 | labelFeature: ui.Label('Features:', { 1344 | // 'padding': '1px', 1345 | 'fontSize': '16px' 1346 | }), 1347 | 1348 | labelDataType: ui.Label('Data Type:', { 1349 | // 'padding': '1px', 1350 | 'fontSize': '16px' 1351 | }), 1352 | 1353 | labelBuffer: ui.Label('Buffer:', { 1354 | // 'padding': '1px', 1355 | 'fontSize': '16px' 1356 | }), 1357 | 1358 | labelLayers: ui.Label('Layers:', { 1359 | // 'padding': '1px', 1360 | 'fontSize': '16px' 1361 | }), 1362 | 1363 | labelNotes: ui.Label('Go to TASK tab in the up-rght corner and click RUN', { 1364 | // 'padding': '1px', 1365 | 'fontSize': '16px' 1366 | }), 1367 | 1368 | labelStates: ui.Label('States:', { 1369 | // 'padding': '1px', 1370 | 'fontSize': '16px' 1371 | }), 1372 | 1373 | selectName: ui.Select({ 1374 | 'items': ['None'], 1375 | 'placeholder': 'None', 1376 | 'style': { 1377 | 'stretch': 'horizontal' 1378 | } 1379 | }), 1380 | 1381 | selectCollection: ui.Select({ 1382 | 'items': [], 1383 | 'placeholder': 'None', 1384 | 'style': { 1385 | 'stretch': 'horizontal' 1386 | }, 1387 | }), 1388 | 1389 | selectRegion: ui.Select({ 1390 | 'items': [ 1391 | // 'mapbiomas-amazon', 1392 | // 'mapbiomas-atlantic-forest', 1393 | 'mapbiomas-brazil', 1394 | // 'mapbiomas-chaco', 1395 | // 'mapbiomas-indonesia', 1396 | // 'mapbiomas-pampa', 1397 | ], 1398 | 'placeholder': 'None', 1399 | 'style': { 1400 | 'stretch': 'horizontal' 1401 | }, 1402 | 'onChange': function (region) { 1403 | 1404 | ee.Number(1).evaluate( 1405 | function (a) { 1406 | App.ui.setMapbiomasRegion(region); 1407 | } 1408 | ); 1409 | 1410 | }, 1411 | }), 1412 | 1413 | selectFeatureCollections: ui.Select({ 1414 | 'items': ['None'], 1415 | 'placeholder': 'None', 1416 | 'style': { 1417 | 'stretch': 'horizontal' 1418 | } 1419 | }), 1420 | 1421 | selectFeature: ui.Select({ 1422 | 'items': ['None'], 1423 | 'placeholder': 'None', 1424 | 'style': { 1425 | 'stretch': 'horizontal' 1426 | } 1427 | }), 1428 | 1429 | selectProperties: ui.Select({ 1430 | 'items': ['None'], 1431 | 'placeholder': 'None', 1432 | 'style': { 1433 | 'stretch': 'horizontal' 1434 | } 1435 | }), 1436 | 1437 | selectDataType: ui.Select({ 1438 | 'items': [ 1439 | 'mined_substance', 1440 | ], 1441 | 'placeholder': 'Data type', 1442 | 'style': { 1443 | 'stretch': 'horizontal' 1444 | }, 1445 | 'disabled': true, 1446 | 'onChange': function (dataType) { 1447 | 1448 | var regionName = App.ui.form.selectRegion.getValue(); 1449 | var collectionName = App.ui.form.selectCollection.getValue(); 1450 | 1451 | App.ui.setDataType(dataType); 1452 | 1453 | App.ui.makeLayersList( 1454 | App.options.activeName.split('/').slice(-1)[0], 1455 | App.options.activeFeature, 1456 | App.options.collections[regionName][collectionName].periods[dataType]); 1457 | 1458 | }, 1459 | }), 1460 | 1461 | selectBuffer: ui.Select({ 1462 | 'items': [ 1463 | 'None', 1464 | '1km', 1465 | '2km', 1466 | '3km', 1467 | '4km', 1468 | '5km', 1469 | ], 1470 | 'placeholder': 'None', 1471 | 'style': { 1472 | 'stretch': 'horizontal' 1473 | }, 1474 | 'onChange': function (distance) { 1475 | var distances = { 1476 | 'None': 0, 1477 | '1km': 1000, 1478 | '2km': 2000, 1479 | '3km': 3000, 1480 | '4km': 4000, 1481 | '5km': 5000, 1482 | }; 1483 | 1484 | App.options.bufferDistance = distances[distance]; 1485 | }, 1486 | }), 1487 | 1488 | selectStates: ui.Select({ 1489 | 'items': [ 1490 | 'None', 'Acre', 'Alagoas', 'Amazonas', 'Amapá', 'Bahia', 1491 | 'Ceará', 'Distrito Federal', 'Espírito Santo', 'Goiás', 'Maranhão', 1492 | 'Minas Gerais', 'Mato Grosso do Sul', 'Mato Grosso', 'Pará', 'Paraíba', 1493 | 'Pernambuco', 'Piauí', 'Paraná', 'Rio de Janeiro', 'Rio Grande do Norte', 1494 | 'Rondônia', 'Roraima', 'Rio Grande do Sul', 'Santa Catarina', 'Sergipe', 1495 | 'São Paulo', 'Tocantins' 1496 | ], 1497 | 'placeholder': 'select state', 1498 | 'onChange': function (state) { 1499 | if (state != 'None') { 1500 | 1501 | ee.Number(1).evaluate( 1502 | function (a) { 1503 | App.ui.loadTableStates(App.options.activeName); 1504 | App.ui.makeLayersList(App.options.activeName.split('/')[3], App.options.activeFeature, App.options.periods[App.options.dataType]); 1505 | App.ui.loadPropertiesNames(); 1506 | App.ui.form.selectDataType.setDisabled(false); 1507 | } 1508 | ); 1509 | 1510 | App.ui.loadingBox(); 1511 | } 1512 | }, 1513 | 'style': { 1514 | 'stretch': 'horizontal' 1515 | } 1516 | }), 1517 | 1518 | buttonExport2Drive: ui.Button({ 1519 | "label": "Export images to Google Drive", 1520 | "onClick": function () { 1521 | App.ui.export2Drive(); 1522 | }, 1523 | "disabled": false, 1524 | "style": { 1525 | // 'padding': '2px', 1526 | 'stretch': 'horizontal' 1527 | } 1528 | }), 1529 | 1530 | // panels and tabs 1531 | tabs: ui.Panel({ 1532 | layout: ui.Panel.Layout.flow('horizontal') 1533 | }), 1534 | 1535 | checkboxTab1: ui.Checkbox({ 1536 | 'label': ' Toolkit ', 1537 | 'style': { 1538 | 'margin': '5px 0px 5px -16px', 1539 | 'stretch': 'horizontal', 1540 | 'backgroundColor': '#00000000', 1541 | }, 1542 | 'onChange': function (checked) { 1543 | if (checked) { 1544 | App.ui.form.checkboxTab2.setValue(false); 1545 | App.ui.form.tab1.style().set('border', '1px solid #808080'); 1546 | App.ui.form.tab2.style().set('border', '1px solid #80808033'); 1547 | 1548 | App.ui.form.panelMain.remove(App.ui.form.panel2); 1549 | App.ui.form.panelMain.add(App.ui.form.panel1); 1550 | } 1551 | } 1552 | }), 1553 | 1554 | checkboxTab2: ui.Checkbox({ 1555 | 'label': ' Direct Link', 1556 | 'style': { 1557 | 'margin': '5px 20px 5px -16px', 1558 | 'stretch': 'horizontal', 1559 | 'backgroundColor': '#00000000', 1560 | }, 1561 | 'onChange': function (checked) { 1562 | if (checked) { 1563 | App.ui.form.checkboxTab1.setValue(false); 1564 | App.ui.form.tab1.style().set('border', '1px solid #80808033'); 1565 | App.ui.form.tab2.style().set('border', '1px solid #808080'); 1566 | 1567 | App.ui.form.panelMain.remove(App.ui.form.panel1); 1568 | App.ui.form.panelMain.add(App.ui.form.panel2); 1569 | } 1570 | 1571 | } 1572 | }), 1573 | 1574 | tab1: ui.Panel({ 1575 | 'style': { 1576 | 'width': '100px', 1577 | 'backgroundColor': '#dddddd00', 1578 | 'stretch': 'horizontal', 1579 | 'border': '1px solid #808080', 1580 | 'margin': '0px 0px 0px 6px' 1581 | }, 1582 | }), 1583 | 1584 | tab2: ui.Panel({ 1585 | 'style': { 1586 | 'width': '100px', 1587 | 'backgroundColor': '#dddddd00', 1588 | 'stretch': 'horizontal', 1589 | 'border': '1px solid #80808033', 1590 | } 1591 | }), 1592 | 1593 | panel1: ui.Panel({ 1594 | style: { 1595 | 'stretch': 'both' 1596 | } 1597 | }), 1598 | 1599 | panel2: ui.Panel({ 1600 | widgets: [ 1601 | ui.Label('Brazil'), 1602 | ui.Panel({ 1603 | widgets: [ 1604 | ui.Label({ value: 'Data will be available soon', targetUrl: '' }), 1605 | // ui.Label({ value: '1985-2022 (shp)', targetUrl: '' }), 1606 | ], 1607 | 'layout': ui.Panel.Layout.flow('horizontal', true), 1608 | style: { 1609 | 'border': '1px grey solid', 1610 | 'margin': '0px 6px 0px 6px' 1611 | } 1612 | }), 1613 | ], 1614 | style: { 1615 | 'stretch': 'both' 1616 | } 1617 | }), 1618 | 1619 | }, 1620 | } 1621 | }; 1622 | 1623 | App.init(); 1624 | 1625 | App.setVersion(); --------------------------------------------------------------------------------