File size: 1,375 Bytes
22b146c
 
 
 
faeaa09
ba6c427
0911cdf
 
819f9ab
faeaa09
eb60c7b
faeaa09
5d6e075
4c15380
eb60c7b
71e2c2b
faeaa09
687f780
a84198e
8c8795c
a84198e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import pydeck as pdk
import streamlit as st
import pandas as pd

st.set_page_config(layout="wide")
st.title("Visualising New York City crime data from 2006 - 2016.")
st.write("This is a visualisation of crimes reported to the New York City Police Department between 2006 to 2016.")
st.write("Locations with longer columns imply higher crime reports.")
st.write("Data: [NYC crime dataset](https://data.world/data-society/nyc-crime-data) from [data society](https://data.world/data-society).")

@st.experimental_memo()
def load_data():
    df = pd.read_csv("https://raw.githubusercontent.com/OOlajide/nyc_crime_dataset/main/nyc_crimes.csv")
    return df

df = load_data()
    
with st.spinner(text="Loading map... please wait for a few seconds"):
    st.pydeck_chart(pdk.Deck(
         map_style="mapbox://styles/mapbox/outdoors-v11",
         initial_view_state=pdk.ViewState(
             latitude=40.95,
             longitude=-74.0,
             zoom=8.28,
             pitch=50,
             bearing=0,
         ),
         layers=[
             pdk.Layer(
                'HexagonLayer',
                data=load_data(),
                get_position='[lng, lat]',
                radius=200,
                elevation_scale=18,
                elevation_range=[0, 3000],
                pickable=False,
                extruded=True,
             ),
         ],
     ))