March 2016

Getting Data

The data is updated daily.


Direct link to the data:

You really want the first two below, since it contains each raw event.

https://storage.googleapis.com/montco-stats/tz.csv
https://storage.googleapis.com/montco-stats/tzr.csv
https://storage.googleapis.com/montco-stats/pivotTrafficVehicleAccident.csv
https://storage.googleapis.com/montco-stats/pivotEmsVehicleAccident.csv

Here's a quick snapshot of what tzr.csv looks like, downloaded, then, opened in Excel.

Screenshot 2016-02-12 14.20.57


The fields are as follows:
lat: Latitude
from Google maps, based on the address in the description.
png: Longitude same
as above, based on the address
desc: Is the exact description
as it was delivered through Montco Active Alert.
zip: Calculated
from Google, when possible.
two: The township
or boro
add: Just the address
e: This field
is always 1…used for counting
rlat: Is latitude
with jitter. Not, sometimes Montco gives the exact same address - difficult to plot
ring: This
is longitude with some jitter (randomness)


Getting the data in python

#!/usr/bin/env python

import requests
import pandas as pd
import io
import datetime

# Read in the data
def readTZ():
url=
"https://storage.googleapis.com/montco-stats/tz.csv"
d=requests.get(url).content
d=pd.read_csv(io.StringIO(d.decode(
'utf-8')),
header=
0,names=['lat', 'lng','desc','zip','title','timeStamp','twp','e'],
dtype={
'lat':str,'lng':str,'desc':str,'zip':str,
'title':str,'timeStamp':datetime.datetime,'twp':str,'e':int})
d=pd.DataFrame(d)
return d

d=readTZ()


Getting the data in R project

urlLink="https://storage.googleapis.com/montco-stats/tzr.csv"
d=read.csv(url(urlLink),header=TRUE,stringsAsFactors=FALSE)
wd<-function(x)
as.POSIXct(strptime(x, '%Y-%m-%d %H:%M:%S',tz='EST'))
d$mdate=wd(d$timeStamp)