!uv pip install leafmap jupyterlab earthengine-api localtileserver
import leafmap
import ipywidgets as widgets
from IPython.display import display
import leafmap
m = leafmap.Map()
m.add_overture_3d_buildings()
m
Alpha Earth
OVERVIEW = 9
BAND = 1
YEAR = 2017
tif_path = f"/content/output-{OVERVIEW}-{BAND}-{YEAR}.tif"
if not os.path.exists(tif_path):
url = f"hf://datasets/stateofmaryland/Google-Alpha-Earth-MD-data/google-alpha-earth-md-overview-{OVERVIEW}.zarr"
ds = xr.open_zarr(url)
ds = ds.rio.set_spatial_dims(x_dim="x", y_dim="y")
ds = ds.rio.write_crs(ds["spatial_ref"].attrs["crs_wkt"])
da = ds.sel(year=YEAR, band=BAND)["data"].compute()
da.attrs.pop("long_name", None)
da.rio.to_raster(tif_path)
m = leafmap.Map(center=[39.0, -76.7])
m.add_raster(tif_path, layer_name="Alpha earth", colormap="viridis")
m.zoom = 8
# Find the raster layer
raster_layer = None
for layer in m.layers:
if hasattr(layer, 'name') and layer.name == "Alpha earth":
raster_layer = layer
break
slider = widgets.FloatSlider(
value=1.0, min=0.0, max=1.0, step=0.05,
description="Opacity:",
style={"description_width": "initial"}
)
def on_opacity_change(change):
if raster_layer:
raster_layer.opacity = change["new"]
slider.observe(on_opacity_change, names="value")
display(slider)
display(m)