From f022cb10cdd031c4a773ccc8a160b450fe7834dd Mon Sep 17 00:00:00 2001
From: Shuang Song <103439749+cariashuang0417@users.noreply.github.com>
Date: Tue, 22 Oct 2024 14:54:10 -0400
Subject: [PATCH] updates_for_designate_bike_routes_sample_24
---
...e_routes_for_commuting_professionals.ipynb | 650 +++++++-----------
1 file changed, 261 insertions(+), 389 deletions(-)
diff --git a/samples/04_gis_analysts_data_scientists/designate_bike_routes_for_commuting_professionals.ipynb b/samples/04_gis_analysts_data_scientists/designate_bike_routes_for_commuting_professionals.ipynb
index 8ddd80b03d..ad8994e32a 100644
--- a/samples/04_gis_analysts_data_scientists/designate_bike_routes_for_commuting_professionals.ipynb
+++ b/samples/04_gis_analysts_data_scientists/designate_bike_routes_for_commuting_professionals.ipynb
@@ -13,7 +13,7 @@
"source": [
"Traffic congestion has been increasing in cities due to long commutes to and from work. A simple measure of using bicycles for commuting can prove to be a very effective solution for this problem. This will also be a healthy option for individuals by making them physically active. In order to encourage citizens to use bicycles for commute, cities need to ensure that there are adequate number of safe bike lanes.\n",
"\n",
- "This sample uses ArcGIS API for Python to analyze and select streets for making bike routes for people commuting to and from work in the City of Seattle, Washington. It will demostrate the use tools such as `find_existing_locations`, `create_buffers`, `merge_layers`, `dissolve_boundaries`, `overlay_layers`, `enrich_layer`, and attribute `query`. We will also be using Esri Tapestry Segmentation to perform this analysis. \n",
+ "This sample uses ArcGIS API for Python to analyze and select streets for making bike routes for people commuting to and from work in the City of Seattle, Washington. It will demostrate the use tools such as `find_existing_locations`, `create_buffers`, `merge_layers`, `dissolve_boundaries`, `overlay_layers`, `enrich_layer`, and attribute `query`. \n",
"\n",
"The aim of this analysis is to:\n",
"\n",
@@ -63,11 +63,9 @@
" \n",
"2) Filter Seattle's zoning layer by downtown office.\n",
"\n",
- "3) Identify high demand neighborhood. We use the tapestry segmentation layer and visualize it on the map. We click some of the segments in the vicinity of Downtown area and choose a segment that contains young, health-conscious and environmentally-conscious professionals, i.e, Capitol Hill which serves as a good target to get started.\n",
+ "3) Filter neighborhoods layer by Capitol Hill.\n",
"\n",
- "4) Filter neighborhoods layer by Capitol Hill.\n",
- "\n",
- "5) Check if the bike lanes can be made on trails.\n",
+ "4) Check if the bike lanes can be made on trails.\n",
"\n",
"5) Use `find existing_locations` to get arterial streets layer. We use this tool to select the streets which will be the most appropriate for making bike lanes. \n",
" \n",
@@ -93,7 +91,10 @@
{
"cell_type": "markdown",
"metadata": {
- "collapsed": true
+ "collapsed": true,
+ "jupyter": {
+ "outputs_hidden": true
+ }
},
"source": [
"### Necessary Imports"
@@ -101,7 +102,7 @@
},
{
"cell_type": "code",
- "execution_count": 1,
+ "execution_count": null,
"metadata": {},
"outputs": [],
"source": [
@@ -157,17 +158,17 @@
"text/html": [
"
\n",
"
\n",
"\n",
"
\n",
- "
SeattleBikeRoutes\n",
+ " SeattleBikeRoutes\n",
" \n",
- "
datascience
Feature Layer Collection by api_data_owner\n",
+ "
datascience
Feature Layer Collection by api_data_owner\n",
"
Last Modified: June 13, 2019\n",
- "
0 comments, 0 views\n",
+ "
0 comments, 127 views\n",
"
\n",
"
\n",
" "
@@ -281,140 +282,69 @@
]
},
{
- "cell_type": "code",
- "execution_count": 10,
+ "cell_type": "markdown",
"metadata": {},
- "outputs": [],
"source": [
- "tapestry_segmentation = gis.content.search('\"2018 USA Tapestry segmentation\" owner: api_data_owner',\n",
- " 'Map Image Layer')[0]"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 11,
- "metadata": {},
- "outputs": [
- {
- "data": {
- "text/html": [
- "\n",
- "
\n",
- "\n",
- "
\n",
- "
2018 USA Tapestry Segmentation\n",
- " \n",
- "
This layer shows the dominant LifeMode Summary Group in the United States in 2018 by state, county, ZIP Code, tract, and block group based on Esri's Tapestry Segmentation system. ArcGIS Online subscription required.
Map Image Layer by api_data_owner\n",
- "
Last Modified: June 05, 2019\n",
- "
0 comments, 0 views\n",
- "
\n",
- "
\n",
- " "
- ],
- "text/plain": [
- "- "
- ]
- },
- "execution_count": 11,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "tapestry_segmentation"
+ "### Identify potential bike routes\n",
+ "\n",
+ "The Streets layer includes main streets, trails, and other street types. Let's look at the trails first to determine if they can be used for commuting.\n",
+ "\n",
+ "Filter the Streets so that only the trails are showing, by setting a definition expression that filters the roads by the segment type of trails (SEGMENT_TY = 8)."
]
},
{
"cell_type": "code",
- "execution_count": 12,
+ "execution_count": 104,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
- ""
+ ""
],
"text/plain": [
""
]
},
- "execution_count": 12,
+ "execution_count": 104,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
- "tapestry_map = gis.map('Seattle')\n",
- "tapestry_map"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 13,
- "metadata": {
- "collapsed": true
- },
- "outputs": [],
- "source": [
- "tapestry_map.add_layer(tapestry_segmentation)"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "The neighborhood in the 98112 ZIP Code, called Capitol Hill, contains the Urban Chic, Laptops and Lattes, and Metro Renters segments. All three of the segments designated in the ZIP Code mention environmental awareness and biking, which makes the ZIP Code a good choice to get the bike lane project started."
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "### Identify potential bike routes\n",
- "\n",
- "The Streets layer includes main streets, trails, and other street types. Let's look at the trails first to determine if they can be used for commuting.\n",
- "\n",
- "Filter the Streets so that only the trails are showing, by setting a definition expression that filters the roads by the segment type of trails (SEGMENT_TY = 8)."
+ "bike_street_filtered_map = gis.map('Seattle')\n",
+ "bike_street_filtered_map.basemap.basemap = \"arcgis-streets\"\n",
+ "bike_street_filtered_map"
]
},
{
"cell_type": "code",
- "execution_count": 14,
+ "execution_count": 93,
"metadata": {},
"outputs": [
{
"data": {
- "text/html": [
- ""
- ],
"text/plain": [
- ""
+ " 185 features"
]
},
- "execution_count": 14,
+ "execution_count": 93,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
- "bike_street_filtered_map = gis.map('Seattle')\n",
- "bike_street_filtered_map"
+ "bike_route_streets_trails = bike_route_streets.query(\"SEGMENT_TY = 8\") # code for trails\n",
+ "bike_route_streets_trails"
]
},
{
"cell_type": "code",
- "execution_count": 15,
+ "execution_count": 94,
"metadata": {},
"outputs": [],
"source": [
- "bike_street_filtered_map.add_layer({\"type\":\"FeatureLayer\", \n",
- " \"url\":bike_route_streets.url,\n",
- " \"definition_expression\" : \"SEGMENT_TY = 8\", # code for trails\n",
- " })"
+ "bike_street_filtered_map.content.add(bike_route_streets_trails)"
]
},
{
@@ -437,11 +367,17 @@
},
{
"cell_type": "code",
- "execution_count": 16,
- "metadata": {
- "collapsed": true
- },
- "outputs": [],
+ "execution_count": 95,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "{\"cost\": 26.209}\n"
+ ]
+ }
+ ],
"source": [
"busy_streets = find_existing_locations(input_layers=[{'url': bike_route_streets.url}], \n",
" expressions=[{\"operator\":\"\",\"layer\":0,\"where\":\"SEGMENT_TY = 1\"},\n",
@@ -451,7 +387,7 @@
},
{
"cell_type": "code",
- "execution_count": 17,
+ "execution_count": 96,
"metadata": {},
"outputs": [
{
@@ -460,7 +396,7 @@
" 6605 features"
]
},
- "execution_count": 17,
+ "execution_count": 96,
"metadata": {},
"output_type": "execute_result"
}
@@ -471,37 +407,36 @@
},
{
"cell_type": "code",
- "execution_count": 18,
+ "execution_count": 105,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
- ""
+ ""
],
"text/plain": [
""
]
},
- "execution_count": 18,
+ "execution_count": 105,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"busy_streets_map = gis.map('Seattle')\n",
+ "busy_streets_map.basemap.basemap = \"arcgis-streets\n",
"busy_streets_map"
]
},
{
"cell_type": "code",
- "execution_count": 19,
- "metadata": {
- "collapsed": true
- },
+ "execution_count": 98,
+ "metadata": {},
"outputs": [],
"source": [
- "busy_streets_map.add_layer(busy_streets)"
+ "busy_streets_map.content.add(busy_streets)"
]
},
{
@@ -517,10 +452,8 @@
},
{
"cell_type": "code",
- "execution_count": 20,
- "metadata": {
- "collapsed": true
- },
+ "execution_count": 99,
+ "metadata": {},
"outputs": [],
"source": [
"busy_streets_layer = busy_streets.layers[0]"
@@ -542,11 +475,17 @@
},
{
"cell_type": "code",
- "execution_count": 21,
- "metadata": {
- "collapsed": true
- },
- "outputs": [],
+ "execution_count": 30,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "{\"cost\": 6.61}\n"
+ ]
+ }
+ ],
"source": [
"madison_street = find_existing_locations(input_layers=[{'url': busy_streets_layer.url},\n",
" {'url': bike_route_neighbourhood.url, 'filter':\"L_HOOD = 'CAPITOL HILL'\"}],\n",
@@ -558,7 +497,7 @@
},
{
"cell_type": "code",
- "execution_count": 22,
+ "execution_count": 31,
"metadata": {},
"outputs": [
{
@@ -566,26 +505,26 @@
"text/html": [
"
\n",
"
\n",
"\n",
"
\n",
- "
MadisonStreet715882\n",
+ " MadisonStreet694249\n",
" \n",
- "
Feature Layer Collection by arcgis_python\n",
- "
Last Modified: June 13, 2019\n",
+ "
Feature Layer Collection by arcgis_python\n",
+ "
Last Modified: October 22, 2024\n",
"
0 comments, 0 views\n",
"
\n",
"
\n",
" "
],
"text/plain": [
- "- "
+ "
- "
]
},
- "execution_count": 22,
+ "execution_count": 31,
"metadata": {},
"output_type": "execute_result"
}
@@ -596,10 +535,8 @@
},
{
"cell_type": "code",
- "execution_count": 23,
- "metadata": {
- "collapsed": true
- },
+ "execution_count": 32,
+ "metadata": {},
"outputs": [],
"source": [
"madison_street_lyr = madison_street.layers[0]"
@@ -607,10 +544,8 @@
},
{
"cell_type": "code",
- "execution_count": 24,
- "metadata": {
- "collapsed": true
- },
+ "execution_count": 33,
+ "metadata": {},
"outputs": [],
"source": [
"stat_1 = madison_street_lyr.query(where='1=1',\n",
@@ -627,10 +562,8 @@
},
{
"cell_type": "code",
- "execution_count": 25,
- "metadata": {
- "collapsed": true
- },
+ "execution_count": 34,
+ "metadata": {},
"outputs": [],
"source": [
"df1 = stat_1.sdf # field statistics"
@@ -638,10 +571,8 @@
},
{
"cell_type": "code",
- "execution_count": 26,
- "metadata": {
- "collapsed": true
- },
+ "execution_count": 35,
+ "metadata": {},
"outputs": [],
"source": [
"len1 = df1.sumField.values[0]"
@@ -649,7 +580,7 @@
},
{
"cell_type": "code",
- "execution_count": 27,
+ "execution_count": 36,
"metadata": {},
"outputs": [
{
@@ -658,7 +589,7 @@
"2.47538356"
]
},
- "execution_count": 27,
+ "execution_count": 36,
"metadata": {},
"output_type": "execute_result"
}
@@ -676,10 +607,8 @@
},
{
"cell_type": "code",
- "execution_count": 28,
- "metadata": {
- "collapsed": true
- },
+ "execution_count": 37,
+ "metadata": {},
"outputs": [],
"source": [
"madison_street_layer = madison_street.layers[0]"
@@ -687,37 +616,36 @@
},
{
"cell_type": "code",
- "execution_count": 29,
+ "execution_count": 106,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
- ""
+ ""
],
"text/plain": [
""
]
},
- "execution_count": 29,
+ "execution_count": 106,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"madison_map = gis.map('Seattle')\n",
+ "madison_map.basemap.basemap = \"arcgis-streets\"\n",
"madison_map"
]
},
{
"cell_type": "code",
- "execution_count": 30,
- "metadata": {
- "collapsed": true
- },
+ "execution_count": 101,
+ "metadata": {},
"outputs": [],
"source": [
- "madison_map.add_layer(madison_street)"
+ "madison_map.content.add(madison_street)"
]
},
{
@@ -737,11 +665,17 @@
},
{
"cell_type": "code",
- "execution_count": 31,
- "metadata": {
- "collapsed": true
- },
- "outputs": [],
+ "execution_count": 40,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "{\"cost\": 0.041}\n"
+ ]
+ }
+ ],
"source": [
"buffer_street = create_buffers(madison_street_layer,\n",
" dissolve_type='Dissolve',\n",
@@ -753,10 +687,8 @@
},
{
"cell_type": "code",
- "execution_count": 32,
- "metadata": {
- "collapsed": true
- },
+ "execution_count": 41,
+ "metadata": {},
"outputs": [],
"source": [
"buffer_street_layer = buffer_street.layers[0]"
@@ -764,37 +696,36 @@
},
{
"cell_type": "code",
- "execution_count": 33,
+ "execution_count": 107,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
- ""
+ ""
],
"text/plain": [
""
]
},
- "execution_count": 33,
+ "execution_count": 107,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"buffer_street_map = gis.map('Seattle')\n",
+ "buffer_street_map.basemap.basemap = \"arcgis-streets\"\n",
"buffer_street_map"
]
},
{
"cell_type": "code",
- "execution_count": 34,
- "metadata": {
- "collapsed": true
- },
+ "execution_count": 103,
+ "metadata": {},
"outputs": [],
"source": [
- "buffer_street_map.add_layer(buffer_street)"
+ "buffer_street_map.content.add(buffer_street)"
]
},
{
@@ -813,11 +744,17 @@
},
{
"cell_type": "code",
- "execution_count": 35,
- "metadata": {
- "collapsed": true
- },
- "outputs": [],
+ "execution_count": 44,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "{\"cost\": 6.61}\n"
+ ]
+ }
+ ],
"source": [
"broadway_ave = find_existing_locations(input_layers=[{'url': busy_streets_layer.url},\n",
" {'url': bike_route_neighbourhood.url, 'filter':\"L_HOOD = 'CAPITOL HILL'\"}],\n",
@@ -831,10 +768,8 @@
},
{
"cell_type": "code",
- "execution_count": 36,
- "metadata": {
- "collapsed": true
- },
+ "execution_count": 45,
+ "metadata": {},
"outputs": [],
"source": [
"broadway_ave_layer = broadway_ave.layers[0]"
@@ -842,10 +777,8 @@
},
{
"cell_type": "code",
- "execution_count": 37,
- "metadata": {
- "collapsed": true
- },
+ "execution_count": 46,
+ "metadata": {},
"outputs": [],
"source": [
"stat_2 = broadway_ave_layer.query(where='1=1',\n",
@@ -857,10 +790,8 @@
},
{
"cell_type": "code",
- "execution_count": 38,
- "metadata": {
- "collapsed": true
- },
+ "execution_count": 47,
+ "metadata": {},
"outputs": [],
"source": [
"df2 = stat_2.sdf"
@@ -868,10 +799,8 @@
},
{
"cell_type": "code",
- "execution_count": 39,
- "metadata": {
- "collapsed": true
- },
+ "execution_count": 48,
+ "metadata": {},
"outputs": [],
"source": [
"len2 = df2.sumField.values[0]"
@@ -879,7 +808,7 @@
},
{
"cell_type": "code",
- "execution_count": 40,
+ "execution_count": 49,
"metadata": {},
"outputs": [
{
@@ -888,7 +817,7 @@
"1.98774174"
]
},
- "execution_count": 40,
+ "execution_count": 49,
"metadata": {},
"output_type": "execute_result"
}
@@ -906,37 +835,36 @@
},
{
"cell_type": "code",
- "execution_count": 41,
+ "execution_count": 108,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
- ""
+ ""
],
"text/plain": [
""
]
},
- "execution_count": 41,
+ "execution_count": 108,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"broadway_ave_map = gis.map('Seattle')\n",
+ "broadway_ave_map.basemap.basemap = \"arcgis-streets\"\n",
"broadway_ave_map"
]
},
{
"cell_type": "code",
- "execution_count": 42,
- "metadata": {
- "collapsed": true
- },
+ "execution_count": 51,
+ "metadata": {},
"outputs": [],
"source": [
- "broadway_ave_map.add_layer(broadway_ave)"
+ "broadway_ave_map.content.add(broadway_ave)"
]
},
{
@@ -948,10 +876,8 @@
},
{
"cell_type": "code",
- "execution_count": 43,
- "metadata": {
- "collapsed": true
- },
+ "execution_count": null,
+ "metadata": {},
"outputs": [],
"source": [
"buffer_street_broadway = create_buffers(broadway_ave_layer,\n",
@@ -964,33 +890,36 @@
},
{
"cell_type": "code",
- "execution_count": 44,
+ "execution_count": 110,
"metadata": {},
"outputs": [
{
"data": {
- "application/vnd.jupyter.widget-view+json": {
- "model_id": "590d53c6fda64372b59a10c90148a85c"
- }
+ "text/html": [
+ ""
+ ],
+ "text/plain": [
+ ""
+ ]
},
+ "execution_count": 110,
"metadata": {},
- "output_type": "display_data"
+ "output_type": "execute_result"
}
],
"source": [
"buffer_street_broadway_map = gis.map('Seattle')\n",
+ "buffer_street_broadway_map.basemap.basemap = \"arcgis-streets\"\n",
"buffer_street_broadway_map"
]
},
{
"cell_type": "code",
- "execution_count": 45,
- "metadata": {
- "collapsed": true
- },
+ "execution_count": 55,
+ "metadata": {},
"outputs": [],
"source": [
- "buffer_street_broadway_map.add_layer(buffer_street_broadway)"
+ "buffer_street_broadway_map.content.add(buffer_street_broadway)"
]
},
{
@@ -1009,10 +938,8 @@
},
{
"cell_type": "code",
- "execution_count": 46,
- "metadata": {
- "collapsed": true
- },
+ "execution_count": null,
+ "metadata": {},
"outputs": [],
"source": [
"ave = find_existing_locations(input_layers=[{'url': busy_streets_layer.url},\n",
@@ -1027,10 +954,8 @@
},
{
"cell_type": "code",
- "execution_count": 47,
- "metadata": {
- "collapsed": true
- },
+ "execution_count": 57,
+ "metadata": {},
"outputs": [],
"source": [
"ave_layer = ave.layers[0]"
@@ -1038,10 +963,8 @@
},
{
"cell_type": "code",
- "execution_count": 48,
- "metadata": {
- "collapsed": true
- },
+ "execution_count": 58,
+ "metadata": {},
"outputs": [],
"source": [
"stat_3 = ave_layer.query(where='1=1',\n",
@@ -1058,10 +981,8 @@
},
{
"cell_type": "code",
- "execution_count": 49,
- "metadata": {
- "collapsed": true
- },
+ "execution_count": 59,
+ "metadata": {},
"outputs": [],
"source": [
"df3 = stat_3.sdf"
@@ -1069,10 +990,8 @@
},
{
"cell_type": "code",
- "execution_count": 50,
- "metadata": {
- "collapsed": true
- },
+ "execution_count": 60,
+ "metadata": {},
"outputs": [],
"source": [
"len3 = df3.sumField.values[0]"
@@ -1080,7 +999,7 @@
},
{
"cell_type": "code",
- "execution_count": 51,
+ "execution_count": 61,
"metadata": {},
"outputs": [
{
@@ -1089,7 +1008,7 @@
"1.63694922"
]
},
- "execution_count": 51,
+ "execution_count": 61,
"metadata": {},
"output_type": "execute_result"
}
@@ -1107,39 +1026,36 @@
},
{
"cell_type": "code",
- "execution_count": 52,
- "metadata": {
- "scrolled": false
- },
+ "execution_count": 111,
+ "metadata": {},
"outputs": [
{
"data": {
"text/html": [
- ""
+ ""
],
"text/plain": [
""
]
},
- "execution_count": 52,
+ "execution_count": 111,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"ave_map = gis.map('Seattle')\n",
+ "ave_map.basemap.basemap = \"arcgis-streets\"\n",
"ave_map"
]
},
{
"cell_type": "code",
- "execution_count": 53,
- "metadata": {
- "collapsed": true
- },
+ "execution_count": 64,
+ "metadata": {},
"outputs": [],
"source": [
- "ave_map.add_layer(ave_layer)"
+ "ave_map.content.add(ave_layer)"
]
},
{
@@ -1151,10 +1067,8 @@
},
{
"cell_type": "code",
- "execution_count": 54,
- "metadata": {
- "collapsed": true
- },
+ "execution_count": null,
+ "metadata": {},
"outputs": [],
"source": [
"buffer_street_ave = create_buffers(ave_layer,\n",
@@ -1167,37 +1081,36 @@
},
{
"cell_type": "code",
- "execution_count": 55,
+ "execution_count": 112,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
- ""
+ ""
],
"text/plain": [
""
]
},
- "execution_count": 55,
+ "execution_count": 112,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"buffer_street_ave_map = gis.map('Seattle')\n",
+ "buffer_street_ave_map.basemap.basemap = \"arcgis-streets\"\n",
"buffer_street_ave_map"
]
},
{
"cell_type": "code",
- "execution_count": 56,
- "metadata": {
- "collapsed": true
- },
+ "execution_count": 67,
+ "metadata": {},
"outputs": [],
"source": [
- "buffer_street_ave_map.add_layer(buffer_street_ave)"
+ "buffer_street_ave_map.content.add(buffer_street_ave)"
]
},
{
@@ -1216,10 +1129,8 @@
},
{
"cell_type": "code",
- "execution_count": 57,
- "metadata": {
- "collapsed": true
- },
+ "execution_count": null,
+ "metadata": {},
"outputs": [],
"source": [
"capitol_hill_streets = find_existing_locations(input_layers=[{'url': bike_route_streets.url},\n",
@@ -1232,10 +1143,8 @@
},
{
"cell_type": "code",
- "execution_count": 58,
- "metadata": {
- "collapsed": true
- },
+ "execution_count": 69,
+ "metadata": {},
"outputs": [],
"source": [
"capitol_hill_lyr = capitol_hill_streets.layers[0]"
@@ -1243,10 +1152,8 @@
},
{
"cell_type": "code",
- "execution_count": 59,
- "metadata": {
- "collapsed": true
- },
+ "execution_count": 70,
+ "metadata": {},
"outputs": [],
"source": [
"stat_4 = capitol_hill_lyr.query(where='1=1',\n",
@@ -1264,7 +1171,7 @@
},
{
"cell_type": "code",
- "execution_count": 60,
+ "execution_count": 71,
"metadata": {
"scrolled": true
},
@@ -1290,39 +1197,34 @@
" \n",
"
\n",
" | \n",
- " avgField | \n",
" countField | \n",
- " maxField | \n",
+ " sumField | \n",
" minField | \n",
+ " maxField | \n",
+ " avgField | \n",
" stddevField | \n",
- " sumField | \n",
- " SHAPE | \n",
"
\n",
" \n",
" \n",
" \n",
" 0 | \n",
- " 0.068718 | \n",
" 1361 | \n",
- " 0.944354 | \n",
+ " 93.52469 | \n",
" 0.002864 | \n",
+ " 0.944354 | \n",
+ " 0.068718 | \n",
" 0.047955 | \n",
- " 93.52469 | \n",
- " {'spatialReference': {'wkid': 2926, 'latestWki... | \n",
"
\n",
" \n",
"\n",
""
],
"text/plain": [
- " avgField countField maxField minField stddevField sumField \\\n",
- "0 0.068718 1361 0.944354 0.002864 0.047955 93.52469 \n",
- "\n",
- " SHAPE \n",
- "0 {'spatialReference': {'wkid': 2926, 'latestWki... "
+ " countField sumField minField maxField avgField stddevField\n",
+ "0 1361 93.52469 0.002864 0.944354 0.068718 0.047955"
]
},
- "execution_count": 60,
+ "execution_count": 71,
"metadata": {},
"output_type": "execute_result"
}
@@ -1333,10 +1235,8 @@
},
{
"cell_type": "code",
- "execution_count": 61,
- "metadata": {
- "collapsed": true
- },
+ "execution_count": 72,
+ "metadata": {},
"outputs": [],
"source": [
"df4 = stat_4.sdf "
@@ -1344,10 +1244,8 @@
},
{
"cell_type": "code",
- "execution_count": 62,
- "metadata": {
- "collapsed": true
- },
+ "execution_count": 73,
+ "metadata": {},
"outputs": [],
"source": [
"len4 = df4.sumField.values[0]"
@@ -1355,16 +1253,16 @@
},
{
"cell_type": "code",
- "execution_count": 63,
+ "execution_count": 74,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
- "93.52469044"
+ "93.52469041"
]
},
- "execution_count": 63,
+ "execution_count": 74,
"metadata": {},
"output_type": "execute_result"
}
@@ -1389,7 +1287,7 @@
},
{
"cell_type": "code",
- "execution_count": 64,
+ "execution_count": 75,
"metadata": {},
"outputs": [
{
@@ -1398,7 +1296,7 @@
"6.522421505228268"
]
},
- "execution_count": 65,
+ "execution_count": 75,
"metadata": {},
"output_type": "execute_result"
}
@@ -1430,10 +1328,8 @@
},
{
"cell_type": "code",
- "execution_count": 65,
- "metadata": {
- "collapsed": true
- },
+ "execution_count": null,
+ "metadata": {},
"outputs": [],
"source": [
"merge_madison_broadway_buffer = merge_layers(buffer_street,\n",
@@ -1443,10 +1339,8 @@
},
{
"cell_type": "code",
- "execution_count": 66,
- "metadata": {
- "collapsed": true
- },
+ "execution_count": null,
+ "metadata": {},
"outputs": [],
"source": [
"merge_all_buffers = merge_layers(merge_madison_broadway_buffer,\n",
@@ -1456,37 +1350,36 @@
},
{
"cell_type": "code",
- "execution_count": 67,
+ "execution_count": 113,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
- ""
+ ""
],
"text/plain": [
""
]
},
- "execution_count": 67,
+ "execution_count": 113,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"buffer_map = gis.map('Seattle')\n",
+ "buffer_map.basemap.basemap = \"arcgis-streets\"\n",
"buffer_map"
]
},
{
"cell_type": "code",
- "execution_count": 68,
- "metadata": {
- "collapsed": true
- },
+ "execution_count": 79,
+ "metadata": {},
"outputs": [],
"source": [
- "buffer_map.add_layer(merge_all_buffers)"
+ "buffer_map.content.add(merge_all_buffers)"
]
},
{
@@ -1505,10 +1398,8 @@
},
{
"cell_type": "code",
- "execution_count": 69,
- "metadata": {
- "collapsed": true
- },
+ "execution_count": null,
+ "metadata": {},
"outputs": [],
"source": [
"dissolve = dissolve_boundaries(merge_all_buffers,\n",
@@ -1517,37 +1408,36 @@
},
{
"cell_type": "code",
- "execution_count": 70,
+ "execution_count": 114,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
- ""
+ ""
],
"text/plain": [
""
]
},
- "execution_count": 70,
+ "execution_count": 114,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"dissolve_map = gis.map('Seattle')\n",
+ "dissolve_map.basemap.basemap = \"arcgis-streets\"\n",
"dissolve_map"
]
},
{
"cell_type": "code",
- "execution_count": 71,
- "metadata": {
- "collapsed": true
- },
+ "execution_count": 82,
+ "metadata": {},
"outputs": [],
"source": [
- "dissolve_map.add_layer(dissolve)"
+ "dissolve_map.content.add(dissolve)"
]
},
{
@@ -1566,10 +1456,8 @@
},
{
"cell_type": "code",
- "execution_count": 72,
- "metadata": {
- "collapsed": true
- },
+ "execution_count": null,
+ "metadata": {},
"outputs": [],
"source": [
"cliped_buffer = overlay_layers(dissolve,\n",
@@ -1581,10 +1469,8 @@
},
{
"cell_type": "code",
- "execution_count": 73,
- "metadata": {
- "collapsed": true
- },
+ "execution_count": 84,
+ "metadata": {},
"outputs": [],
"source": [
"cliped_buffer_layer = cliped_buffer.layers[0]"
@@ -1592,37 +1478,36 @@
},
{
"cell_type": "code",
- "execution_count": 74,
+ "execution_count": 115,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
- ""
+ ""
],
"text/plain": [
""
]
},
- "execution_count": 74,
+ "execution_count": 115,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cliped_buffer_map = gis.map('Seattle')\n",
+ "cliped_buffer_map.basemap.basemap = \"arcgis-streets\"\n",
"cliped_buffer_map"
]
},
{
"cell_type": "code",
- "execution_count": 75,
- "metadata": {
- "collapsed": true
- },
+ "execution_count": 86,
+ "metadata": {},
"outputs": [],
"source": [
- "cliped_buffer_map.add_layer(cliped_buffer)"
+ "cliped_buffer_map.content.add(cliped_buffer)"
]
},
{
@@ -1641,10 +1526,8 @@
},
{
"cell_type": "code",
- "execution_count": 76,
- "metadata": {
- "collapsed": true
- },
+ "execution_count": null,
+ "metadata": {},
"outputs": [],
"source": [
"clipped_enrich = enrich_layer(cliped_buffer_layer, \n",
@@ -1661,10 +1544,8 @@
},
{
"cell_type": "code",
- "execution_count": 77,
- "metadata": {
- "collapsed": true
- },
+ "execution_count": null,
+ "metadata": {},
"outputs": [],
"source": [
"capitolhill_enrich = enrich_layer(bike_route_neighbourhood,\n",
@@ -1674,10 +1555,8 @@
},
{
"cell_type": "code",
- "execution_count": 78,
- "metadata": {
- "collapsed": true
- },
+ "execution_count": 89,
+ "metadata": {},
"outputs": [],
"source": [
"clip_lyr = clipped_enrich.layers[0]"
@@ -1685,10 +1564,8 @@
},
{
"cell_type": "code",
- "execution_count": 79,
- "metadata": {
- "collapsed": true
- },
+ "execution_count": 90,
+ "metadata": {},
"outputs": [],
"source": [
"stat_5 = clip_lyr.query(where='1=1',\n",
@@ -1705,7 +1582,7 @@
},
{
"cell_type": "code",
- "execution_count": 80,
+ "execution_count": 91,
"metadata": {},
"outputs": [
{
@@ -1729,39 +1606,34 @@
" \n",
" \n",
" | \n",
- " avgField | \n",
" countField | \n",
- " maxField | \n",
+ " sumField | \n",
" minField | \n",
+ " maxField | \n",
+ " avgField | \n",
" stddevField | \n",
- " sumField | \n",
- " SHAPE | \n",
"
\n",
" \n",
" \n",
" \n",
" 0 | \n",
- " 9886.2 | \n",
" 5 | \n",
- " 27189 | \n",
- " 1263 | \n",
- " 10397.063081 | \n",
- " 49431 | \n",
- " {'spatialReference': {'wkid': 2926, 'latestWki... | \n",
+ " 52490.0 | \n",
+ " 1374.0 | \n",
+ " 29400.0 | \n",
+ " 10498.0 | \n",
+ " 11313.92264 | \n",
"
\n",
" \n",
"\n",
""
],
"text/plain": [
- " avgField countField maxField minField stddevField sumField \\\n",
- "0 9886.2 5 27189 1263 10397.063081 49431 \n",
- "\n",
- " SHAPE \n",
- "0 {'spatialReference': {'wkid': 2926, 'latestWki... "
+ " countField sumField minField maxField avgField stddevField\n",
+ "0 5 52490.0 1374.0 29400.0 10498.0 11313.92264"
]
},
- "execution_count": 80,
+ "execution_count": 91,
"metadata": {},
"output_type": "execute_result"
}
@@ -1880,7 +1752,7 @@
"notebookRuntimeVersion": "9.0"
},
"kernelspec": {
- "display_name": "Python 3",
+ "display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
@@ -1894,9 +1766,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
- "version": "3.7.9"
+ "version": "3.11.0"
}
},
"nbformat": 4,
- "nbformat_minor": 2
+ "nbformat_minor": 4
}