Skip to content

Commit

Permalink
Fix samgeo notebook bug
Browse files Browse the repository at this point in the history
  • Loading branch information
giswqs committed Nov 23, 2023
1 parent 474226f commit 13bc182
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
5 changes: 2 additions & 3 deletions docs/notebooks/135_segmentation.ipynb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"cells": [
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand All @@ -27,7 +26,7 @@
"metadata": {},
"outputs": [],
"source": [
"# %pip install segment-geospatial"
"# %pip install segment-geospatial pycrs"
]
},
{
Expand Down Expand Up @@ -130,7 +129,7 @@
"metadata": {},
"outputs": [],
"source": [
"Map.add_raster(\"annotations.tif\", alpha=0.5, layer_name=\"Masks\")\n",
"Map.add_raster(\"annotations.tif\", opacity=0.5, layer_name=\"Masks\")\n",
"Map"
]
},
Expand Down
4 changes: 2 additions & 2 deletions examples/notebooks/135_segmentation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"metadata": {},
"outputs": [],
"source": [
"# %pip install segment-geospatial"
"# %pip install segment-geospatial pycrs"
]
},
{
Expand Down Expand Up @@ -129,7 +129,7 @@
"metadata": {},
"outputs": [],
"source": [
"Map.add_raster(\"annotations.tif\", alpha=0.5, layer_name=\"Masks\")\n",
"Map.add_raster(\"annotations.tif\", opacity=0.5, layer_name=\"Masks\")\n",
"Map"
]
},
Expand Down
8 changes: 6 additions & 2 deletions geemap/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ def ee_initialize(
ee_token = os.environ.get(token_name)
if in_colab_shell():
from google.colab import userdata

try:
ee_token = userdata.get(token_name)
except Exception:
Expand Down Expand Up @@ -10651,6 +10652,9 @@ def get_local_tile_layer(
if "cmap" not in kwargs:
kwargs["cmap"] = palette

if "alpha" in kwargs:
kwargs["opacity"] = float(kwargs["alpha"])

with output:
tile_client = TileClient(source, port=port, debug=debug)

Expand Down Expand Up @@ -15481,8 +15485,8 @@ def geotiff_to_image(image: str, output: str) -> None:
data = dataset.read()

# Convert the image data to 8-bit format (assuming it's not already)
if dataset.dtypes[0] != 'uint8':
data = (data / data.max() * 255).astype('uint8')
if dataset.dtypes[0] != "uint8":
data = (data / data.max() * 255).astype("uint8")

# Convert the image data to RGB format if it's a single band image
if dataset.count == 1:
Expand Down

0 comments on commit 13bc182

Please sign in to comment.