Skip to content

Commit 0409d0e

Browse files
committed
updated examples
1 parent ed13b9a commit 0409d0e

File tree

11 files changed

+2042
-17
lines changed

11 files changed

+2042
-17
lines changed
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
/**** Start of imports. If edited, may not auto-convert in the playground. ****/
2-
var elevation = ee.ImageCollection("projects/sat-io/open-datasets/landfire/topographic/ELEV"),
3-
aspect = ee.ImageCollection("projects/sat-io/open-datasets/landfire/topographic/ASP"),
4-
slope_degrees = ee.ImageCollection("projects/sat-io/open-datasets/landfire/topographic/SLP"),
5-
slope_perc_rise = ee.ImageCollection("projects/sat-io/open-datasets/landfire/topographic/SlpP");
2+
var asp = ee.ImageCollection("projects/sat-io/open-datasets/landfire/TOPOGRAPHY/ASP"),
3+
elev = ee.ImageCollection("projects/sat-io/open-datasets/landfire/TOPOGRAPHY/ELEV"),
4+
slpd = ee.ImageCollection("projects/sat-io/open-datasets/landfire/TOPOGRAPHY/SLPD"),
5+
slpp = ee.ImageCollection("projects/sat-io/open-datasets/landfire/TOPOGRAPHY/SLPP");
66
/***** End of imports. If edited, may not auto-convert in the playground. *****/
77
//Import palette
88
var palettes = require('users/gena/packages:palettes')
99

1010
// Topographic
11-
Map.addLayer(elevation.mosaic().mask(elevation.mosaic().neq(32767)),{'min':2,'max':3500,palette: palettes.cmocean.Amp[7]},'Elevation')
12-
Map.addLayer(aspect.mosaic().mask(aspect.mosaic().neq(32767)),{'min':2,'max':174,palette: palettes.cmocean.Haline[7]},'Aspect')
11+
Map.addLayer(elev.mosaic().mask(elev.mosaic().neq(32767)),{'min':2,'max':3500,palette: palettes.cmocean.Amp[7]},'Elevation')
12+
Map.addLayer(asp.mosaic().mask(asp.mosaic().neq(32767)),{'min':2,'max':174,palette: palettes.cmocean.Haline[7]},'Aspect')

awesome-gee-catalog-examples/agriculture-vegetation-forestry/LANDFIRE-VEGETATION

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**** Start of imports. If edited, may not auto-convert in the playground. ****/
2-
var evc = ee.ImageCollection("projects/sat-io/open-datasets/landfire/vegetation/EVC"),
3-
evh = ee.ImageCollection("projects/sat-io/open-datasets/landfire/vegetation/EVH"),
4-
evt = ee.ImageCollection("projects/sat-io/open-datasets/landfire/vegetation/EVT");
2+
var evc = ee.ImageCollection("projects/sat-io/open-datasets/landfire/VEGETATION/EVC"),
3+
evh = ee.ImageCollection("projects/sat-io/open-datasets/landfire/VEGETATION/EVH"),
4+
evt = ee.ImageCollection("projects/sat-io/open-datasets/landfire/VEGETATION/EVT");
55
/***** End of imports. If edited, may not auto-convert in the playground. *****/
66
//Import palette
77
var palettes = require('users/gena/packages:palettes');
Lines changed: 193 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,193 @@
1+
/**** Start of imports. If edited, may not auto-convert in the playground. ****/
2+
var enhancedTCC = ee.Image("projects/sat-io/open-datasets/USGS/EnhancedTCC2011");
3+
/***** End of imports. If edited, may not auto-convert in the playground. *****/
4+
// Define a color palette for tree canopy percentage
5+
var tccPalette = [
6+
'#FFFFFF', // 0% - white
7+
'#EDF8E9', // Very light green
8+
'#C7E9C0',
9+
'#A1D99B',
10+
'#74C476',
11+
'#41AB5D',
12+
'#238B45',
13+
'#006D2C', // Dark green
14+
'#00441B' // Very dark green - 100%
15+
];
16+
17+
// Set visualization parameters
18+
var visParams = {
19+
min: 0,
20+
max: 100,
21+
palette: tccPalette,
22+
opacity: 0.9
23+
};
24+
25+
// Add the UNMASKED dataset to the map - this is key for seeing all values
26+
// We'll handle NoData values (255) in the inspection itself, not in visualization
27+
Map.addLayer(enhancedTCC, visParams, 'Enhanced Urban Tree Canopy Cover');
28+
29+
// Set map center to Washington DC area
30+
Map.setCenter(-77.0369, 38.9072, 10);
31+
32+
// Create a panel to display the tree canopy percentage
33+
var panel = ui.Panel({
34+
style: {
35+
position: 'top-right',
36+
padding: '8px 15px',
37+
width: '300px'
38+
}
39+
});
40+
41+
// Add a title to the panel
42+
var panelTitle = ui.Label('Tree Canopy Cover Inspector', {
43+
fontWeight: 'bold',
44+
fontSize: '16px',
45+
margin: '0 0 8px 0'
46+
});
47+
panel.add(panelTitle);
48+
49+
// Add instructions
50+
var instructions = ui.Label('Click anywhere on the map to see the tree canopy percentage. Wait for value to Load', {
51+
fontSize: '12px',
52+
margin: '0 0 10px 0'
53+
});
54+
panel.add(instructions);
55+
56+
// Create labels for displaying the clicked location and value
57+
var valueLabel = ui.Label('', {fontSize: '14px', margin: '5px 0'});
58+
var coordLabel = ui.Label('', {fontSize: '12px', margin: '5px 0'});
59+
panel.add(valueLabel);
60+
panel.add(coordLabel);
61+
62+
// Add the panel to the map
63+
Map.add(panel);
64+
65+
// Create a variable to store the current inspection point
66+
var inspectionPoint = null;
67+
68+
// Handle map clicks - active immediately
69+
Map.onClick(function(coords) {
70+
// Get the coordinates of the clicked point
71+
var point = ee.Geometry.Point(coords.lon, coords.lat);
72+
73+
// Remove previous inspection point if exists
74+
if (inspectionPoint) {
75+
Map.layers().remove(inspectionPoint);
76+
}
77+
78+
// Add a new point at the click location with a plus sign style
79+
inspectionPoint = ui.Map.Layer(point, {
80+
color: 'red',
81+
pointSize: 6,
82+
pointShape: 'cross' // This creates a plus sign
83+
}, 'Inspection Point');
84+
85+
Map.layers().set(Map.layers().length(), inspectionPoint);
86+
87+
// Try a different sampling approach
88+
// Create a small buffer around the clicked point to ensure we capture data
89+
var buffer = point.buffer(30);
90+
91+
// Use reduceRegion instead of sample
92+
var tccValue = enhancedTCC.reduceRegion({
93+
reducer: ee.Reducer.first(),
94+
geometry: point,
95+
scale: 30,
96+
maxPixels: 1e9
97+
});
98+
99+
// Get the value
100+
tccValue.evaluate(function(result) {
101+
if (result && result.b1 !== null && result.b1 !== undefined) {
102+
// Check if it's NoData (255)
103+
if (result.b1 === 255) {
104+
valueLabel.setValue('No data available at this point');
105+
} else {
106+
// Round to nearest whole number for display
107+
var roundedValue = Math.round(result.b1);
108+
valueLabel.setValue('Tree Canopy Cover: ' + roundedValue + '%');
109+
}
110+
111+
// Update coordinate display
112+
coordLabel.setValue('Location: ' + coords.lon.toFixed(4) + ', ' + coords.lat.toFixed(4));
113+
} else {
114+
valueLabel.setValue('No data available at this point');
115+
coordLabel.setValue('Location: ' + coords.lon.toFixed(4) + ', ' + coords.lat.toFixed(4));
116+
117+
// Try a slightly different approach with a small buffer
118+
enhancedTCC.reduceRegion({
119+
reducer: ee.Reducer.mean(),
120+
geometry: buffer,
121+
scale: 30,
122+
maxPixels: 1e9
123+
}).evaluate(function(bufferResult) {
124+
if (bufferResult && bufferResult.b1 !== null && bufferResult.b1 !== undefined && bufferResult.b1 !== 255) {
125+
var roundedValue = Math.round(bufferResult.b1);
126+
valueLabel.setValue('Tree Canopy Cover (area average): ' + roundedValue + '%');
127+
}
128+
});
129+
}
130+
});
131+
});
132+
133+
// Add a title and label for the legend
134+
var title = ui.Label('Enhanced National-Scale Urban Tree Canopy Cover (2011)',
135+
{fontWeight: 'bold', fontSize: '16px', margin: '0 0 4px 0'});
136+
137+
var subtitle = ui.Label('Values represent percent tree canopy cover (0-100%)',
138+
{fontSize: '13px', margin: '0 0 15px 0'});
139+
140+
// Create a color bar for the legend
141+
var makeColorBar = function(palette) {
142+
var colorBar = ui.Thumbnail({
143+
image: ee.Image.pixelLonLat().select(0),
144+
params: {
145+
bbox: [0, 0, 1, 0.1],
146+
dimensions: '300x20',
147+
format: 'png',
148+
min: 0,
149+
max: 1,
150+
palette: palette
151+
},
152+
style: {stretch: 'horizontal', margin: '0px 8px'}
153+
});
154+
return colorBar;
155+
};
156+
157+
// Create a panel with a legend
158+
var legend = ui.Panel({
159+
style: {
160+
position: 'bottom-left',
161+
padding: '8px 15px'
162+
}
163+
});
164+
165+
// Create legend title and add the colorbar
166+
legend.add(title);
167+
legend.add(subtitle);
168+
legend.add(makeColorBar(tccPalette));
169+
170+
// Add labels for the legend
171+
var legendLabels = ui.Panel({
172+
widgets: [
173+
ui.Label('0%', {margin: '4px 0'}),
174+
ui.Label('', {margin: '4px 20px'}),
175+
ui.Label('50%', {margin: '4px 0', textAlign: 'center', stretch: 'horizontal'}),
176+
ui.Label('', {margin: '4px 20px'}),
177+
ui.Label('100%', {margin: '4px 0'})
178+
],
179+
layout: ui.Panel.Layout.flow('horizontal')
180+
});
181+
182+
legend.add(legendLabels);
183+
184+
// Add the legend panel to the map
185+
Map.add(legend);
186+
187+
// Add a source attribution label
188+
var source = ui.Label('Source: Corro et al. (2025) Enhanced national-scale urban tree canopy cover dataset',
189+
{fontSize: '10px', position: 'bottom-right', padding: '3px 8px'});
190+
Map.add(source);
191+
Map.setCenter(-99.0530,39.484,5)
192+
var snazzy = require("users/aazuspan/snazzy:styles");
193+
snazzy.addStyle("https://snazzymaps.com/style/38/shades-of-grey", "Greyscale");

awesome-gee-catalog-examples/analysis-ready-data/SWISSTOPO-S2-SR-HARMONIZED

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ Map.centerObject(collection.first(),8)
66

77
print(collection.aggregate_histogram('pixel_size_meter'))
88

9-
var collection_3b = collection.filter(ee.Filter.eq('pixel_size_meter',20))
10-
var collection_10b = collection.filter(ee.Filter.neq('pixel_size_meter',20))
9+
var collection_20m = collection.filter(ee.Filter.eq('pixel_size_meter',20))
10+
var collection_10m = collection.filter(ee.Filter.neq('pixel_size_meter',20))
1111

12-
Map.addLayer(collection_10b.filterDate('2024-07-01','2024-07-30').median(),vis,'Collection Mosaic Month')
12+
Map.addLayer(collection_10m.filterDate('2024-07-01','2024-07-30').median(),vis,'Collection Mosaic Month')
1313

1414
var snazzy = require("users/aazuspan/snazzy:styles");
1515
snazzy.addStyle("https://snazzymaps.com/style/38/shades-of-grey", "Greyscale");
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
var DEM = ee.ImageCollection("projects/sat-io/open-datasets/Tinitaly_DTM")
2+
print(DEM);
3+
4+
var elevationVis = {
5+
min: -30.0,
6+
max: 1200.0,
7+
palette: ["#317605","f5cf13","b45504","#ffffff"],
8+
};
9+
10+
Map.setCenter(13.58, 42.386, 7);
11+
Map.addLayer(DEM, elevationVis, 'Tinitaly 10m');

0 commit comments

Comments
 (0)