Public
Edited
Jul 7, 2024
2 forks
1 star
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
{
// remove previous element
document.getElementById('cesiumContainer2').replaceChildren();

// Initialize the Cesium Viewer in the HTML element with the `cesiumContainer` ID.
const viewer = new Cesium.Viewer('cesiumContainer2', {
//terrainProvider: Cesium.createWorldTerrain(),
timeline: false,
animation: false,
sceneModePicker: false,
baseLayerPicker: false
});

// Fly the camera to San Francisco at the given longitude, latitude, and height.
viewer.camera.flyTo({
destination : Cesium.Cartesian3.fromArray([3979224, -9186, 4968214]),
orientation : {
heading : Cesium.Math.toRadians(45.0),
pitch : Cesium.Math.toRadians(-10.0),
}
});

// Add Earth Engine layer on top
const provider = new Cesium.UrlTemplateImageryProvider({
url : imageWater.getMap().urlFormat,
maximumLevel: 200,
});
const layer = new Cesium.ImageryLayer(provider);
viewer.imageryLayers.add(layer);
}
Insert cell
imageWater = {
var waterOccurrence = ee.Image("JRC/GSW1_3/GlobalSurfaceWater").select('occurrence')
.divide(100).unmask(0).resample('bilinear')
//.convolve(ee.Kernel.gaussian(45, 30, 'meters'))
//.reduceNeighborhood(ee.Reducer.mean(), ee.Kernel.circle(45, 'meters'))
.rename('occurrence')

waterOccurrence = waterOccurrence.updateMask(waterOccurrence.unitScale(0, 0.02))
var waterOccurrenceMin = 0.02
var palette = ["2171b5", "4292c6", "6baed6", "9ecae1", "c6dbef", "deebf7", "f7fbff"]
var rgb = ee.Image(1).subtract(waterOccurrence)
.mask(waterOccurrence.unitScale(waterOccurrenceMin, waterOccurrenceMin + 0.2))
.visualize({ palette: palette, min: 0, max: 1 })

var land = ee.Image("users/gena/land_polygons_image").mask()

return rgb.updateMask(rgb.mask().multiply(land))
}
Insert cell
Cesium = import("https://esm.run/cesium@1.107");
Insert cell
import {ee} from '@gena/ee'
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more