{ "cells": [ { "cell_type": "code", "execution_count": 87, "id": "41da1fbc-35b7-49cc-9352-a262309b444e", "metadata": { "collapsed": true, "jupyter": { "outputs_hidden": true }, "tags": [] }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Defaulting to user installation because normal site-packages is not writeable\n", "Requirement already satisfied: geopandas in /cvmfs/cybergis.illinois.edu/software/conda/cybergisx/python3-0.9.0/lib/python3.8/site-packages (0.10.2)\n", "Requirement already satisfied: folium in /cvmfs/cybergis.illinois.edu/software/conda/cybergisx/python3-0.9.0/lib/python3.8/site-packages (0.12.1.post1)\n", "Requirement already satisfied: rasterio in /cvmfs/cybergis.illinois.edu/software/conda/cybergisx/python3-0.9.0/lib/python3.8/site-packages (1.2.8)\n", "Requirement already satisfied: pyproj>=2.2.0 in /cvmfs/cybergis.illinois.edu/software/conda/cybergisx/python3-0.9.0/lib/python3.8/site-packages (from geopandas) (3.3.0)\n", "Requirement already satisfied: pandas>=0.25.0 in /cvmfs/cybergis.illinois.edu/software/conda/cybergisx/python3-0.9.0/lib/python3.8/site-packages (from geopandas) (1.3.5)\n", "Requirement already satisfied: shapely>=1.6 in /cvmfs/cybergis.illinois.edu/software/conda/cybergisx/python3-0.9.0/lib/python3.8/site-packages (from geopandas) (1.8.0)\n", "Requirement already satisfied: fiona>=1.8 in /cvmfs/cybergis.illinois.edu/software/conda/cybergisx/python3-0.9.0/lib/python3.8/site-packages (from geopandas) (1.8.20)\n", "Requirement already satisfied: numpy in /cvmfs/cybergis.illinois.edu/software/conda/cybergisx/python3-0.9.0/lib/python3.8/site-packages (from folium) (1.22.0)\n", "Requirement already satisfied: jinja2>=2.9 in /cvmfs/cybergis.illinois.edu/software/conda/cybergisx/python3-0.9.0/lib/python3.8/site-packages (from folium) (3.0.3)\n", "Requirement already satisfied: requests in /cvmfs/cybergis.illinois.edu/software/conda/cybergisx/python3-0.9.0/lib/python3.8/site-packages (from folium) (2.27.1)\n", "Requirement already satisfied: branca>=0.3.0 in /cvmfs/cybergis.illinois.edu/software/conda/cybergisx/python3-0.9.0/lib/python3.8/site-packages (from folium) (0.4.2)\n", "Requirement already satisfied: click>=4.0 in /cvmfs/cybergis.illinois.edu/software/conda/cybergisx/python3-0.9.0/lib/python3.8/site-packages (from rasterio) (7.1.2)\n", "Requirement already satisfied: setuptools in /cvmfs/cybergis.illinois.edu/software/conda/cybergisx/python3-0.9.0/lib/python3.8/site-packages (from rasterio) (59.8.0)\n", "Requirement already satisfied: affine in /cvmfs/cybergis.illinois.edu/software/conda/cybergisx/python3-0.9.0/lib/python3.8/site-packages (from rasterio) (2.3.0)\n", "Requirement already satisfied: attrs in /cvmfs/cybergis.illinois.edu/software/conda/cybergisx/python3-0.9.0/lib/python3.8/site-packages (from rasterio) (21.4.0)\n", "Requirement already satisfied: click-plugins in /cvmfs/cybergis.illinois.edu/software/conda/cybergisx/python3-0.9.0/lib/python3.8/site-packages (from rasterio) (1.1.1)\n", "Requirement already satisfied: cligj>=0.5 in /cvmfs/cybergis.illinois.edu/software/conda/cybergisx/python3-0.9.0/lib/python3.8/site-packages (from rasterio) (0.7.2)\n", "Requirement already satisfied: snuggs>=1.4.1 in /cvmfs/cybergis.illinois.edu/software/conda/cybergisx/python3-0.9.0/lib/python3.8/site-packages (from rasterio) (1.4.7)\n", "Requirement already satisfied: certifi in /cvmfs/cybergis.illinois.edu/software/conda/cybergisx/python3-0.9.0/lib/python3.8/site-packages (from rasterio) (2021.10.8)\n", "Requirement already satisfied: six>=1.7 in /cvmfs/cybergis.illinois.edu/software/conda/cybergisx/python3-0.9.0/lib/python3.8/site-packages (from fiona>=1.8->geopandas) (1.16.0)\n", "Requirement already satisfied: munch in /cvmfs/cybergis.illinois.edu/software/conda/cybergisx/python3-0.9.0/lib/python3.8/site-packages (from fiona>=1.8->geopandas) (2.5.0)\n", "Requirement already satisfied: MarkupSafe>=2.0 in /cvmfs/cybergis.illinois.edu/software/conda/cybergisx/python3-0.9.0/lib/python3.8/site-packages (from jinja2>=2.9->folium) (2.0.1)\n", "Requirement already satisfied: python-dateutil>=2.7.3 in /cvmfs/cybergis.illinois.edu/software/conda/cybergisx/python3-0.9.0/lib/python3.8/site-packages (from pandas>=0.25.0->geopandas) (2.8.0)\n", "Requirement already satisfied: pytz>=2017.3 in /cvmfs/cybergis.illinois.edu/software/conda/cybergisx/python3-0.9.0/lib/python3.8/site-packages (from pandas>=0.25.0->geopandas) (2021.3)\n", "Requirement already satisfied: pyparsing>=2.1.6 in /cvmfs/cybergis.illinois.edu/software/conda/cybergisx/python3-0.9.0/lib/python3.8/site-packages (from snuggs>=1.4.1->rasterio) (3.0.7)\n", "Requirement already satisfied: charset-normalizer~=2.0.0 in /cvmfs/cybergis.illinois.edu/software/conda/cybergisx/python3-0.9.0/lib/python3.8/site-packages (from requests->folium) (2.0.10)\n", "Requirement already satisfied: idna<4,>=2.5 in /cvmfs/cybergis.illinois.edu/software/conda/cybergisx/python3-0.9.0/lib/python3.8/site-packages (from requests->folium) (3.3)\n", "Requirement already satisfied: urllib3<1.27,>=1.21.1 in /cvmfs/cybergis.illinois.edu/software/conda/cybergisx/python3-0.9.0/lib/python3.8/site-packages (from requests->folium) (1.25.11)\n", "Note: you may need to restart the kernel to use updated packages.\n" ] } ], "source": [ "pip install geopandas folium rasterio" ] }, { "cell_type": "code", "execution_count": 93, "id": "01fdb484-883c-4374-981e-62483c8a704b", "metadata": { "collapsed": true, "jupyter": { "outputs_hidden": true }, "tags": [] }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Defaulting to user installation because normal site-packages is not writeable\n", "Requirement already satisfied: folium in /cvmfs/cybergis.illinois.edu/software/conda/cybergisx/python3-0.9.0/lib/python3.8/site-packages (0.12.1.post1)\n", "Requirement already satisfied: geopandas in /cvmfs/cybergis.illinois.edu/software/conda/cybergisx/python3-0.9.0/lib/python3.8/site-packages (0.10.2)\n", "Requirement already satisfied: requests in /cvmfs/cybergis.illinois.edu/software/conda/cybergisx/python3-0.9.0/lib/python3.8/site-packages (from folium) (2.27.1)\n", "Requirement already satisfied: jinja2>=2.9 in /cvmfs/cybergis.illinois.edu/software/conda/cybergisx/python3-0.9.0/lib/python3.8/site-packages (from folium) (3.0.3)\n", "Requirement already satisfied: numpy in /cvmfs/cybergis.illinois.edu/software/conda/cybergisx/python3-0.9.0/lib/python3.8/site-packages (from folium) (1.22.0)\n", "Requirement already satisfied: branca>=0.3.0 in /cvmfs/cybergis.illinois.edu/software/conda/cybergisx/python3-0.9.0/lib/python3.8/site-packages (from folium) (0.4.2)\n", "Requirement already satisfied: shapely>=1.6 in /cvmfs/cybergis.illinois.edu/software/conda/cybergisx/python3-0.9.0/lib/python3.8/site-packages (from geopandas) (1.8.0)\n", "Requirement already satisfied: fiona>=1.8 in /cvmfs/cybergis.illinois.edu/software/conda/cybergisx/python3-0.9.0/lib/python3.8/site-packages (from geopandas) (1.8.20)\n", "Requirement already satisfied: pyproj>=2.2.0 in /cvmfs/cybergis.illinois.edu/software/conda/cybergisx/python3-0.9.0/lib/python3.8/site-packages (from geopandas) (3.3.0)\n", "Requirement already satisfied: pandas>=0.25.0 in /cvmfs/cybergis.illinois.edu/software/conda/cybergisx/python3-0.9.0/lib/python3.8/site-packages (from geopandas) (1.3.5)\n", "Requirement already satisfied: attrs>=17 in /cvmfs/cybergis.illinois.edu/software/conda/cybergisx/python3-0.9.0/lib/python3.8/site-packages (from fiona>=1.8->geopandas) (21.4.0)\n", "Requirement already satisfied: certifi in /cvmfs/cybergis.illinois.edu/software/conda/cybergisx/python3-0.9.0/lib/python3.8/site-packages (from fiona>=1.8->geopandas) (2021.10.8)\n", "Requirement already satisfied: click>=4.0 in /cvmfs/cybergis.illinois.edu/software/conda/cybergisx/python3-0.9.0/lib/python3.8/site-packages (from fiona>=1.8->geopandas) (7.1.2)\n", "Requirement already satisfied: cligj>=0.5 in /cvmfs/cybergis.illinois.edu/software/conda/cybergisx/python3-0.9.0/lib/python3.8/site-packages (from fiona>=1.8->geopandas) (0.7.2)\n", "Requirement already satisfied: click-plugins>=1.0 in /cvmfs/cybergis.illinois.edu/software/conda/cybergisx/python3-0.9.0/lib/python3.8/site-packages (from fiona>=1.8->geopandas) (1.1.1)\n", "Requirement already satisfied: six>=1.7 in /cvmfs/cybergis.illinois.edu/software/conda/cybergisx/python3-0.9.0/lib/python3.8/site-packages (from fiona>=1.8->geopandas) (1.16.0)\n", "Requirement already satisfied: munch in /cvmfs/cybergis.illinois.edu/software/conda/cybergisx/python3-0.9.0/lib/python3.8/site-packages (from fiona>=1.8->geopandas) (2.5.0)\n", "Requirement already satisfied: setuptools in /cvmfs/cybergis.illinois.edu/software/conda/cybergisx/python3-0.9.0/lib/python3.8/site-packages (from fiona>=1.8->geopandas) (59.8.0)\n", "Requirement already satisfied: MarkupSafe>=2.0 in /cvmfs/cybergis.illinois.edu/software/conda/cybergisx/python3-0.9.0/lib/python3.8/site-packages (from jinja2>=2.9->folium) (2.0.1)\n", "Requirement already satisfied: python-dateutil>=2.7.3 in /cvmfs/cybergis.illinois.edu/software/conda/cybergisx/python3-0.9.0/lib/python3.8/site-packages (from pandas>=0.25.0->geopandas) (2.8.0)\n", "Requirement already satisfied: pytz>=2017.3 in /cvmfs/cybergis.illinois.edu/software/conda/cybergisx/python3-0.9.0/lib/python3.8/site-packages (from pandas>=0.25.0->geopandas) (2021.3)\n", "Requirement already satisfied: urllib3<1.27,>=1.21.1 in /cvmfs/cybergis.illinois.edu/software/conda/cybergisx/python3-0.9.0/lib/python3.8/site-packages (from requests->folium) (1.25.11)\n", "Requirement already satisfied: charset-normalizer~=2.0.0 in /cvmfs/cybergis.illinois.edu/software/conda/cybergisx/python3-0.9.0/lib/python3.8/site-packages (from requests->folium) (2.0.10)\n", "Requirement already satisfied: idna<4,>=2.5 in /cvmfs/cybergis.illinois.edu/software/conda/cybergisx/python3-0.9.0/lib/python3.8/site-packages (from requests->folium) (3.3)\n", "Note: you may need to restart the kernel to use updated packages.\n" ] } ], "source": [ "pip install folium geopandas\n" ] }, { "cell_type": "code", "execution_count": 94, "id": "3ea3aa3d-31e3-4d68-babf-27780afb5509", "metadata": {}, "outputs": [], "source": [ "import folium\n", "import geopandas as gpd\n" ] }, { "cell_type": "code", "execution_count": 98, "id": "d881a1be-a4b0-4088-a627-077e36437688", "metadata": {}, "outputs": [], "source": [ "#Watershed & Subwatershed\n", "shapefile_path = \"WBDHU12.shp\" #This contains the boundaries of the watershed 8 - 14080105 and its subwatersheds\n", "gdf = gpd.read_file(shapefile_path)\n" ] }, { "cell_type": "code", "execution_count": 108, "id": "95d7a1bc-e5e5-4345-aade-235181c3840d", "metadata": {}, "outputs": [], "source": [ "geojson_data = gdf.__geo_interface__ #GeoDataFrame data to GeoJSON data\n", "m = folium.Map(location=[36.9990, -109.0452], zoom_start=7) #make a folium map centered in the Southwest\n", "\n" ] }, { "cell_type": "code", "execution_count": 109, "id": "e78409e1-609d-4a45-9689-1024aa3ba2c9", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "" ] }, "execution_count": 109, "metadata": {}, "output_type": "execute_result" } ], "source": [ "#Add the overlay to the folium map\n", "folium.GeoJson(\n", " geojson_data,\n", " name=\"My Shapefile Overlay\"\n", ").add_to(m)\n" ] }, { "cell_type": "code", "execution_count": 110, "id": "2938c79e-b71a-4670-be26-bf82ec47e4c8", "metadata": {}, "outputs": [], "source": [ "m.save(\"shapefile_map.html\") #make it an html file that we can see on the web" ] }, { "cell_type": "code", "execution_count": null, "id": "8b88df0e-15e4-4de7-b6f9-afbdd10adaf4", "metadata": { "tags": [] }, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "id": "3b5a0d94-84c2-49bd-9665-d0c26f136118", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "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.8.12" } }, "nbformat": 4, "nbformat_minor": 5 }