diff --git a/how-tos/How_to_Extract_Area.ipynb b/how-tos/How_to_Extract_Area.ipynb index aec1a71..b0d4479 100644 --- a/how-tos/How_to_Extract_Area.ipynb +++ b/how-tos/How_to_Extract_Area.ipynb @@ -1977,6 +1977,7 @@ "import rasterio as rio\n", "import rioxarray as rxr\n", "import hvplot.xarray\n", + "import hvplot.pandas\n", "import holoviews as hv\n", "import geopandas as gp\n", "import sys\n", @@ -2402,9 +2403,9 @@ " spatial_ref: GEOGCS["WGS 84",DATUM["WGS_1984",SPHER...\n", " geotransform: [-6.25120945e+01 5.42232520e-04 -0.00...\n", " day_night_flag: Day\n", - " title: EMIT L2A Surface Reflectance 60 m V001" ], "text/plain": [ @@ -2567,13 +2568,91 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Use the `clip` function from `rasterio` to clip the dataset to polygons from the `geopandas.geodataframe`. Setting `all_touched` to `True` will include pixels that intersected with the edges of the polygon. " + "Now plot the polygon we've loaded overlayed on a plot of the dataset." ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, + "outputs": [ + { + "data": {}, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "application/vnd.holoviews_exec.v0+json": "", + "text/html": [ + "
\n", + "
\n", + "
\n", + "" + ], + "text/plain": [ + ":DynamicMap []\n", + " :Overlay\n", + " .Image.I :Image [longitude,latitude] (reflectance)\n", + " .Polygons.I :Polygons [x,y]" + ] + }, + "execution_count": 5, + "metadata": { + "application/vnd.holoviews_exec.v0+json": { + "id": "1004" + } + }, + "output_type": "execute_result" + } + ], + "source": [ + "ds.sel(bands=63).hvplot.image(cmap='greys', frame_width=500, rasterize=True)*shape.hvplot(color='#d95f02',aspect='equal', alpha=0.5)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Use the `clip` function from `rasterio` to clip the dataset to polygons from the `geopandas.geodataframe`. Setting `all_touched` to `True` will include pixels that intersected with the edges of the polygon. " + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": {}, "outputs": [ { "data": { @@ -2965,7 +3044,7 @@ " spatial_ref: GEOGCS["WGS 84",DATUM["WGS_1984",SPHER...\n", " geotransform: [-6.25120945e+01 5.42232520e-04 -0.00...\n", " day_night_flag: Day\n", - " title: EMIT L2A Surface Reflectance 60 m V001" ], "text/plain": [ @@ -3104,7 +3183,7 @@ " title: EMIT L2A Surface Reflectance 60 m V001" ] }, - "execution_count": 5, + "execution_count": 6, "metadata": {}, "output_type": "execute_result" } @@ -3123,7 +3202,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 7, "metadata": {}, "outputs": [ { @@ -3135,13 +3214,13 @@ "data": { "application/vnd.holoviews_exec.v0+json": "", "text/html": [ - "
\n", - "
\n", + "
\n", + "
\n", "
\n", "" + ], + "text/plain": [ + ":DynamicMap []\n", + " :Overlay\n", + " .Image.I :Image [longitude,latitude] (reflectance)\n", + " .Scatter.I :Scatter [Longitude] (Latitude,ID)\n", + " .Labels.I :Labels [Longitude,Latitude] (ID)" + ] + }, + "execution_count": 5, + "metadata": { + "application/vnd.holoviews_exec.v0+json": { + "id": "1002" + } + }, + "output_type": "execute_result" + } + ], + "source": [ + "ds.sel(bands=63).hvplot.image(cmap='greys', frame_width=500, rasterize=True,aspect='equal')*\\\n", + "points.hvplot.scatter(x='Longitude',y='Latitude', color='ID', cmap='Category10',aspect='equal')*\\\n", + "points.hvplot.labels(x='Longitude',y='Latitude', text='ID', text_color='ID', cmap='Category10',aspect='equal').opts(xoffset=0.03)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Set the `points` dataframe index as `ID` to utilize our existing point ID's as an index." + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": {}, "outputs": [], "source": [ "points = points.set_index(['ID'])" @@ -2624,7 +2706,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 7, "metadata": {}, "outputs": [ { @@ -3000,7 +3082,7 @@ "Data variables:\n", " Category (ID) int64 1 1 3 2 3\n", " Latitude (ID) float64 -39.94 -39.75 -40.0 -39.89 -39.38\n", - " Longitude (ID) float64 -62.36 -61.74 -62.1 -61.85 -62.03
" + " Longitude (ID) float64 -62.36 -61.74 -62.1 -61.85 -62.03" ], "text/plain": [ "\n", @@ -3013,7 +3095,7 @@ " Longitude (ID) float64 -62.36 -61.74 -62.1 -61.85 -62.03" ] }, - "execution_count": 6, + "execution_count": 7, "metadata": {}, "output_type": "execute_result" } @@ -3032,7 +3114,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 8, "metadata": {}, "outputs": [ { @@ -3201,7 +3283,7 @@ "[1425 rows x 6 columns]" ] }, - "execution_count": 7, + "execution_count": 8, "metadata": {}, "output_type": "execute_result" } @@ -3220,7 +3302,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 9, "metadata": {}, "outputs": [ { @@ -3416,7 +3498,7 @@ "[1425 rows x 7 columns]" ] }, - "execution_count": 8, + "execution_count": 9, "metadata": {}, "output_type": "execute_result" } @@ -3435,7 +3517,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 10, "metadata": {}, "outputs": [], "source": [ @@ -3451,7 +3533,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 11, "metadata": {}, "outputs": [], "source": [ @@ -3467,7 +3549,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 12, "metadata": {}, "outputs": [ { @@ -3479,13 +3561,13 @@ "data": { "application/vnd.holoviews_exec.v0+json": "", "text/html": [ - "
\n", - "
\n", + "
\n", + "
\n", "
\n", "