In [1]:
import geopandas as gpd
import pandas as pd
import datetime
from cityiq import Config, CityIq
from cityiq.api import Asset, Location
from cityiq.scrape import EventScraper
%matplotlib inline
import matplotlib
import numpy as np
import matplotlib.pyplot as plt
In [2]:
#pkg = mp.jupyter.open_package()
pkg = mp.jupyter.open_source_package()
pkg
Out[2]:
In [3]:
locations = pkg.resource('locations').geoframe()
assets = pkg.resource('assets').geoframe()
locations.head()
Out[3]:
In [4]:
assets.head()
Out[4]:
In [5]:
parking = [ e for e in loc_rec if e.locationType == 'PARKING_ZONE']
In [ ]:
import metapack as mp
pkg = mp.open_package('http://library.metatab.org/sandiegodata.org-geography-2018.csv')
pkg
In [ ]:
tracts = pkg.resource('tract_boundaries').geoframe()
tract_comm = pkg.resource('tract_communities').dataframe()
In [ ]:
t = gpd.GeoDataFrame(
[ (e.locationUid, e.geometry) for e in parking],
columns = ['locationUid','geometry'],
geometry='geometry')
t.crs = tracts.crs
t['geometry'] = t.geometry.centroid
t = gpd.sjoin(t, tracts)
parking_geo = t.merge(tract_comm, on='geoid').drop(columns=['geometry', 'index_right'])
parking_geo.head()
In [ ]:
parking_geo.to_csv('parking_geo.csv')
In [ ]:
com = pkg.resource('sd_community_boundaries').geoframe()
com.plot()
In [ ]:
com = com.to_crs({'init':'epsg:2875'})
com.plot()
In [ ]:
pkg = mp.jupyter.open_package()
roads = pkg.resource('all_roads').geoframe()
sdroads = roads[(roads.lpsjur == 'SD') | (roads.rpsjur == 'SD')].copy()
# Convert to EPSG:2875 ( California zone 6, feet ) so we can make the buffer in feet
sdroads = sdroads.to_crs({'init':'epsg:2875'})
# Buffer the roads to be big enough to enclose the assets
sdroads['geometry'] = sdroads.geometry.apply(lambda g : g.buffer(60,cap_style=1, join_style=2))