In [3]:
import json, shapely, fiona, os
import seaborn as sns
import pandas as pd
import geopandas as gpd
import networkx as nx
import matplotlib.pyplot as plt
%matplotlib inline
In [6]:
hydro = gpd.read_file('data/HydrologyLine.shp')
hydro.columns = ['layer','length','geometry']
hydro.head(1)
Out[6]:
In [7]:
hydro.plot(figsize=(15,8))
Out[7]:
In [10]:
hydro.crs
Out[10]:
In [11]:
crime = gpd.read_file('data/Target_Crime_Locations.shp')
crime['date'] = crime.REPORTDATE.apply(lambda x: pd.Timestamp(x).date())
crime['year'] = crime.date.apply(lambda x: x.year)
crime.head()
Out[11]:
In [105]:
crimes_on_osmplands = gpd.sjoin(osmp_lands.to_crs(crime.crs),crime) #Spatial join Points to polygons
crimes_on_osmplands.head(2)
Out[105]:
In [108]:
# What crimes happpen on OSMP lands?
crimes_on_osmplands.OFFENSE.value_counts()
Out[108]:
In [18]:
hydro_polies = hydro.buffer(100).to_crs(crime.crs)
In [19]:
crimes_near_water = gpd.sjoin(hydro_polies, crime)
In [82]:
prairie = gpd.read_file('data/prairies.shp')
print("Found {0} colonies".format(len(prairie)))
prairie.head()
Out[82]:
In [93]:
prairie.head().buffer(0.001).plot()
Out[93]:
In [84]:
# What types of crimes are happening near Prairie Dog Colonies?
In [94]:
dfsjoin = gpd.sjoin(prairie.head().buffer(0.001),crime) #Spatial join Points to polygons
# dfpivot = pd.pivot_table(df,index='PolyID',columns='Food',aggfunc={'Food':len})
# dfpivot.columns = dfpivot.columns.droplevel()
dfsjoin.head()
In [ ]:
In [ ]:
In [62]:
buildings = gpd.read_file('data/City_of_Boulder_3D_Building_Roof.shp')
buildings.head()
Out[62]:
In [63]:
buildings.crs
Out[63]:
In [79]:
buildings.iloc[413].geometry
Out[79]:
In [ ]: