krz/omaha-metro-blotter
Archive of police activity and ALPR surveillance across the Omaha metro.
clone: git clone https://gitbay.org/krz/omaha-metro-blotter.git
38515b5c270ec9a668ff912878530d7aa180b697
verified · cmc
author: Christian Cleberg <hello@cleberg.net> · 2024-01-24T17:01:36Z
README.md | 10 ++++++++++ scripts/dashboard.py => app.py | 5 +++-- assets/styles.css | 8 ++++++++ scripts/load.py => ingest.py | 2 +- 4 files changed, 22 insertions(+), 3 deletions(-) @@ -10,3 +10,13 @@ Data from the Omaha police department, used to analyze and visualize statistics. - [ ] Analysis script - [~] Visualization script - [ ] Build API to connect to database? + +## API + +For the time being, you can explore the database via API with +[sqlite2rest](https://github.com/nside/sqlite2rest): + +```sh +pip3 install sqlite2rest +sqlite2rest serve ./raw_data/ingress.db +``` similarity index 89% rename from scripts/dashboard.py rename to app.py @@ -15,14 +15,15 @@ df['year'] = df['date'].str[-4:] # Configure HTML layout app = Dash(__name__) app.layout = html.Div(children = [ + html.H1(children="Omaha Police Invidents", style={"textAlign":"center"}), html.Div([ - html.H1(children="Omaha Police Invidents", style={"textAlign":"center"}), + html.H2(children="Totals per Category and Year", style={"textAlign":"center"}), dcc.Dropdown(df.sort_values("description").description.unique(), "INJURY", id="bar-dropdown"), dcc.Dropdown(df.sort_values("year").year.unique(), "2023", id="bar-year-dropdown"), dcc.Graph(id="bar-graph") ]), html.Div([ - html.H2(children="Map Coordinates", style={"textAlign":"center"}), + html.H2(children="Map of Incidents per Category and Year", style={"textAlign":"center"}), dcc.Dropdown(df.sort_values("description").description.unique(), "INJURY", id="map-dropdown"), dcc.Dropdown(df.sort_values("year").year.unique(), "2023", id="map-year-dropdown"), dcc.Graph(id="map-graph") new file mode 100644 @@ -0,0 +1,8 @@ +body { + font-family: -apple-system, BlinkMacSystemFont, avenir next, avenir, segoe ui, helvetica neue, helvetica, Cantarell, Ubuntu, roboto, noto, arial, sans-serif; +} + +#_dash-app-content { + max-width: 80vw; + margin: 2rem auto; +} \ No newline at end of file similarity index 97% rename from scripts/load.py rename to ingest.py @@ -4,7 +4,7 @@ import sqlite3 import os # Create the database file -connection = sqlite3.connect('../raw_data/ingress.db') +connection = sqlite3.connect('./raw_data/ingress.db') # Creating a cursor object to execute SQL queries cursor = connection.cursor()