samapriya / awesome-gee-community-datasets

Community Datasets added by users and made available for use at large
https://gee-community-catalog.org/
Creative Commons Attribution 4.0 International
754 stars 120 forks source link

Areas of global conservation value #275

Open pinkychow1010 opened 1 month ago

pinkychow1010 commented 1 month ago

Contact Details

pinkychow1010@gmail.com

Provide Dataset Link

https://gee-community-catalog.org/projects/gci/?h=conservat

Describe the example

Addressing Conservation Priorities

This script aims to combine forest vulnerability modelling together with conservation value to locate areas in Brazil calling for conservation efforts.

// Study Site: Brazil
var admin1 = ee.FeatureCollection("projects/sat-io/open-datasets/geoboundaries/HPSCGS-ADM1");
var geometry = admin1.filter(ee.Filter.eq('shapeGroup', 'BRA'));

// Load data on conservation values
var biodiv = ee.Image("projects/sat-io/open-datasets/naturemap/biodiversity/minshort_speciestargets_esh10km_repruns10_ranked").clip(geometry);
var biodivcarbon = ee.Image("projects/sat-io/open-datasets/naturemap/biodiversity-carbon/minshort_speciestargets_carbon_esh10km_repruns10_ranked").clip(geometry);
var biodivwater = ee.Image("projects/sat-io/open-datasets/naturemap/biodiversity-water/minshort_speciestargets_water_esh10km_repruns10_ranked").clip(geometry);
var biodivcarbonwater = ee.Image("projects/sat-io/open-datasets/naturemap/biodiversity-carbon-water/minshort_speciestargets_carbon_water_esh10km_repruns10_ranked").clip(geometry);

// Visualization params
var vis = {min: 1, max: 100, palette:[
  '7a0403','c92903','f56918','fbb938','c9ef34','74fe5d','1be5b5','35abf8','4662d8','30123b'
]};

var biodivvis = {min: 1, max: 100, palette:[
  '#FF0000',  // Bright Red
  '#FF3333',  // Red
  '#FF6666',  // Light Salmon
  '#FF9999',  // Light Coral
  '#FFCCCC',  // Light Red
  '#FFE5E5',  // Very Light Red
  '#FFFFFF'   // White
]};

var watervis = {min: 1, max: 100, palette:[
  '#0000FF',  // Bright Blue
  '#3333FF',  // Blue
  '#6666FF',  // Slate Blue
  '#9999FF',  // Medium Slate Blue
  '#CCCCFF',  // Light Blue
  '#E5E5FF',  // Very Light Blue
  '#FFFFFF'   // White
]};

var carbonvis = {min: 1, max: 70, palette:[
  '#00FF00',  // Bright Green
  '#33FF33',  // Lime Green
  '#66FF66',  // Light Green
  '#99FF99',  // Pale Green
  '#CCFFCC',  // Light Green
  '#E5FFE5',  // Very Light Green
  '#FFFFFF'   // White
]};

// Create two maps
var leftMap = ui.Map();
var rightMap = ui.Map();

// Add layers to the left map
leftMap.addLayer(biodiv, vis, "Biodiversity", false);
leftMap.addLayer(biodivcarbon, vis, "Biodiversity and Carbon", false);
leftMap.addLayer(biodivwater, vis, "Biodiversity and Water", false);
leftMap.addLayer(biodivcarbonwater, vis, "Biodiversity, Water and Carbon", false);

// Calculate Forest Vulnerability
// Load and preprocess the land-based travel speed image
var landBasedTravelSpeed = ee.Image('Oxford/MAP/friction_surface_2019')
  .select('friction')
  .clip(geometry);

// Define urban areas as the source for cost surface calculation
var urbanAreas = ee.ImageCollection('projects/sat-io/open-datasets/ORNL/LANDSCAN_GLOBAL')
  .sort('system:time_start', false)
  .first()
  .gt(1)
  .clip(geometry);

// Compute the cumulative cost surface from urban areas
var costSurface = landBasedTravelSpeed.cumulativeCost({
  source: urbanAreas,
  maxDistance: 500000, // Maximum distance in meters
  geodeticDistance: true
}).clip(geometry);

// Define criteria for conservation priorities
// Compute mask
var vulnerable = costSurface.log().focalMean(5).lt(7);
var forest = ee.Image("users/nlang/ETH_GlobalCanopyHeight_2020_10m_v1").focalMean(5).gt(5);
var highValue = biodivcarbonwater.focalMean(5).lt(30);

var mask = vulnerable.and(forest).and(highValue);

// Visualize Conservation Priority Areas
leftMap.addLayer(
  biodiv.updateMask(mask),
  biodivvis, "Conservation Site (Biodiversity)",
  false
  );

leftMap.addLayer(
  biodivcarbon.updateMask(mask), 
  carbonvis, "Conservation Site (Biodiversity, Carbon)",
  true
  );

leftMap.addLayer(
  biodivwater.updateMask(mask),
  watervis, 
  "Conservation Site (Biodiversity, Water)",
  true, 0.5
  );

leftMap.addLayer(
  biodivcarbonwater.updateMask(mask), 
  vis, 
  "Conservation Site (Biodiversity, Carbon, Water)",
  false
  );

// Visualize protected areas
var protectedAreas = ui.Map.FeatureViewLayer('WCMC/WDPA/current/polygons_FeatureView');

protectedAreas.setVisParams({
  color: '#262626',
  fillColor: '#262626',
  opacity: 1
});

protectedAreas.setName('WDPA Protected Areas');
leftMap.add(protectedAreas);

// Visualize Brazil
var styled = geometry.style({color: 'white', fillColor: "#00000000"});
leftMap.addLayer(styled, {}, "Brazil");

// Custom base map
var grayscaleBasemap = [
  {   // Dial down the map saturation.
  stylers: [ { saturation: -100} ,{ lightness: -80 } ]
  },{ // Dial down the label darkness.
  elementType: 'labels',
  stylers: [ { lightness: 20 } ]
  },{ // Simplify the road geometries.
  featureType: 'road',
  elementType: 'geometry',
  stylers: [ { visibility: 'simplified' } ]
  },{ // Turn off road labels.
  featureType: 'road',
  elementType: 'labels',
  stylers: [ { visibility: 'off' } ]
  },{ // Turn off all icons.
  elementType: 'labels.icon',
  stylers: [ { visibility: 'on' } ]
  },{ // Turn off all POIs.
  featureType: 'poi',
  elementType: 'all',
  stylers: [ { visibility: 'off' }]
  }
];

// Visualizing conservation priorities in a split map
// Set the base map for the right map to satellite
leftMap.setOptions('Gray', {'Gray': grayscaleBasemap});
rightMap.setOptions('SATELLITE');

// Link both map
var linker = ui.Map.Linker([leftMap, rightMap]);

// Create a split panel
var splitPanel = ui.SplitPanel({
  firstPanel: leftMap,
  secondPanel: rightMap,
  orientation: 'horizontal',
  wipe: true,
  style: {stretch: 'both'}
});

// Add the split panel to the ui.root
ui.root.clear();
ui.root.add(splitPanel);

// Center the maps on the geometry and set the base map options
leftMap.centerObject(geometry, 5);

Code of Conduct

samapriya commented 1 month ago

I could not get this code to work are you sure this is working at your end? Getting this error message

Conservation Site (Biodiversity, Water): Tile error: Asset 'Oxford/MAP/friction_surface_2019@1641990724602367' is corrupted
Conservation Site (Biodiversity, Carbon): Tile error: Asset 'Oxford/MAP/friction_surface_2019@1641990724602367' is corrupted
Conservation Site (Biodiversity, Water): Tile error: Asset 'Oxford/MAP/friction_surface_2019@1641990724602367' is corrupted
Conservation Site (Biodiversity, Carbon): Tile error: Asset 'Oxford/MAP/friction_surface_2019@1641990724602367' is corrupted
pinkychow1010 commented 1 month ago

It worked for me but when I re-run it just now, indeed, it seems to be some issues on the dataset itself. Do you have suggestions to adjust or just left it as I cannot fix the issues on the dataset side unfortunately.

samapriya commented 5 days ago

Seems the dataset corruption is an issue that the Earth Engine team is aware of keeping the issue open till they fix it and till the example can be migrated. Thank you