krz/omaha-metro-blotter

Archive of police activity and ALPR surveillance across the Omaha metro. alpr archive omaha police surveillance

Commit 38515b5c27

38515b5c270ec9a668ff912878530d7aa180b697

parent: cf90fe362d

Verified · cmc

cmc <hello@cleberg.net> · 2024-01-24 17:01 UTC

fix: restructure project around the dash app

Layout: unified · split

README.md +10
@@ -10,3 +10,13 @@ Data from the Omaha police department, used to analyze and visualize statistics.
10- [ ] Analysis script 10- [ ] Analysis script
11- [~] Visualization script 11- [~] Visualization script
12- [ ] Build API to connect to database? 12- [ ] Build API to connect to database?
13
14## API
15
16For the time being, you can explore the database via API with
17[sqlite2rest](https://github.com/nside/sqlite2rest):
18
19```sh
20pip3 install sqlite2rest
21sqlite2rest serve ./raw_data/ingress.db
22```
scripts/dashboard.py → app.py renamed +3 −2
@@ -15,14 +15,15 @@ df['year'] = df['date'].str[-4:]
15# Configure HTML layout 15# Configure HTML layout
16app = Dash(__name__) 16app = Dash(__name__)
17app.layout = html.Div(children = [ 17app.layout = html.Div(children = [
18 html.H1(children="Omaha Police Invidents", style={"textAlign":"center"}),
18 html.Div([ 19 html.Div([
19 html.H1(children="Omaha Police Invidents", style={"textAlign":"center"}), 20 html.H2(children="Totals per Category and Year", style={"textAlign":"center"}),
20 dcc.Dropdown(df.sort_values("description").description.unique(), "INJURY", id="bar-dropdown"), 21 dcc.Dropdown(df.sort_values("description").description.unique(), "INJURY", id="bar-dropdown"),
21 dcc.Dropdown(df.sort_values("year").year.unique(), "2023", id="bar-year-dropdown"), 22 dcc.Dropdown(df.sort_values("year").year.unique(), "2023", id="bar-year-dropdown"),
22 dcc.Graph(id="bar-graph") 23 dcc.Graph(id="bar-graph")
23 ]), 24 ]),
24 html.Div([ 25 html.Div([
25 html.H2(children="Map Coordinates", style={"textAlign":"center"}), 26 html.H2(children="Map of Incidents per Category and Year", style={"textAlign":"center"}),
26 dcc.Dropdown(df.sort_values("description").description.unique(), "INJURY", id="map-dropdown"), 27 dcc.Dropdown(df.sort_values("description").description.unique(), "INJURY", id="map-dropdown"),
27 dcc.Dropdown(df.sort_values("year").year.unique(), "2023", id="map-year-dropdown"), 28 dcc.Dropdown(df.sort_values("year").year.unique(), "2023", id="map-year-dropdown"),
28 dcc.Graph(id="map-graph") 29 dcc.Graph(id="map-graph")
assets/styles.css added +8
@@ -0,0 +1,8 @@
1body {
2 font-family: -apple-system, BlinkMacSystemFont, avenir next, avenir, segoe ui, helvetica neue, helvetica, Cantarell, Ubuntu, roboto, noto, arial, sans-serif;
3}
4
5#_dash-app-content {
6 max-width: 80vw;
7 margin: 2rem auto;
8}\ No newline at end of file
scripts/load.py → ingest.py renamed +1 −1
@@ -4,7 +4,7 @@ import sqlite3
4import os 4import os
5 5
6# Create the database file 6# Create the database file
7connection = sqlite3.connect('../raw_data/ingress.db') 7connection = sqlite3.connect('./raw_data/ingress.db')
8 8
9# Creating a cursor object to execute SQL queries 9# Creating a cursor object to execute SQL queries
10cursor = connection.cursor() 10cursor = connection.cursor()