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

WPS returns datasets : access band_data variable #356

Merged
merged 9 commits into from
May 9, 2024
31 changes: 21 additions & 10 deletions docs/notebooks/02_Extract_geographical_watershed_properties.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@
"source": [
"features, statistics, raster = stats_resp.get(asobj=True)\n",
"grid = raster[0]\n",
"grid.plot()"
"grid.band_data.plot()"
]
},
{
Expand Down Expand Up @@ -226,7 +226,7 @@
},
"outputs": [],
"source": [
"unique, counts = np.unique(grid, return_counts=True)\n",
"unique, counts = np.unique(grid.band_data, return_counts=True)\n",
"print(\"The land-use categories available are: \" + str(unique))\n",
"print(\"The number of occurrences of each land-use category is: \" + str(counts))\n",
"\n",
Expand All @@ -245,8 +245,8 @@
"plt.ylabel(\"Number of pixels\")\n",
"plt.show()\n",
"\n",
"grid.where(grid != 127).sel(band=1).plot.imshow(cmap=\"tab20\")\n",
"grid.name = \"Land-use categories\"\n",
"grid.band_data.where(grid.band_data != 127).sel(band=1).plot.imshow(cmap=\"tab20\")\n",
"grid.band_data.name = \"Land-use categories\"\n",
"plt.show()"
]
},
Expand Down Expand Up @@ -301,8 +301,10 @@
")\n",
"\n",
"ax = plt.subplot(projection=crs)\n",
"grid.name = \"Land-use categories\"\n",
"grid.where(grid != 127).sel(band=1).plot.imshow(ax=ax, transform=crs, cmap=\"tab20\")\n",
"grid.band_data.name = \"Land-use categories\"\n",
"grid.band_data.where(grid.band_data != 127).sel(band=1).plot.imshow(\n",
" ax=ax, transform=crs, cmap=\"tab20\"\n",
")\n",
"plt.show()"
]
},
Expand Down Expand Up @@ -362,10 +364,12 @@
" central_latitude=49, central_longitude=-95, standard_parallels=(49, 77)\n",
")\n",
"\n",
"dem.name = \"Elevation\"\n",
"dem.attrs[\"units\"] = \"m\"\n",
"dem.band_data.name = \"Elevation\"\n",
"dem.band_data.attrs[\"units\"] = \"m\"\n",
"ax = plt.subplot(projection=crs)\n",
"dem.where(dem != -32768).sel(band=1).plot.imshow(ax=ax, transform=crs, cmap=\"gnuplot\")\n",
"dem.band_data.where(dem.band_data != -32768).sel(band=1).plot.imshow(\n",
" ax=ax, transform=crs, cmap=\"gnuplot\"\n",
")\n",
"plt.show()"
]
},
Expand Down Expand Up @@ -405,6 +409,13 @@
"all_properties = {**shape_info, **land_use, **terrain}\n",
"display(all_properties)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand All @@ -418,7 +429,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.16"
"version": "3.10.13"
}
},
"nbformat": 4,
Expand Down
Loading