From 130fb9dbffc6f9f8eebb620aaebaef63b5e06171 Mon Sep 17 00:00:00 2001 From: Nupur Lal Date: Thu, 24 Aug 2023 13:08:40 +0000 Subject: [PATCH 1/2] incorporated review comments for flood proximity --- .../Flood_Proximity_Analysis_Python.ipynb | 47 ++++++++++++++----- 1 file changed, 36 insertions(+), 11 deletions(-) diff --git a/UseCases/Flood_Proximity_Analysis/Flood_Proximity_Analysis_Python.ipynb b/UseCases/Flood_Proximity_Analysis/Flood_Proximity_Analysis_Python.ipynb index 211d135d..bb5b6399 100644 --- a/UseCases/Flood_Proximity_Analysis/Flood_Proximity_Analysis_Python.ipynb +++ b/UseCases/Flood_Proximity_Analysis/Flood_Proximity_Analysis_Python.ipynb @@ -26,7 +26,9 @@ "
    \n", "
  1. Inspect Geospatial data using client-side tools and visualization
  2. \n", "
  3. Analyze Proximity at Scale using ClearScape Analytic functions to calculate flood location centroids and risk boundaries, and then apply the analysis at scale to analyze every New Zealand address and asses high, medium, and low risk based on proximity to the flood zones
  4. \n", - "
" + " \n", + "\n", + "

For the demo we have taken approximately 60k address sample from 1.6million addresses of North Island." ] }, { @@ -107,9 +109,9 @@ }, "outputs": [], "source": [ - "#%run -i ../run_procedure.py \"call get_data('DEMO_NZFloods_cloud');\"\n", + "%run -i ../run_procedure.py \"call get_data('DEMO_NZFloods_cloud');\"\n", " # takes about 30 seconds, estimated space: 0 MB\n", - "%run -i ../run_procedure.py \"call get_data('DEMO_NZFloods_local');\" \n", + "#%run -i ../run_procedure.py \"call get_data('DEMO_NZFloods_local');\" \n", "# takes about 30 seconds, estimated space: 3 MB" ] }, @@ -182,7 +184,7 @@ "source": [ "print('NZ Street Addresses with Lat, Lon, and POINT object:')\n", "ipydisplay(tdf_addrs)\n", - "print('Sample 10k Addresses:')\n", + "print('Sample 60k Addresses:')\n", "ipydisplay(tdf_addrs.shape)" ] }, @@ -288,8 +290,7 @@ "source": [ "

2.5 Calculate Centroids

\n", "\n", - "

In order to properly compute geometric properties, in this case centroids, of the geometries, we need to project the data to a projected coordinate system.

\n", - "\n" + "

A centroid is the geometric centre of the object or shape. In order to properly compute geometric properties, in this case centroids, of the geometries, we need to project the data to a projected coordinate system.

\n" ] }, { @@ -348,6 +349,13 @@ "m" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

In the map above, the blue markers are the centroid of each of the flood zones (1-7)." + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -357,7 +365,7 @@ "

" ] @@ -544,9 +552,7 @@ "
  • Red for addresses inside the Flood Zone
  • \n", "
  • Yellow for addresses 0 to 5 KM away
  • \n", "
  • Green for addresses 5 to 10 KM away
  • \n", - " \n", - "\n", - "

    Note there are about 400 addresses inside the 10 KM boundary to Flood Zone 7.

    " + " \n" ] }, { @@ -655,7 +661,7 @@ }, "outputs": [], "source": [ - "fig = Figure(width=600, height=400)\n", + "fig = Figure(width=850, height=500)\n", "hm = folium.Map(location=[-39.646172303816414, 176.775454544966948], zoom_start=8)\n", "\n", "\n", @@ -678,6 +684,13 @@ "fig.add_child(hm)" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

    The above map shows are the total count of the addresses. You can zoom the map to individual address location, click on the aggregated count and the map will zoom in or you can click the '+' button." + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -713,6 +726,18 @@ "hm" ] }, + { + "cell_type": "markdown", + "metadata": { + "ExecuteTime": { + "end_time": "2023-03-20T17:01:08.775855Z", + "start_time": "2023-03-20T17:00:17.595009Z" + } + }, + "source": [ + "

    The above map shows are the total count of the addresses with their risk zone marked. We have created three risk zones based on the distance of the address from the flood zone." + ] + }, { "cell_type": "code", "execution_count": null, From 3900c8022b85c9ccf77dfd5ea4e3c19b30f65d6d Mon Sep 17 00:00:00 2001 From: Doug Ebel Date: Wed, 30 Aug 2023 13:42:37 +0000 Subject: [PATCH 2/2] clarified explanations --- .../Flood_Proximity_Analysis_Python.ipynb | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/UseCases/Flood_Proximity_Analysis/Flood_Proximity_Analysis_Python.ipynb b/UseCases/Flood_Proximity_Analysis/Flood_Proximity_Analysis_Python.ipynb index bb5b6399..d9f96777 100644 --- a/UseCases/Flood_Proximity_Analysis/Flood_Proximity_Analysis_Python.ipynb +++ b/UseCases/Flood_Proximity_Analysis/Flood_Proximity_Analysis_Python.ipynb @@ -227,7 +227,7 @@ "source": [ "

    2.3 Putting the Flood Zones on a Map

    \n", "\n", - "

    This demonstration uses the folium package along with geopandas to overlay the flood zone data on an interactive map

    " + "

    This demonstration uses the folium package along with geopandas to overlay the flood zone data on an interactive map. We will start by showing the basic map (named \"m\").

    " ] }, { @@ -253,7 +253,7 @@ "source": [ "

    2.4 Draw the Flood Regions

    \n", "\n", - "

    Use Pandas, GeoPandas, and Folium to paint the flood zones

    " + "

    Use Pandas, GeoPandas, and Folium to paint the flood zones on top of the basic map (named \"m\")

    " ] }, { @@ -376,7 +376,8 @@ "source": [ "

    3.1 Calculate Centroids and Buffer Zones in-Database

    \n", "\n", - "

    Use the centroid property as well as the buffer method of the teradataml DataFrame to inspect and calculate this data in-database. Note this python syntax is automaticaly translated to SQL to run in the Vantage system. The ST_Centroid and ST_Buffer SQL functions can be run directly as well to perform the same calculations.

    " + "

    Use the centroid property as well as the buffer method of the teradataml DataFrame to inspect and calculate this data in-database. Note this python syntax is automaticaly translated to SQL to run in the Vantage system. The ST_Centroid and ST_Buffer SQL functions can be run directly as well to perform the same calculations.

    \n", + "

    For the following steps, we will focus on Zone 7 located in the southeast side of North Island around Hastings.

    " ] }, { @@ -403,7 +404,7 @@ "source": [ "

    3.2 Map the Buffer

    \n", "\n", - "

    Retrieve the buffer shape to the client, and use GeoPandas methods to simplify the shape so it can be easily drawn on the map.

    " + "

    Retrieve the buffer shape to the client, and use GeoPandas methods to simplify the shape so zone 7 can be easily drawn on the map.

    " ] }, { @@ -552,7 +553,8 @@ "
  • Red for addresses inside the Flood Zone
  • \n", "
  • Yellow for addresses 0 to 5 KM away
  • \n", "
  • Green for addresses 5 to 10 KM away
  • \n", - " \n" + " \n", + "

    Note there are about 400 addresses inside the 10 KM boundary to Flood Zone 7.

    " ] }, { @@ -735,7 +737,7 @@ } }, "source": [ - "

    The above map shows are the total count of the addresses with their risk zone marked. We have created three risk zones based on the distance of the address from the flood zone." + "

    The heat map shows the number of properties at risk within an area. As you move your mouse over the circles and zoom in and out, you will see the shape of the area marked with the circle and the basis of the color. Hundreds of properties would be red, less than 10 might be green.

    " ] }, { @@ -778,7 +780,7 @@ " lon=gdf_st_dist['lon'],\n", " z=gdf_st_dist['RISK'],\n", " radius=3,\n", - " colorscale=[[0.0, 'blue',],[0.3,'lime'],[0.5,'yellow'],[0.7,'orange'],[1.0, 'red']],\n", + " colorscale=[[0.0, 'blue',],[0.3,'green'],[0.5,'yellow'],[0.7,'orange'],[1.0, 'red']],\n", " zmin=0.0,\n", " zmax=1.0,\n", " opacity=0.5 \n", @@ -793,6 +795,13 @@ "fig.show()" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

    On this representation the density of properties at a given zoom level changes by color alone. As you zoom in, the dots will go from red to yellow to orange to green.

    " + ] + }, { "cell_type": "markdown", "metadata": {},