Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

actinia_leafmap.ipynb: fix broken notebook #16

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 18 additions & 49 deletions notebooks/actinia_leafmap.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
"id": "21a733b7",
"metadata": {},
"source": [
"For the following actinia example we use the [actinia-python-client](https://actinia-core.github.io/actinia-python-client/) ([source code](https://github.com/actinia-org/actinia-python-client)) to establish the connection to the actinia instance."
"For the following actinia example we use the [actinia-python-client](https://actinia-org.github.io/actinia-python-client/) ([source code](https://github.com/actinia-org/actinia-python-client)) to establish the connection to the actinia instance."
]
},
{
Expand All @@ -101,10 +101,8 @@
"metadata": {},
"outputs": [],
"source": [
"# install actinia-python-client, update version as needed\n",
"!wget -c https://github.com/actinia-org/actinia-python-client/releases/download/0.3.0/actinia_python_client-0.3.0-py3-none-any.whl\n",
"\n",
"!pip3 install actinia_python_client-0.3.0-py3-none-any.whl"
"# install actinia-python-client\n",
"!pip install actinia-python-client"
]
},
{
Expand Down Expand Up @@ -168,9 +166,18 @@
"metadata": {},
"outputs": [],
"source": [
"# variables to set the actinia host, version, and user\n",
"actinia_baseurl = \"https://actinia.mundialis.de\"\n",
"actinia_version = \"v3\"\n",
"actinia_user = \"demouser\"\n",
"actinia_pw = \"gu3st!pa55w0rd\"\n",
"actinia_url = f\"{actinia_baseurl}/api/{actinia_version}\"\n",
"\n",
"# connect to default actinia server (actinia.mundialis.de)\n",
"import requests\n",
"from requests.auth import HTTPBasicAuth\n",
"from actinia import Actinia\n",
"\n",
"actinia_auth = HTTPBasicAuth(actinia_user, actinia_pw)\n",
"actinia_mundialis = Actinia()\n",
"\n",
"# retrieve metadata about actinia and related software versions\n",
Expand All @@ -195,9 +202,7 @@
"outputs": [],
"source": [
"# define user/password for connection\n",
"#actinia_mundialis.set_authentication(\"demouser\", \"gu3st!pa55w0rd\")\n",
"\n",
"actinia_mundialis.set_authentication(\"fossgis2023\", \"ieh0ahweefavicieca6g\") # DELETEME\n",
"actinia_mundialis.set_authentication(actinia_user, actinia_pw)\n",
"print(\"Connected to actinia server.\")"
]
},
Expand Down Expand Up @@ -320,7 +325,7 @@
"id": "7c4aae0e",
"metadata": {},
"source": [
"In order to pass on username and password when visualizing the map processed in actinia, we auto-inject `user:password@server` into `exported_raster` URL (i.e., the actinia resource)."
"In order to pass on username and password when visualizing the map processed in actinia, we inject `user:password@server` into `exported_raster` URL (i.e., the actinia resource)."
]
},
{
Expand All @@ -330,7 +335,7 @@
"metadata": {},
"outputs": [],
"source": [
"url = exported_raster.replace(\"//\", \"//fossgis2023:ieh0ahweefavicieca6g@\")"
"url = exported_raster.replace(\"//\", f\"//{actinia_user}:{actinia_pw}@\")"
]
},
{
Expand All @@ -343,7 +348,7 @@
"## Using GDAL (or QGIS) to verify the generated map (note that the GDAL binary tools\n",
"## need to be installed on the server this jupyter notebook is executed on).\n",
"#\n",
"# !gdalinfo '/vsicurl/https://fossgis2023:ieh0ahweefavicieca6g@actinia.mundialis.de/api/v3/resources/fossgis2023/resource_id-3c336dbe-cb43-4aa8-8bc3-a6998249406b/hillshade.tif'"
"# !gdalinfo '/vsicurl/https://USER:PASSWORD@actinia.mundialis.de/api/v3/resources/fossgis2023/resource_id-3c336dbe-cb43-4aa8-8bc3-a6998249406b/hillshade.tif'"
]
},
{
Expand Down Expand Up @@ -380,42 +385,6 @@
"We use the path to actinia resource (here: a raster map)."
]
},
{
"cell_type": "markdown",
"id": "69c4c9f9-4ab0-44b9-8d6b-610966ff7a03",
"metadata": {},
"source": [
"Validate if it is a COG file (expected: `True` - may take a moment):"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "cd103e3e-3823-4e7c-9a61-4f05850b7e4d",
"metadata": {},
"outputs": [],
"source": [
"leafmap.cog_validate(url)"
]
},
{
"cell_type": "markdown",
"id": "608ea391-ccc8-43b2-b855-c54f69e42edf",
"metadata": {},
"source": [
"See validation in greater detail (optional):"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "207f7475-e22a-4e5d-a312-ac13d8f3eb5c",
"metadata": {},
"outputs": [],
"source": [
"leafmap.cog_validate(url, verbose=True)"
]
},
{
"cell_type": "markdown",
"id": "946aebca-71b2-41d5-8cd6-d169940d65fb",
Expand Down Expand Up @@ -471,7 +440,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.2"
"version": "3.11.8"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion notebooks/actinia_python_client.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"or Landsat data, spatio-temporal statistical analysis and many more.\n",
"\n",
"The following example is a Jupyter Notebook which uses the \n",
"[actinia-python-client](https://actinia-core.github.io/actinia-python-client/) ([source code](https://github.com/actinia-org/actinia-python-client)) to\n",
"[actinia-python-client](https://actinia-org.github.io/actinia-python-client/) ([source code](https://github.com/actinia-org/actinia-python-client)) to\n",
"establish the connection to the actinia instance. "
]
},
Expand Down