In [ ]:


In [1]:
# A very laborious way to get the areas of the cities in San Diego County

# First, get the census records for places, which has far more than we need. 
from rowgenerators import parse_app_url
u = parse_app_url('census://2016/5/05000US06073/place/B17001')
places = u.geo_url.geoframe()

# Then merge spatially join to cities. 
import metapack as mp
pkg = mp.open_package('http://library.metatab.org/sandiegodata.org-communities-2018-7.csv')
cc = pkg.resource('cities_communities').geoframe()

cc.crs =  places.crs

t = gpd.sjoin(places, cc)

t[t['type'] == 'city'][['name_left', 'aland']].drop_duplicates().sort_values('name_left')

# Then, these values are manually copies into the data/cities.csv file.


---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-1-209300bc36ac> in <module>
     13 cc.crs =  places.crs
     14 
---> 15 t = gpd.sjoin(places, cc)
     16 
     17 t[t['type'] == 'city'][['name_left', 'aland']].drop_duplicates().sort_values('name_left')

NameError: name 'gpd' is not defined

In [ ]: