Skip to content

Commit

Permalink
Updated notebooks 2024-02-22 UTC
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Feb 22, 2024
1 parent 6d624fe commit b22a299
Showing 1 changed file with 85 additions and 3 deletions.
88 changes: 85 additions & 3 deletions content/notebooks/90_pixel_inspector.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@
"outputs": [],
"source": [
"import leafmap\n",
"import rasterio"
"import rasterio\n",
"import rioxarray\n",
"import xarray as xr"
]
},
{
Expand All @@ -50,7 +52,7 @@
"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_cog_layer(url, name=\"Libya\")\n",
"m.add(\"inspector\")\n",
"m"
]
Expand Down Expand Up @@ -134,7 +136,9 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## In-memory raster"
"## In-memory raster\n",
"\n",
"### NumPy array"
]
},
{
Expand Down Expand Up @@ -163,6 +167,84 @@
"m"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Xarray DataArray"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"url = \"https://open.gishub.org/data/raster/srtm90.tif\"\n",
"dem = leafmap.download_file(url, \"srtm90.tif\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"ds = rioxarray.open_rasterio(dem)\n",
"ds"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"array = ds.sel(band=1)\n",
"masked_array = xr.where(array < 2000, 0, 1)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"m = leafmap.Map()\n",
"m.add_raster(dem, colormap=\"terrain\", layer_name=\"DEM\")\n",
"m.add_raster(masked_array, colormap=\"coolwarm\", layer_name=\"Classified DEM\")\n",
"m"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Split map"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"m = leafmap.Map(center=[37.6, -119], zoom=9)\n",
"m.split_map(\n",
" dem,\n",
" masked_array,\n",
" left_args={\n",
" \"layer_name\": \"DEM\",\n",
" \"colormap\": \"terrain\",\n",
" },\n",
" right_args={\n",
" \"layer_name\": \"Classified DEM\",\n",
" \"colormap\": \"coolwarm\",\n",
" },\n",
")\n",
"m"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down

0 comments on commit b22a299

Please sign in to comment.