Skip to content

Commit

Permalink
Updated notebooks 2024-02-21 UTC
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Feb 21, 2024
1 parent 90f426f commit 6d624fe
Show file tree
Hide file tree
Showing 6 changed files with 204 additions and 20 deletions.
2 changes: 1 addition & 1 deletion content/notebooks/32_local_tile.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@
"metadata": {},
"outputs": [],
"source": [
"m.add_raster(dem, cmap=\"viridis\", layer_name=\"DEM\")"
"m.add_raster(dem, colormap=\"viridis\", layer_name=\"DEM\")"
]
},
{
Expand Down
13 changes: 12 additions & 1 deletion content/notebooks/52_netcdf.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,18 @@
"source": [
"m = leafmap.Map(layers_control=True)\n",
"m.add_basemap(\"CartoDB.DarkMatter\")\n",
"m.add_velocity(filename, zonal_speed=\"u_wind\", meridional_speed=\"v_wind\")\n",
"m.add_velocity(\n",
" filename,\n",
" zonal_speed=\"u_wind\",\n",
" meridional_speed=\"v_wind\",\n",
" color_scale=[\n",
" \"rgb(0,0,150)\",\n",
" \"rgb(0,150,0)\",\n",
" \"rgb(255,255,0)\",\n",
" \"rgb(255,165,0)\",\n",
" \"rgb(150,0,0)\",\n",
" ],\n",
")\n",
"m"
]
},
Expand Down
12 changes: 1 addition & 11 deletions content/notebooks/87_actinia.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,7 @@
"metadata": {},
"outputs": [],
"source": [
"url = \"https://github.com/actinia-org/actinia-python-client/releases/download/0.3.1/actinia_python_client-0.3.1-py3-none-any.whl\"\n",
"leafmap.download_file(url)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%pip install actinia_python_client-0.3.1-py3-none-any.whl"
"%pip install actinia_python_client"
]
},
{
Expand Down
12 changes: 6 additions & 6 deletions content/notebooks/89_image_array_viz.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@
"metadata": {},
"outputs": [],
"source": [
"url1 = \"https://open.gishub.org/data/raster/landsat7.tif\"\n",
"url1 = \"https://open.gishub.org/data/raster/landsat.tif\"\n",
"url2 = \"https://open.gishub.org/data/raster/srtm90.tif\"\n",
"satellite = leafmap.download_file(url1, \"landsat7.tif\")\n",
"satellite = leafmap.download_file(url1, \"landsat.tif\", overwrite=True)\n",
"dem = leafmap.download_file(url2, \"srtm90.tif\")"
]
},
Expand All @@ -68,8 +68,8 @@
"outputs": [],
"source": [
"dataset = rasterio.open(satellite)\n",
"nir = dataset.read(1).astype(float)\n",
"red = dataset.read(2).astype(float)\n",
"nir = dataset.read(4).astype(float)\n",
"red = dataset.read(1).astype(float)\n",
"ndvi = (nir - red) / (nir + red)"
]
},
Expand Down Expand Up @@ -103,7 +103,7 @@
"outputs": [],
"source": [
"m = leafmap.Map()\n",
"m.add_raster(satellite, band=[1, 2, 3], nodata=-1, layer_name=\"Landsat 7\")\n",
"m.add_raster(satellite, indexes=[4, 1, 2], vmin=0, vmax=120, layer_name=\"Landsat 7\")\n",
"m.add_raster(ndvi_image, colormap=\"Greens\", layer_name=\"NDVI\")\n",
"m"
]
Expand Down Expand Up @@ -191,7 +191,7 @@
"outputs": [],
"source": [
"m = leafmap.Map()\n",
"m.add_raster(satellite, band=[1, 2, 3], nodata=-1, layer_name=\"Landsat 7\")\n",
"m.add_raster(satellite, indexes=[4, 1, 2], vmin=0, vmax=120, layer_name=\"Landsat 7\")\n",
"m.add_raster(ndvi_image, colormap=\"Greens\", layer_name=\"NDVI\")\n",
"m"
]
Expand Down
183 changes: 183 additions & 0 deletions content/notebooks/90_pixel_inspector.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/90_pixel_inspector.ipynb)\n",
"[![image](https://studiolab.sagemaker.aws/studiolab.svg)](https://studiolab.sagemaker.aws/import/github/opengeos/leafmap/blob/master/examples/notebooks/90_pixel_inspector.ipynb)\n",
"[![image](https://img.shields.io/badge/Open-Planetary%20Computer-black?style=flat&logo=microsoft)](https://pccompute.westeurope.cloudapp.azure.com/compute/hub/user-redirect/git-pull?repo=https://github.com/opengeos/leafmap&urlpath=lab/tree/leafmap/examples/notebooks/90_pixel_inspector.ipynb&branch=master)\n",
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/90_pixel_inspector.ipynb)\n",
"[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/90_pixel_inspector.ipynb)\n",
"[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
"\n",
"## Interactive pixel inspector \n",
"\n",
"The interactive pixel inspector can be used to explore the pixel values of an image. It supports Cloud Optimized GeoTIFF (COG), STAC, and other raster data formats, either stored locally or on the cloud. The COG and STAC functionalities are powered by the [TiTiler](https://developmentseed.org/titiler/), while the local file support is powered by [localtileserver](https://github.com/banesullivan/localtileserver)."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# %pip install \"leafmap[raster]\""
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import leafmap\n",
"import rasterio"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### COG"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"m = leafmap.Map()\n",
"url = \"https://github.com/opengeos/data/releases/download/raster/Libya-2023-07-01.tif\"\n",
"m.add_cog_layer(url, layer_name=\"Libya\")\n",
"m.add(\"inspector\")\n",
"m"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### STAC"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"m = leafmap.Map()\n",
"url = \"https://canada-spot-ortho.s3.amazonaws.com/canada_spot_orthoimages/canada_spot5_orthoimages/S5_2007/S5_11055_6057_20070622/S5_11055_6057_20070622.json\"\n",
"m.add_stac_layer(url, bands=[\"B3\", \"B2\", \"B1\"], name=\"SPOT Image\")\n",
"m.add(\"inspector\")\n",
"m"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Planetary Computer"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"m = leafmap.Map()\n",
"collection = \"landsat-8-c2-l2\"\n",
"item = \"LC08_L2SP_047027_20201204_02_T1\"\n",
"m.add_stac_layer(\n",
" collection=collection,\n",
" item=item,\n",
" assets=\"SR_B7,SR_B5,SR_B4\",\n",
" name=\"Landsat Band-754\",\n",
")\n",
"m.add(\"inspector\")\n",
"m"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Local raster"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"url = \"https://open.gishub.org/data/raster/landsat.tif\"\n",
"satellite = leafmap.download_file(url, \"landsat.tif\", overwrite=True)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"m = leafmap.Map()\n",
"m.add_raster(satellite, indexes=[4, 1, 2], vmin=0, vmax=120, layer_name=\"Landsat 7\")\n",
"m.add(\"inspector\")\n",
"m"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## In-memory raster"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"dataset = rasterio.open(satellite)\n",
"nir = dataset.read(4).astype(float)\n",
"red = dataset.read(1).astype(float)\n",
"ndvi = (nir - red) / (nir + red)\n",
"ndvi_image = leafmap.array_to_image(ndvi, source=satellite)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"m = leafmap.Map()\n",
"m.add_raster(satellite, indexes=[4, 1, 2], vmin=0, vmax=120, layer_name=\"Landsat 7\")\n",
"m.add_raster(ndvi_image, colormap=\"Greens\", layer_name=\"NDVI\")\n",
"m.add(\"inspector\")\n",
"m"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"![](https://i.imgur.com/2AduU8G.gif)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python (Pyodide)",
"language": "python",
"name": "python"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
2 changes: 1 addition & 1 deletion content/workshops/EarthCube_2023.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -787,7 +787,7 @@
"outputs": [],
"source": [
"m = leafmap.Map()\n",
"m.add_raster(\"merged.tif\", cmap=\"terrain\", layer_name=\"Merged raster\")\n",
"m.add_raster(\"merged.tif\", colormap=\"terrain\", layer_name=\"Merged raster\")\n",
"m"
]
},
Expand Down

0 comments on commit 6d624fe

Please sign in to comment.