Introduction: Traffic Saffety is quite concerning in a growing suburban area like Montgomery County, Maryland, where Law Enforcement officers operate and conduct traffic stops on a daily basis to prevent accidents and enforcing compliance with road regulations. This project will look into officer-issues traffic violations to reveal any temporal and spatial enforcement patterns within Montgomery County.
This dataset was published by Montgomery County’s Police Department through their county’s open data which will contain the records of traffic stops with variables such as Date Of Stop, District, Violation Type, and Enforcement Unit. With these variables will give way for a comprehensive analysis of law enforcement behavior and driver’s compliance. The inclusion of the variable Enforcement Unit is quite essential to this research because it will also reveal the use of such vehicles like Unmarked and Marked Law enforcement vehicles, indicating how different enforcement methods may influence stop frequencies, as well utilizing District for location trends.
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(lubridate)
##
## Attaching package: 'lubridate'
## The following objects are masked from 'package:base':
##
## date, intersect, setdiff, union
library(zoo)
##
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
##
## as.Date, as.Date.numeric
library(forcats)
library(ggplot2)
tv_data <- read.csv("traffic_violations.csv")
str(tv_data)
## 'data.frame': 2049900 obs. of 43 variables:
## $ SeqID : chr "89305975-69ea-40bb-8555-05ffaf2eafab" "20fcbffa-fec9-40c5-af03-4d46a21b669b" "782cb378-1676-4f96-af0d-de083fd13001" "e11807d7-dde1-49fd-88d0-c1e628692b70" ...
## $ Date.Of.Stop : chr "10/09/2025" "10/09/2025" "10/09/2025" "10/09/2025" ...
## $ Time.Of.Stop : chr "11:15:00" "11:10:00" "11:09:00" "11:09:00" ...
## $ Agency : chr "MCP" "MCP" "MCP" "MCP" ...
## $ SubAgency : chr "6th District, Gaithersburg / Montgomery Village" "1st District, Rockville" "Headquarters and Special Operations" "6th District, Gaithersburg / Montgomery Village" ...
## $ Description : chr "EXCEEDING THE POSTED SPEED LIMIT OF 35 MPH" "EXCEEDING THE POSTED SPEED LIMIT OF 40 MPH" "PEDESTRIAN CROSSING ROADWAY BETWEEN ADJACENT INTERSECTIONS HAVING TRAFFIC CONTROL SIGNAL" "EXCEEDING THE POSTED SPEED LIMIT OF 35 MPH" ...
## $ Location : chr "GEORGIA @ HATHAWAY" "DARNESTOWN RD @ AMERICAN WAY" "VEIRS MILL RD @ RANDOLPH RD" "GEORGIA @ HATHAWAY" ...
## $ Latitude : num 39.1 39.1 0 39.1 39.2 ...
## $ Longitude : num -77.1 -77.2 0 -77.1 -77.2 ...
## $ Accident : chr "No" "No" "No" "No" ...
## $ Belts : chr "No" "No" "No" "No" ...
## $ Personal.Injury : chr "No" "No" "No" "No" ...
## $ Property.Damage : chr "No" "No" "No" "No" ...
## $ Fatal : chr "No" "No" "No" "No" ...
## $ Commercial.License : chr "No" "Yes" "No" "No" ...
## $ HAZMAT : chr "No" "No" "No" "No" ...
## $ Commercial.Vehicle : chr "No" "No" "No" "No" ...
## $ Alcohol : chr "No" "No" "No" "No" ...
## $ Work.Zone : chr "No" "No" "No" "No" ...
## $ Search.Conducted : chr "" "" "" "" ...
## $ Search.Disposition : chr "" "" "" "" ...
## $ Search.Outcome : chr "" "" "" "" ...
## $ Search.Reason : chr "" "" "" "" ...
## $ Search.Reason.For.Stop : chr "" "" "" "" ...
## $ Search.Type : chr "" "" "" "" ...
## $ Search.Arrest.Reason : chr "" "" "" "" ...
## $ State : chr "MD" "MD" "XX" "MD" ...
## $ VehicleType : chr "02 - Automobile" "02 - Automobile" "30 - Unknown" "02 - Automobile" ...
## $ Year : int 2011 2009 NA 2025 2014 2025 NA 2023 2007 2016 ...
## $ Make : chr "MERZ" "TOYOTA" "NONE" "FORD" ...
## $ Model : chr "SW" "COROLLA" "NONE" "CG" ...
## $ Color : chr "WHITE" "SILVER" "N/A" "WHITE" ...
## $ Violation.Type : chr "Warning" "Warning" "Warning" "Warning" ...
## $ Charge : chr "21-801.1" "21-801.1" "21-503(c)" "21-801.1" ...
## $ Article : chr "Transportation Article" "Transportation Article" "Transportation Article" "Transportation Article" ...
## $ Contributed.To.Accident: chr "False" "False" "False" "False" ...
## $ Race : chr "BLACK" "BLACK" "BLACK" "BLACK" ...
## $ Gender : chr "M" "M" "M" "M" ...
## $ Driver.City : chr "SILVER SPRING" "POOLESVILLE" "ROCKVILLE" "SILVER SPRING" ...
## $ Driver.State : chr "MD" "MD" "MD" "MD" ...
## $ DL.State : chr "MD" "MD" "MD" "MD" ...
## $ Arrest.Type : chr "Q - Marked Laser" "Q - Marked Laser" "A - Marked Patrol" "Q - Marked Laser" ...
## $ Geolocation : chr " (39.0694633333333, -77.062085)" " (39.105075, -77.231085)" " (0.0, 0.0)" " (39.068045, -77.0608133333333)" ...
head(tv_data)
## SeqID Date.Of.Stop Time.Of.Stop Agency
## 1 89305975-69ea-40bb-8555-05ffaf2eafab 10/09/2025 11:15:00 MCP
## 2 20fcbffa-fec9-40c5-af03-4d46a21b669b 10/09/2025 11:10:00 MCP
## 3 782cb378-1676-4f96-af0d-de083fd13001 10/09/2025 11:09:00 MCP
## 4 e11807d7-dde1-49fd-88d0-c1e628692b70 10/09/2025 11:09:00 MCP
## 5 758d1c64-508f-4d37-a41f-2171bd0a41fe 10/09/2025 11:06:00 MCP
## 6 63ea8860-e596-45e5-8be9-bf0a1bb17495 10/09/2025 11:04:00 MCP
## SubAgency
## 1 6th District, Gaithersburg / Montgomery Village
## 2 1st District, Rockville
## 3 Headquarters and Special Operations
## 4 6th District, Gaithersburg / Montgomery Village
## 5 Headquarters and Special Operations
## 6 1st District, Rockville
## Description
## 1 EXCEEDING THE POSTED SPEED LIMIT OF 35 MPH
## 2 EXCEEDING THE POSTED SPEED LIMIT OF 40 MPH
## 3 PEDESTRIAN CROSSING ROADWAY BETWEEN ADJACENT INTERSECTIONS HAVING TRAFFIC CONTROL SIGNAL
## 4 EXCEEDING THE POSTED SPEED LIMIT OF 35 MPH
## 5 EXCEEDING POSTED MAXIMUM SPEED LIMIT: 59 MPH IN A POSTED 35 MPH ZONE
## 6 EXCEEDING THE POSTED SPEED LIMIT OF 30 MPH
## Location Latitude Longitude Accident Belts
## 1 GEORGIA @ HATHAWAY 39.06946 -77.06208 No No
## 2 DARNESTOWN RD @ AMERICAN WAY 39.10507 -77.23108 No No
## 3 VEIRS MILL RD @ RANDOLPH RD 0.00000 0.00000 No No
## 4 GEORGIA @ HATHAWAY 39.06804 -77.06081 No No
## 5 SB GEORGIA AVE/RIPPLING BROOK DR 39.24399 -77.15366 No No
## 6 DARNESTOWN RD @ BLACKBERRY DR 39.11442 -77.24426 No No
## Personal.Injury Property.Damage Fatal Commercial.License HAZMAT
## 1 No No No No No
## 2 No No No Yes No
## 3 No No No No No
## 4 No No No No No
## 5 No No No No No
## 6 No No No No No
## Commercial.Vehicle Alcohol Work.Zone Search.Conducted Search.Disposition
## 1 No No No
## 2 No No No
## 3 No No No
## 4 No No No
## 5 No No No
## 6 No No No
## Search.Outcome Search.Reason Search.Reason.For.Stop Search.Type
## 1
## 2
## 3
## 4
## 5
## 6
## Search.Arrest.Reason State VehicleType Year Make Model Color
## 1 MD 02 - Automobile 2011 MERZ SW WHITE
## 2 MD 02 - Automobile 2009 TOYOTA COROLLA SILVER
## 3 XX 30 - Unknown NA NONE NONE N/A
## 4 MD 02 - Automobile 2025 FORD CG WHITE
## 5 MD 02 - Automobile 2014 VOLK 4S GRAY
## 6 MD 02 - Automobile 2025 DODGE UT BLACK
## Violation.Type Charge Article Contributed.To.Accident Race
## 1 Warning 21-801.1 Transportation Article False BLACK
## 2 Warning 21-801.1 Transportation Article False BLACK
## 3 Warning 21-503(c) Transportation Article False BLACK
## 4 Warning 21-801.1 Transportation Article False BLACK
## 5 Citation 21-801.1 Transportation Article False WHITE
## 6 Warning 21-801.1 Transportation Article False WHITE
## Gender Driver.City Driver.State DL.State Arrest.Type
## 1 M SILVER SPRING MD MD Q - Marked Laser
## 2 M POOLESVILLE MD MD Q - Marked Laser
## 3 M ROCKVILLE MD MD A - Marked Patrol
## 4 M SILVER SPRING MD MD Q - Marked Laser
## 5 M OLNEY MD MD E - Marked Stationary Radar
## 6 F GERMANTOWN MD MD Q - Marked Laser
## Geolocation
## 1 (39.0694633333333, -77.062085)
## 2 (39.105075, -77.231085)
## 3 (0.0, 0.0)
## 4 (39.068045, -77.0608133333333)
## 5 (39.243995, -77.1536633333333)
## 6 (39.1144216666667, -77.2442633333333)
names(tv_data)[names(tv_data) == "Date.Of.Stop"] <- "Date_of_Stop"
names(tv_data)[names(tv_data) == "Violation.Type"] <- "Violation_Type"
names(tv_data)[names(tv_data) == "Arrest.Type"] <- "Enforcement_Unit"
names(tv_data)[names(tv_data) == "SubAgency"] <- "District"
tv_data <- subset(tv_data, !is.na(Date_of_Stop) & Location != "")
colSums(is.na(tv_data))
## SeqID Date_of_Stop Time.Of.Stop
## 0 0 0
## Agency District Description
## 0 0 1
## Location Latitude Longitude
## 0 0 0
## Accident Belts Personal.Injury
## 0 0 0
## Property.Damage Fatal Commercial.License
## 0 0 0
## HAZMAT Commercial.Vehicle Alcohol
## 0 0 0
## Work.Zone Search.Conducted Search.Disposition
## 0 0 0
## Search.Outcome Search.Reason Search.Reason.For.Stop
## 0 0 0
## Search.Type Search.Arrest.Reason State
## 0 0 0
## VehicleType Year Make
## 0 10625 22
## Model Color Violation_Type
## 85 0 0
## Charge Article Contributed.To.Accident
## 0 0 0
## Race Gender Driver.City
## 0 0 307
## Driver.State DL.State Enforcement_Unit
## 0 0 0
## Geolocation
## 0
summary(tv_data)
## SeqID Date_of_Stop Time.Of.Stop Agency
## Length:2049896 Length:2049896 Length:2049896 Length:2049896
## Class :character Class :character Class :character Class :character
## Mode :character Mode :character Mode :character Mode :character
##
##
##
##
## District Description Location Latitude
## Length:2049896 Length:2049896 Length:2049896 Min. : 0.00
## Class :character Class :character Class :character 1st Qu.:39.02
## Mode :character Mode :character Mode :character Median :39.07
## Mean :36.16
## 3rd Qu.:39.14
## Max. :41.54
##
## Longitude Accident Belts Personal.Injury
## Min. :-151.26 Length:2049896 Length:2049896 Length:2049896
## 1st Qu.: -77.19 Class :character Class :character Class :character
## Median : -77.09 Mode :character Mode :character Mode :character
## Mean : -71.35
## 3rd Qu.: -77.03
## Max. : 39.06
##
## Property.Damage Fatal Commercial.License HAZMAT
## Length:2049896 Length:2049896 Length:2049896 Length:2049896
## Class :character Class :character Class :character Class :character
## Mode :character Mode :character Mode :character Mode :character
##
##
##
##
## Commercial.Vehicle Alcohol Work.Zone Search.Conducted
## Length:2049896 Length:2049896 Length:2049896 Length:2049896
## Class :character Class :character Class :character Class :character
## Mode :character Mode :character Mode :character Mode :character
##
##
##
##
## Search.Disposition Search.Outcome Search.Reason
## Length:2049896 Length:2049896 Length:2049896
## Class :character Class :character Class :character
## Mode :character Mode :character Mode :character
##
##
##
##
## Search.Reason.For.Stop Search.Type Search.Arrest.Reason
## Length:2049896 Length:2049896 Length:2049896
## Class :character Class :character Class :character
## Mode :character Mode :character Mode :character
##
##
##
##
## State VehicleType Year Make
## Length:2049896 Length:2049896 Min. : 0 Length:2049896
## Class :character Class :character 1st Qu.:2003 Class :character
## Mode :character Mode :character Median :2008 Mode :character
## Mean :2008
## 3rd Qu.:2013
## Max. :9999
## NA's :10625
## Model Color Violation_Type Charge
## Length:2049896 Length:2049896 Length:2049896 Length:2049896
## Class :character Class :character Class :character Class :character
## Mode :character Mode :character Mode :character Mode :character
##
##
##
##
## Article Contributed.To.Accident Race
## Length:2049896 Length:2049896 Length:2049896
## Class :character Class :character Class :character
## Mode :character Mode :character Mode :character
##
##
##
##
## Gender Driver.City Driver.State DL.State
## Length:2049896 Length:2049896 Length:2049896 Length:2049896
## Class :character Class :character Class :character Class :character
## Mode :character Mode :character Mode :character Mode :character
##
##
##
##
## Enforcement_Unit Geolocation
## Length:2049896 Length:2049896
## Class :character Class :character
## Mode :character Mode :character
##
##
##
##
head(tv_data)
## SeqID Date_of_Stop Time.Of.Stop Agency
## 1 89305975-69ea-40bb-8555-05ffaf2eafab 10/09/2025 11:15:00 MCP
## 2 20fcbffa-fec9-40c5-af03-4d46a21b669b 10/09/2025 11:10:00 MCP
## 3 782cb378-1676-4f96-af0d-de083fd13001 10/09/2025 11:09:00 MCP
## 4 e11807d7-dde1-49fd-88d0-c1e628692b70 10/09/2025 11:09:00 MCP
## 5 758d1c64-508f-4d37-a41f-2171bd0a41fe 10/09/2025 11:06:00 MCP
## 6 63ea8860-e596-45e5-8be9-bf0a1bb17495 10/09/2025 11:04:00 MCP
## District
## 1 6th District, Gaithersburg / Montgomery Village
## 2 1st District, Rockville
## 3 Headquarters and Special Operations
## 4 6th District, Gaithersburg / Montgomery Village
## 5 Headquarters and Special Operations
## 6 1st District, Rockville
## Description
## 1 EXCEEDING THE POSTED SPEED LIMIT OF 35 MPH
## 2 EXCEEDING THE POSTED SPEED LIMIT OF 40 MPH
## 3 PEDESTRIAN CROSSING ROADWAY BETWEEN ADJACENT INTERSECTIONS HAVING TRAFFIC CONTROL SIGNAL
## 4 EXCEEDING THE POSTED SPEED LIMIT OF 35 MPH
## 5 EXCEEDING POSTED MAXIMUM SPEED LIMIT: 59 MPH IN A POSTED 35 MPH ZONE
## 6 EXCEEDING THE POSTED SPEED LIMIT OF 30 MPH
## Location Latitude Longitude Accident Belts
## 1 GEORGIA @ HATHAWAY 39.06946 -77.06208 No No
## 2 DARNESTOWN RD @ AMERICAN WAY 39.10507 -77.23108 No No
## 3 VEIRS MILL RD @ RANDOLPH RD 0.00000 0.00000 No No
## 4 GEORGIA @ HATHAWAY 39.06804 -77.06081 No No
## 5 SB GEORGIA AVE/RIPPLING BROOK DR 39.24399 -77.15366 No No
## 6 DARNESTOWN RD @ BLACKBERRY DR 39.11442 -77.24426 No No
## Personal.Injury Property.Damage Fatal Commercial.License HAZMAT
## 1 No No No No No
## 2 No No No Yes No
## 3 No No No No No
## 4 No No No No No
## 5 No No No No No
## 6 No No No No No
## Commercial.Vehicle Alcohol Work.Zone Search.Conducted Search.Disposition
## 1 No No No
## 2 No No No
## 3 No No No
## 4 No No No
## 5 No No No
## 6 No No No
## Search.Outcome Search.Reason Search.Reason.For.Stop Search.Type
## 1
## 2
## 3
## 4
## 5
## 6
## Search.Arrest.Reason State VehicleType Year Make Model Color
## 1 MD 02 - Automobile 2011 MERZ SW WHITE
## 2 MD 02 - Automobile 2009 TOYOTA COROLLA SILVER
## 3 XX 30 - Unknown NA NONE NONE N/A
## 4 MD 02 - Automobile 2025 FORD CG WHITE
## 5 MD 02 - Automobile 2014 VOLK 4S GRAY
## 6 MD 02 - Automobile 2025 DODGE UT BLACK
## Violation_Type Charge Article Contributed.To.Accident Race
## 1 Warning 21-801.1 Transportation Article False BLACK
## 2 Warning 21-801.1 Transportation Article False BLACK
## 3 Warning 21-503(c) Transportation Article False BLACK
## 4 Warning 21-801.1 Transportation Article False BLACK
## 5 Citation 21-801.1 Transportation Article False WHITE
## 6 Warning 21-801.1 Transportation Article False WHITE
## Gender Driver.City Driver.State DL.State Enforcement_Unit
## 1 M SILVER SPRING MD MD Q - Marked Laser
## 2 M POOLESVILLE MD MD Q - Marked Laser
## 3 M ROCKVILLE MD MD A - Marked Patrol
## 4 M SILVER SPRING MD MD Q - Marked Laser
## 5 M OLNEY MD MD E - Marked Stationary Radar
## 6 F GERMANTOWN MD MD Q - Marked Laser
## Geolocation
## 1 (39.0694633333333, -77.062085)
## 2 (39.105075, -77.231085)
## 3 (0.0, 0.0)
## 4 (39.068045, -77.0608133333333)
## 5 (39.243995, -77.1536633333333)
## 6 (39.1144216666667, -77.2442633333333)
#Converts the Violation Type to a factor
tv_data$Violation_Type <- as.factor(tv_data$Violation_Type)
summary(tv_data$Violation_Type)
## Citation ESERO SERO Warning
## 881700 90947 902 1076347
#Counts the amount of each violation type from the Dataset
violation_count <- table(tv_data$Violation_Type)
violation_count
##
## Citation ESERO SERO Warning
## 881700 90947 902 1076347
#Visualizing those counts
barplot(violation_count / 1000,
main = "Traffic Stops by Violation Type",
xlab = "Violation Type",
ylab = "Number of Stops (In Thousands)",
col = "#FF4040")
#Total Amount of Traffic Stops
total_stops <- sum(violation_count)
total_stops
## [1] 2049896
Based on the data, it indicates that most traffic stops in Montgomery County, Maryland result in Citations, followed by Warnings, meanwhile Electronical/Safety Repair Order (ESERO & SERO) are quite rare which means most Vehicles in Montgomery County are physically safe to be on the road.
#Filtering Only Marked and Unmarked Vehicles
marked_patrol <- tv_data |>
filter(Enforcement_Unit == "A - Marked Patrol")
unmarked_patrol <- tv_data |>
filter(Enforcement_Unit == "B - Unmarked Patrol")
#Counting the stops for both Law Enforcement Vehicles
marked_count <- nrow(marked_patrol)
unmarked_count <- nrow(unmarked_patrol)
patrol_counts <- c(Marked = marked_count, Unmarked = unmarked_count)
patrol_counts
## Marked Unmarked
## 1643400 95355
barplot(patrol_counts / 1000,
main = "Traffic Stops by Law Enforcement Vehicle",
xlab = "Patrol Vehicle",
ylab = "Number of Stops (In Thousands)",
col = c("#0000FF", "#00FFFF"))
Based on the data, it shows that the majority of stops are conducted by officers in marked patrol vehicles while the unmarked vehicles are low, indicating that Montgomery County Police prefers to have a visible enforcement as their main strategy.
library(ggplot2)
# Count the number of stops for each District
district_counts <- table(tv_data$District)
# Sort from highest to lowest and take the top 5
district_sorted <- sort(district_counts, decreasing = TRUE)
top5_districts <- head(district_sorted, 5)
# Convert to data frame for ggplot
district_df <- data.frame(
District = names(top5_districts),
Stops = as.numeric(top5_districts)
)
# Create ggplot bar chart
ggplot(district_df, aes(x = reorder(District, -Stops), y = Stops / 1000)) +
geom_col(fill = "#00B845") +
labs(title = "Traffic Stops by the Top 5 Districts",
x = "District",
y = "Number of Stops (In Thousands)") +
theme_minimal() +
theme(axis.text.x = element_text(angle = 25, hjust = 1))
Based on the frequency of Traffic stops conducted by the 5 districts, Law Enforcement officers tend to be more active and intensive in the Central and Southern areas of Montgomery County, specifically Wheaton and Silver Spring. These two areas likely face higher amount of vehicle flow and better opportunities for law enforcement to conduct a traffic stop, whereas Germantown is the place where Law enforcement is the least intensive.
Conclusion The Data analysis of Traffic Stops and Officer-issued traffic violations in Montgomery County reveals spatial patterns of enforcement. Districts like Wheaton, Silver Spring, and Bethesda shows the highest concentration of traffic stops, indicating that their presence and activity are greatest in these urban areas. In the contrary, northern districts like Germantown and Gaithersburg have the least in terms of their presence and activity, reflecting less traffic and few demand for traffic enforcement.
Overall, the data concludes that population density, urban development, and common routes play a major part in shaping where traffic stops and violations occur. My future analysis could add temporal trends as in the time of day or seasonal patterns, integrating this trend can give way for a deeper understanding of how Law Enforcement will vary their activity over time.
References https://data.montgomerycountymd.gov/Public-Safety/Traffic-Violations/4mse-ku6q/about_data