Analysis of NJDOT traffic crash data.
- Crashes per Month (Statewide)
- Crashes per {County, Month}
- Crashes per Year (Statewide)
- Crashes per {County, Year}
- Crash-Type Percentages
I've only done a very quick first pass at cleaning and plotting the data here, so take these with a grain of salt.
There is a marked decrease in "injury" and "property damage" crashes since the onset of COVID (≈March 2020), but fatal crashes are roughly flat:
rawdata.py
is a CLI for downloading+caching .zip
s, extracting .txt
s, cleaning+converting to .pqt
(Parquet).
./rawdata.py --help
# Usage: rawdata.py [OPTIONS] COMMAND [ARGS]...
#
# Options:
# --help Show this message and exit.
#
# Commands:
# check-nj-agg For one or more years, verify the `NewJersey` file is a
# concatenation of the county-specific files
# parse-fields-pdf Parse fields+lengths from one of the `*CrashTable.pdf`s,
# using Tabula
# pqt Convert 1 or more unzipped {year, county} `.txt` files to
# `.pqt`s, with some dtypes and cleanup
# txt Convert 1 or more {year, county} .zip files (convert each
# .zip to a single .txt)
# zip Download 1 or more {year, county} .zip file(s)
./rawdata.py zip -r NewJersey # download statewide-aggregated `.zip`s for [2001,2020] x {Accidents,Drivers,Occupants,Pedestrians,Vehicles}
./rawdata.py txt -r NewJersey # Extract each `.zip` (to a single `.txt`)
./rawdata.py pqt -r NewJersey # Clean (parse dates, assign some dtypes) + convert to Parquet
- crash-plots.ipynb: load all crashes, generate plots above
njdot compute pqt -f
njdot compute db -f
cmym.ipynb: generate cmymc.db containing several {county, muni, year, month} aggregation tables.
The fatal crash stats here also seem to differ from NJSP's data (see the root of this repository) by ≈10%.
- Driver by Musmellow from Noun Project (CC BY 3.0)
- Passenger by Luiz Carvalho from Noun Project (CC BY 3.0)
- Pedestrian by Adrien Coquet from Noun Project (CC BY 3.0)
- Bicycle by Adrien Coquet from Noun Project (CC BY 3.0)
- Car by Nur syifa fauziah from Noun Project (CC BY 3.0)
- Person by Rini Bahtiar from Noun Project (CC BY 3.0)
TODO: add to www pages