Accidents near elementary schools, such as this one has drawn the attention of city employees and civic-minded individuals to the topic of pedestrian and bicycle safety.
In this notebook, we want to suggest policy actions to civic authorities of Pasadena, California that will reduce the likelihood of future accidents. We will map accident data regarding pedestrians and cyclists struck by vehicles. Then, we will determine the number of accidents that occurred within each school zone and identify the five most dangerous zones. We will present this analysis using a notebook that provides narrative context and helps stakeholders understand our methodology.
The sample uses ArcGIS API for Python to help city officials in improving pedestrian and bicycle safety near schools in the city. We will first uncover patterns in accident data using spatial analysis tool such as
HeatmapRenderer highlights the capabilities of map widget to show areas where large number of accidents occurred. To visualize different category of accidents on the map,
create_symbol tool plays a vital role along with functionality of renderers and arcade expressions.
As the visualizations are not enough to make policy decisions, we'll further use
summarize_within tools to determine the number of accidents that have occurred within half mile walk distance from each school.
Since the city does not have enough funds that encompasses all school zones, we will limit our analysis to the five most vulnerable areas. So, we apply filter to identify the five most dangerous zones in which a pedestrian or cyclist was injured or killed. City officials could then suggest measures such as adding more bike lanes in these areas or change street signs to reduce accidents near schools and increase safety.
%matplotlib inline import pandas as pd from datetime import datetime import matplotlib.pyplot as plt from IPython.display import display from arcgis.gis import GIS from arcgis.features.analyze_patterns import calculate_density from arcgis.features.analyze_patterns import find_hot_spots from arcgis.mapping.symbol import create_symbol from arcgis.features.use_proximity import create_drive_time_areas from arcgis.features.summarize_data import summarize_within
Connect to the GIS via an existing profile or creating a new connection by e.g. gis = GIS("https://www.arcgis.com", "arcgis_python", "P@ssword123")
gis = GIS(profile="your_online_profile")
Search for the Traffic Collisions layer. You can specify the owner's name as "api_data_owner" to get more specific results.
items = gis.content.search('title:Traffic Collisions, owner:api_data_owner', 'feature layer')
item = items
The item shows all accidents that occurred in Pasadena during the past decade.
We can print the names of the layers in this item and assign them to variables that will be used in our analysis
The code below prints name of layers.
for lyr in item.layers: print(lyr.properties.name)
Since the item is a Feature Layer Collection, accessing the layers property gives us a list of FeatureLayer objects. The collisions layer is the only layer in this item.
collisions = item.layers
m1 = gis.map('Pasadena, California') m1