diff --git a/giw/README.ipynb b/giw/README.ipynb index c0fa767..634bd3c 100644 --- a/giw/README.ipynb +++ b/giw/README.ipynb @@ -9,13 +9,17 @@ "\n", "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/source-coop-readme/blob/main/giw/README.ipynb)\n", "\n", - "## Description\n", + "## Introduction\n", "\n", - "This dataset represents the extent and approximate location of [Geographically Isolated Wetlands](https://catalog.data.gov/dataset/geographically-isolated-wetlands-non-floodplain-wetlands-of-the-conterminous-united-states1) (GIWs), also known as non-floodplain wetlands (NFWs), in the conterminous United States. National Wetlands Inventory (NWI) lacustrine systems and palustrine wetlands were determined to be “isolated” based on their geographic location (i.e., unconnected, based on a distance measure, to specific classes of NHD aquatic systems). GIWs were here considered geographically isolated when they were outside of 10 meters from select NHD lines and polygons or were not adjacent to NWI Riverine or Estuarine wetlands and (where applicable) outside of 10 meters from a coastline (e.g., oceans or Great Lakes).\n", + "The datasets represent the extent and approximate location of [Geographically Isolated Wetlands](https://catalog.data.gov/dataset/geographically-isolated-wetlands-non-floodplain-wetlands-of-the-conterminous-united-states1) (GIWs), also known as non-floodplain wetlands (NFWs), in the conterminous United States. National Wetlands Inventory (NWI) lacustrine systems and palustrine wetlands were determined to be “isolated” based on their geographic location (i.e., unconnected, based on a distance measure, to specific classes of NHD aquatic systems). GIWs were here considered geographically isolated when they were outside of 10 meters from select NHD lines and polygons or were not adjacent to NWI Riverine or Estuarine wetlands and (where applicable) outside of 10 meters from a coastline (e.g., oceans or Great Lakes).\n", + "\n", + "The datasets have two versions:\n", + "- [Version 1](https://beta.source.coop/giswqs/giw/wetlands) (46.37 GB): The original Lane & D'Amico (2016) dataset with the original attributes. We call this dataset **NFW**.\n", + "- [Version 2](https://beta.source.coop/giswqs/giw/wetlands_v2) (90.18 GB): The original Lane & D'Amico (2016) dataset with additional attributes from the 10-m resolution depression dataset. We call this dataset **Wetland Depressions**.\n", "\n", "## Reference\n", "\n", - "- Lane, C. R., & D'Amico, E. (2016). Identification of putative geographically isolated wetlands of the conterminous United States. JAWRA Journal of the American Water Resources Association, 52(3), 705-722. https://doi.org/10.1111/1752-1688.12421\n", + "- Lane, C. R., & D'Amico, E. (2016). Identification of putative geographically isolated wetlands of the conterminous United States. _JAWRA Journal of the American Water Resources Association_, 52(3), 705-722. https://doi.org/10.1111/1752-1688.12421\n", "\n", "## Environment setup\n", "\n", @@ -25,8 +29,7 @@ "conda create -n gdal python=3.11\n", "conda activate gdal\n", "conda install -c conda-forge mamba\n", - "mamba install -c conda-forge libgdal-arrow-parquet gdal leafmap\n", - "pip install lonboard\n", + "mamba install -c conda-forge libgdal-arrow-parquet gdal leafmap lonboard\n", "```\n", "\n", "If you are using Google Colab, you can uncomment the following to install the packages and restart the runtime after installation." @@ -82,7 +85,7 @@ "id": "5", "metadata": {}, "source": [ - "The total file size of the Geodatabase files is 4.4 GB. The total file size of the Parquet files is 46.4 GB.\n", + "The total file size of the Geodatabase files is 4.4 GB. The total file size of the Parquet files is 46.37 GB.\n", "\n", "## Data access\n", "\n", @@ -155,7 +158,7 @@ "gdf = leafmap.read_parquet(\n", " url, return_type=\"gdf\", src_crs=\"EPSG:5070\", dst_crs=\"EPSG:4326\"\n", ")\n", - "# leafmap.view_vector(gdf, get_fill_color=[0, 0, 255, 128])" + "leafmap.view_vector(gdf, get_fill_color=[0, 0, 255, 128])" ] }, { @@ -165,7 +168,7 @@ "source": [ "## Data analysis\n", "\n", - "Find out the total number non-floodplain wetlands in the conterminous United States:" + "Find out the total number of NFWs in CONUS:" ] }, { @@ -188,17 +191,25 @@ "id": "13", "metadata": {}, "source": [ - "Find out the number of non-floodplain wetlands in each state and order them by the number of wetlands:" + "The total number of NFWs in CONUS is 8,380,620." + ] + }, + { + "cell_type": "markdown", + "id": "14", + "metadata": {}, + "source": [ + "Find out the number of NFWs in each state and order them by the number of NFWs:" ] }, { "cell_type": "code", "execution_count": null, - "id": "14", + "id": "15", "metadata": {}, "outputs": [], "source": [ - "count_df = con.sql(\n", + "giw_count_df = con.sql(\n", " f\"\"\"\n", "SELECT inState AS State, COUNT(*) AS Count\n", "FROM 's3://us-west-2.opendata.source.coop/giswqs/giw/wetlands/*.parquet'\n", @@ -206,69 +217,72 @@ "ORDER BY COUNT(*) DESC;\n", "\"\"\"\n", ").df()\n", - "count_df.head()" + "giw_count_df.head()" ] }, { "cell_type": "markdown", - "id": "15", + "id": "16", "metadata": {}, "source": [ - "Create a bar chart showing the number of non-floodplain wetlands in each state:" + "Create a pie chart showing the number of NFWs in each state:" ] }, { "cell_type": "code", "execution_count": null, - "id": "16", + "id": "17", "metadata": {}, "outputs": [], "source": [ "leafmap.pie_chart(\n", - " count_df,\n", + " giw_count_df,\n", " \"State\",\n", " \"Count\",\n", " height=700,\n", - " title=\"Number of Non-Floodplain Wetlands by State\",\n", + " title=\"Number of Non-Floodplain Wetlands (NFWs) by State\",\n", ")" ] }, { "cell_type": "markdown", - "id": "17", + "id": "18", "metadata": {}, "source": [ - "![](https://i.imgur.com/GgtlcWB.png)\n", + "![](https://i.imgur.com/SNpVzcC.png)\n", "\n", - "Create a bar chart showing the number of non-floodplain wetlands in each state:" + "Create a bar chart showing the number of NFWs in each state:" ] }, { "cell_type": "code", "execution_count": null, - "id": "18", + "id": "19", "metadata": {}, "outputs": [], "source": [ "leafmap.bar_chart(\n", - " count_df, \"State\", \"Count\", title=\"Number of Non-Floodplain Wetlands by State\"\n", + " giw_count_df,\n", + " \"State\",\n", + " \"Count\",\n", + " title=\"Number of Non-Floodplain Wetlands (NFWs) by State\",\n", ")" ] }, { "cell_type": "markdown", - "id": "19", + "id": "20", "metadata": {}, "source": [ - "![](https://i.imgur.com/v4zz8zV.png)\n", + "![](https://i.imgur.com/19gxoBE.png)\n", "\n", - "Calculate the total area of non-floodplain wetlands in each state and order them by the area of wetlands:" + "Calculate the total area of NFWs in each state and order them by the area of wetlands:" ] }, { "cell_type": "code", "execution_count": null, - "id": "20", + "id": "21", "metadata": {}, "outputs": [], "source": [ @@ -285,16 +299,16 @@ }, { "cell_type": "markdown", - "id": "21", + "id": "22", "metadata": {}, "source": [ - "Create a pie chart showing the total area of non-floodplain wetlands in each state:" + "Create a pie chart showing the total area of NFWs in each state:" ] }, { "cell_type": "code", "execution_count": null, - "id": "22", + "id": "23", "metadata": {}, "outputs": [], "source": [ @@ -303,42 +317,35 @@ " \"State\",\n", " \"Hectares\",\n", " height=700,\n", - " title=\"Area of Non-Floodplain Wetlands by State\",\n", + " title=\"Percentage Area of Non-Floodplain Wetlands (NFWs) by State\",\n", ")" ] }, { "cell_type": "markdown", - "id": "23", + "id": "24", "metadata": {}, "source": [ - "![](https://i.imgur.com/mAsLCDE.png)\n", + "![](https://i.imgur.com/dayPfZY.png)\n", "\n", - "Create a pie chart showing the total area of non-floodplain wetlands in each state:" + "Create a pie chart showing the total area of NFWs in each state:" ] }, { "cell_type": "code", "execution_count": null, - "id": "24", + "id": "25", "metadata": {}, "outputs": [], "source": [ "leafmap.bar_chart(\n", - " sum_df, \"State\", \"Hectares\", title=\"Area of Non-Floodplain Wetlands by State\"\n", + " sum_df,\n", + " \"State\",\n", + " \"Hectares\",\n", + " title=\"Total Area of Non-Floodplain Wetlands (NFWs) by State\",\n", ")" ] }, - { - "cell_type": "markdown", - "id": "25", - "metadata": {}, - "source": [ - "![](https://i.imgur.com/7RtioFU.png)\n", - "\n", - "Find out the mean area of non-floodplain wetlands in each state and order them by the mean area of wetlands:" - ] - }, { "cell_type": "code", "execution_count": null, @@ -362,7 +369,7 @@ "id": "27", "metadata": {}, "source": [ - "Create a bar chart showing the median area of non-floodplain wetlands in each state:" + "Create a bar chart showing the median area of NFWs in each state:" ] }, { @@ -376,7 +383,7 @@ " median_df,\n", " \"State\",\n", " \"Meters\",\n", - " title=\"Median Area of Non-Floodplain Wetlands by State\",\n", + " title=\"Median Area of Non-Floodplain Wetlands (NFWs) by State\",\n", ")" ] }, @@ -385,11 +392,201 @@ "id": "29", "metadata": {}, "source": [ - "![](https://i.imgur.com/2iAYcm3.png)" + "![](https://i.imgur.com/OZahOKx.png)" + ] + }, + { + "cell_type": "markdown", + "id": "30", + "metadata": {}, + "source": [ + "Calculate the number of NFWs intersecting surface depressions (i.e., wetland depressions) in each state:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "31", + "metadata": {}, + "outputs": [], + "source": [ + "giw_dep_count_stat = con.sql(\n", + " f\"\"\"\n", + "SELECT inState AS State, COUNT(DISTINCT Final_ID) AS Count\n", + "FROM 's3://us-west-2.opendata.source.coop/giswqs/giw/wetlands_v2/*.parquet'\n", + "WHERE area IS NOT NULL\n", + "GROUP BY inState\n", + "ORDER BY COUNT(*) DESC;\n", + "\"\"\"\n", + ").df()\n", + "giw_dep_count_stat.head()" + ] + }, + { + "cell_type": "markdown", + "id": "32", + "metadata": {}, + "source": [ + "Merge the NFW table with the wetland depressions table:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "33", + "metadata": {}, + "outputs": [], + "source": [ + "merged_df = giw_count_df.merge(giw_dep_count_stat, on=\"State\")\n", + "merged_df.columns = [\"State\", \"GIW_Count\", \"DEP_Count\"]\n", + "merged_df[\"Percent\"] = merged_df[\"DEP_Count\"] / merged_df[\"GIW_Count\"] * 100\n", + "merged_df.head()" + ] + }, + { + "cell_type": "markdown", + "id": "34", + "metadata": {}, + "source": [ + "Compare the number of NFWs and wetland depressions in each state:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "35", + "metadata": {}, + "outputs": [], + "source": [ + "leafmap.bar_chart(\n", + " merged_df,\n", + " \"State\",\n", + " [\"GIW_Count\", \"DEP_Count\"],\n", + " title=\"Number of NFWs and Wetland Depressions by State\",\n", + ")" + ] + }, + { + "cell_type": "markdown", + "id": "36", + "metadata": {}, + "source": [ + "![](https://i.imgur.com/BsPdZ82.png)" + ] + }, + { + "cell_type": "markdown", + "id": "37", + "metadata": {}, + "source": [ + "Compute the statistics of the area of NFWs and wetland depressions in each state:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "38", + "metadata": {}, + "outputs": [], + "source": [ + "giw_dep_count_stat = con.sql(\n", + " f\"\"\"\n", + "SELECT inState AS State, COUNT(DISTINCT Final_ID) AS Count, \n", + "SUM(area) / 1e6 AS Total_Area_km2, \n", + "SUM(volume) / 1e9 AS Total_Volume_km3, \n", + "Median(area) AS Median_Area_m2, \n", + "Median(volume) AS Median_Volume_m3\n", + "FROM 's3://us-west-2.opendata.source.coop/giswqs/giw/wetlands_v2/*.parquet'\n", + "WHERE area IS NOT NULL\n", + "GROUP BY inState\n", + "ORDER BY COUNT(*) DESC;\n", + "\"\"\"\n", + ").df()\n", + "giw_dep_count_stat.head(10)" + ] + }, + { + "cell_type": "markdown", + "id": "39", + "metadata": {}, + "source": [ + "The median size of wetland depressions in each state:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "40", + "metadata": {}, + "outputs": [], + "source": [ + "leafmap.bar_chart(\n", + " giw_dep_count_stat[giw_dep_count_stat[\"State\"] != \"NV\"],\n", + " \"State\",\n", + " \"Median_Area_m2\",\n", + " title=\"The Median Size of Maximum Depression Area by State\",\n", + ")" + ] + }, + { + "cell_type": "markdown", + "id": "41", + "metadata": {}, + "source": [ + "![](https://i.imgur.com/nkD0NSM.png)" + ] + }, + { + "cell_type": "markdown", + "id": "42", + "metadata": {}, + "source": [ + "The median maximum storage volume of wetland depressions in each state:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "43", + "metadata": {}, + "outputs": [], + "source": [ + "leafmap.bar_chart(\n", + " giw_dep_count_stat,\n", + " \"State\",\n", + " \"Median_Volume_m3\",\n", + " title=\"The Median Maximum Storage Volume of Wetlands Depressions by State\",\n", + ")" + ] + }, + { + "cell_type": "markdown", + "id": "44", + "metadata": {}, + "source": [ + "![](https://i.imgur.com/OLohMJ9.png)" ] } ], - "metadata": {}, + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.11.8" + } + }, "nbformat": 4, "nbformat_minor": 5 } diff --git a/giw/README.md b/giw/README.md index d5f6229..e27abcd 100644 --- a/giw/README.md +++ b/giw/README.md @@ -4,20 +4,29 @@ jupytext: extension: .md format_name: myst format_version: 0.13 - jupytext_version: 1.15.2 + jupytext_version: 1.16.2 +kernelspec: + display_name: Python 3 + language: python + name: python3 --- # Non-Floodplain Wetlands [![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/source-coop-readme/blob/main/giw/README.ipynb) -## Description +## Introduction -This dataset represents the extent and approximate location of [Geographically Isolated Wetlands](https://catalog.data.gov/dataset/geographically-isolated-wetlands-non-floodplain-wetlands-of-the-conterminous-united-states1) (GIWs), also known as non-floodplain wetlands (NFWs), in the conterminous United States. National Wetlands Inventory (NWI) lacustrine systems and palustrine wetlands were determined to be “isolated” based on their geographic location (i.e., unconnected, based on a distance measure, to specific classes of NHD aquatic systems). GIWs were here considered geographically isolated when they were outside of 10 meters from select NHD lines and polygons or were not adjacent to NWI Riverine or Estuarine wetlands and (where applicable) outside of 10 meters from a coastline (e.g., oceans or Great Lakes). +The datasets represent the extent and approximate location of [Geographically Isolated Wetlands](https://catalog.data.gov/dataset/geographically-isolated-wetlands-non-floodplain-wetlands-of-the-conterminous-united-states1) (GIWs), also known as non-floodplain wetlands (NFWs), in the conterminous United States. National Wetlands Inventory (NWI) lacustrine systems and palustrine wetlands were determined to be “isolated” based on their geographic location (i.e., unconnected, based on a distance measure, to specific classes of NHD aquatic systems). GIWs were here considered geographically isolated when they were outside of 10 meters from select NHD lines and polygons or were not adjacent to NWI Riverine or Estuarine wetlands and (where applicable) outside of 10 meters from a coastline (e.g., oceans or Great Lakes). + +The datasets have two versions: + +- [Version 1](https://beta.source.coop/giswqs/giw/wetlands) (46.37 GB): The original Lane & D'Amico (2016) dataset with the original attributes. We call this dataset **NFW**. +- [Version 2](https://beta.source.coop/giswqs/giw/wetlands_v2) (90.18 GB): The original Lane & D'Amico (2016) dataset with additional attributes from the 10-m resolution depression dataset. We call this dataset **Wetland Depressions**. ## Reference -- Lane, C. R., & D'Amico, E. (2016). Identification of putative geographically isolated wetlands of the conterminous United States. JAWRA Journal of the American Water Resources Association, 52(3), 705-722. https://doi.org/10.1111/1752-1688.12421 +- Lane, C. R., & D'Amico, E. (2016). Identification of putative geographically isolated wetlands of the conterminous United States. _JAWRA Journal of the American Water Resources Association_, 52(3), 705-722. https://doi.org/10.1111/1752-1688.12421 ## Environment setup @@ -27,8 +36,7 @@ First, create a conda environment with the required packages: conda create -n gdal python=3.11 conda activate gdal conda install -c conda-forge mamba -mamba install -c conda-forge libgdal-arrow-parquet gdal leafmap -pip install lonboard +mamba install -c conda-forge libgdal-arrow-parquet gdal leafmap lonboard ``` If you are using Google Colab, you can uncomment the following to install the packages and restart the runtime after installation. @@ -50,11 +58,11 @@ import leafmap ``` ```{code-cell} ipython3 -gdb = 'Geographically_Isolated_Wetlands_of_ConterminousUnitedStates.gdb' +gdb = "Geographically_Isolated_Wetlands_of_ConterminousUnitedStates.gdb" # leafmap.gdb_to_vector(gdb, ".", gdal_driver="Parquet") ``` -The total file size of the Geodatabase files is 4.4 GB. The total file size of the Parquet files is 46.4 GB. +The total file size of the Geodatabase files is 4.4 GB. The total file size of the Parquet files is 46.37 GB. ## Data access @@ -67,7 +75,7 @@ con = duckdb.connect() con.install_extension("spatial") con.load_extension("spatial") -state = "IA" # Change to the US State of your choice +state = "IA" # Change to the US State of your choice url = f"https://data.source.coop/giswqs/giw/wetlands/{state}_IW.parquet" # con.sql(f"SELECT * EXCLUDE geometry, ST_GeomFromWKB(geometry) as geometry FROM '{url}'") ``` @@ -91,95 +99,214 @@ To visualize the data, you can use the [leafmap](https://leafmap.org) Python pac ```{code-cell} ipython3 import leafmap -state = "DC" # Change to the US State of your choice +state = "DC" # Change to the US State of your choice url = f"https://data.source.coop/giswqs/giw/wetlands/{state}_IW.parquet" -gdf = leafmap.read_parquet(url, return_type='gdf', src_crs='EPSG:5070', dst_crs='EPSG:4326') -# leafmap.view_vector(gdf, get_fill_color=[0, 0, 255, 128]) +gdf = leafmap.read_parquet( + url, return_type="gdf", src_crs="EPSG:5070", dst_crs="EPSG:4326" +) +leafmap.view_vector(gdf, get_fill_color=[0, 0, 255, 128]) ``` ## Data analysis -Find out the total number non-floodplain wetlands in the conterminous United States: +Find out the total number of NFWs in CONUS: ```{code-cell} ipython3 -con.sql(f""" +con.sql( + f""" SELECT COUNT(*) AS Count FROM 's3://us-west-2.opendata.source.coop/giswqs/giw/wetlands/*.parquet' -""") +""" +) ``` -Find out the number of non-floodplain wetlands in each state and order them by the number of wetlands: +The total number of NFWs in CONUS is 8,380,620. + ++++ + +Find out the number of NFWs in each state and order them by the number of NFWs: ```{code-cell} ipython3 -count_df = con.sql(f""" +giw_count_df = con.sql( + f""" SELECT inState AS State, COUNT(*) AS Count FROM 's3://us-west-2.opendata.source.coop/giswqs/giw/wetlands/*.parquet' GROUP BY inState ORDER BY COUNT(*) DESC; -""").df() -count_df.head() +""" +).df() +giw_count_df.head() ``` -Create a bar chart showing the number of non-floodplain wetlands in each state: +Create a pie chart showing the number of NFWs in each state: ```{code-cell} ipython3 -leafmap.pie_chart(count_df, 'State', 'Count', height=700, title='Number of Non-Floodplain Wetlands by State') +leafmap.pie_chart( + giw_count_df, + "State", + "Count", + height=700, + title="Number of Non-Floodplain Wetlands (NFWs) by State", +) ``` -![](https://i.imgur.com/GgtlcWB.png) +![](https://i.imgur.com/SNpVzcC.png) -Create a bar chart showing the number of non-floodplain wetlands in each state: +Create a bar chart showing the number of NFWs in each state: ```{code-cell} ipython3 -leafmap.bar_chart(count_df, 'State', 'Count', title='Number of Non-Floodplain Wetlands by State') +leafmap.bar_chart( + giw_count_df, "State", "Count", title="Number of Non-Floodplain Wetlands (NFWs) by State" +) ``` -![](https://i.imgur.com/v4zz8zV.png) +![](https://i.imgur.com/19gxoBE.png) -Calculate the total area of non-floodplain wetlands in each state and order them by the area of wetlands: +Calculate the total area of NFWs in each state and order them by the area of wetlands: ```{code-cell} ipython3 -sum_df = con.sql(f""" +sum_df = con.sql( + f""" SELECT inState AS State, Sum(hectares) AS Hectares FROM 's3://us-west-2.opendata.source.coop/giswqs/giw/wetlands/*.parquet' GROUP BY inState ORDER BY Sum(hectares) DESC; -""").df() +""" +).df() sum_df.head() ``` -Create a pie chart showing the total area of non-floodplain wetlands in each state: +Create a pie chart showing the total area of NFWs in each state: ```{code-cell} ipython3 -leafmap.pie_chart(sum_df, 'State', 'Hectares', height=700, title='Area of Non-Floodplain Wetlands by State') +leafmap.pie_chart( + sum_df, + "State", + "Hectares", + height=700, + title="Percentage Area of Non-Floodplain Wetlands (NFWs) by State", +) ``` -![](https://i.imgur.com/mAsLCDE.png) +![](https://i.imgur.com/dayPfZY.png) -Create a pie chart showing the total area of non-floodplain wetlands in each state: +Create a pie chart showing the total area of NFWs in each state: ```{code-cell} ipython3 -leafmap.bar_chart(sum_df, 'State', 'Hectares', title='Area of Non-Floodplain Wetlands by State') +leafmap.bar_chart( + sum_df, "State", "Hectares", title="Total Area of Non-Floodplain Wetlands (NFWs) by State" +) ``` -![](https://i.imgur.com/7RtioFU.png) - -Find out the mean area of non-floodplain wetlands in each state and order them by the mean area of wetlands: - ```{code-cell} ipython3 -median_df = con.sql(f""" +median_df = con.sql( + f""" SELECT inState AS State, median(hectares)*10000 AS Meters FROM 's3://us-west-2.opendata.source.coop/giswqs/giw/wetlands/*.parquet' GROUP BY inState ORDER BY median(hectares) DESC; -""").df() +""" +).df() median_df.head(10) ``` -Create a bar chart showing the median area of non-floodplain wetlands in each state: +Create a bar chart showing the median area of NFWs in each state: + +```{code-cell} ipython3 +leafmap.bar_chart( + median_df, + "State", + "Meters", + title="Median Area of Non-Floodplain Wetlands (NFWs) by State", +) +``` + +![](https://i.imgur.com/OZahOKx.png) + ++++ + +Calculate the number of NFWs intersecting surface depressions (i.e., wetland depressions) in each state: + +```{code-cell} ipython3 +giw_dep_count_stat = con.sql( + f""" +SELECT inState AS State, COUNT(DISTINCT Final_ID) AS Count +FROM 's3://us-west-2.opendata.source.coop/giswqs/giw/wetlands_v2/*.parquet' +WHERE area IS NOT NULL +GROUP BY inState +ORDER BY COUNT(*) DESC; +""" +).df() +giw_dep_count_stat.head() +``` + +Merge the NFW table with the wetland depressions table: + +```{code-cell} ipython3 +merged_df = giw_count_df.merge(giw_dep_count_stat, on="State") +merged_df.columns = ["State", "GIW_Count", "DEP_Count"] +merged_df["Percent"] = merged_df["DEP_Count"] / merged_df["GIW_Count"] * 100 +merged_df.head() +``` + +Compare the number of NFWs and wetland depressions in each state: + +```{code-cell} ipython3 +leafmap.bar_chart( + merged_df, + "State", + ["GIW_Count", "DEP_Count"], + title="Number of NFWs and Wetland Depressions by State", +) +``` + +![](https://i.imgur.com/BsPdZ82.png) + ++++ + +Compute the statistics of the area of NFWs and wetland depressions in each state: + +```{code-cell} ipython3 +giw_dep_count_stat = con.sql( + f""" +SELECT inState AS State, COUNT(DISTINCT Final_ID) AS Count, +SUM(area) / 1e6 AS Total_Area_km2, +SUM(volume) / 1e9 AS Total_Volume_km3, +Median(area) AS Median_Area_m2, +Median(volume) AS Median_Volume_m3 +FROM 's3://us-west-2.opendata.source.coop/giswqs/giw/wetlands_v2/*.parquet' +WHERE area IS NOT NULL +GROUP BY inState +ORDER BY COUNT(*) DESC; +""" +).df() +giw_dep_count_stat.head(10) +``` + +The median size of wetland depressions in each state: + +```{code-cell} ipython3 +leafmap.bar_chart( + giw_dep_count_stat[giw_dep_count_stat['State'] != "NV"], + "State", + "Median_Area_m2", + title="The Median Size of Maximum Depression Area by State", +) +``` + +![](https://i.imgur.com/nkD0NSM.png) + ++++ + +The median maximum storage volume of wetland depressions in each state: ```{code-cell} ipython3 -leafmap.bar_chart(median_df, 'State', 'Meters', title='Median Area of Non-Floodplain Wetlands by State') +leafmap.bar_chart( + giw_dep_count_stat, + "State", + "Median_Volume_m3", + title="The Median Maximum Storage Volume of Wetlands Depressions by State", +) ``` -![](https://i.imgur.com/2iAYcm3.png) +![](https://i.imgur.com/OLohMJ9.png) diff --git a/giw/jupytext.toml b/giw/jupytext.toml new file mode 100644 index 0000000..0426784 --- /dev/null +++ b/giw/jupytext.toml @@ -0,0 +1,9 @@ +# Install jupytext using: conda install jupytext -c conda-forge +# Always pair ipynb notebooks to md files. +# formats = "ipynb,md" +formats = "ipynb,myst" + +# jupytext --to ipynb *.md # convert all .md files to notebooks with no outputs +# jupytext --to ipynb --execute *.md # convert all .md files to notebooks and execute them +# jupytext --set-formats ipynb,md --execute *.md # convert all .md files to paired notebooks and execute them +# jupytext --to md *.ipynb # convert all .ipynb files to .md files \ No newline at end of file