@@ -23,8 +23,8 @@ def emit(self, record):
23
23
24
24
25
25
class GeoClient (census .core .Client ):
26
- @supported_years (2015 , 2014 , 2013 , 2012 , 2011 , 2010 , 2000 )
27
- def geo_tract (self , fields , geojson_geometry , year = None ):
26
+ @supported_years (2015 , 2014 , 2013 , 2012 , 2011 , 2010 , 2000 , 1990 )
27
+ def geo_tract (self , fields , geojson_geometry , year = None , ** kwargs ):
28
28
if year is None :
29
29
year = self .default_year
30
30
@@ -39,7 +39,7 @@ def geo_tract(self, fields, geojson_geometry, year=None):
39
39
tract_id = tract ['properties' ]['TRACT' ]
40
40
result = self .get (fields ,
41
41
{'for' : 'tract:{}' .format (tract_id ),
42
- 'in' : within }, year )
42
+ 'in' : within }, year , ** kwargs )
43
43
44
44
if result :
45
45
result , = result
@@ -49,7 +49,7 @@ def geo_tract(self, fields, geojson_geometry, year=None):
49
49
yield tract , result
50
50
51
51
@supported_years (2015 , 2014 , 2013 , 2012 , 2011 , 2010 , 2000 )
52
- def geo_blockgroup (self , fields , geojson_geometry , year = None ):
52
+ def geo_blockgroup (self , fields , geojson_geometry , year = None , ** kwargs ):
53
53
if year is None :
54
54
year = self .default_year
55
55
@@ -66,7 +66,7 @@ def geo_blockgroup(self, fields, geojson_geometry, year=None):
66
66
67
67
result = self .get (fields ,
68
68
{'for' : 'block group:{}' .format (block_group_id ),
69
- 'in' : within }, year )
69
+ 'in' : within }, year , ** kwargs )
70
70
71
71
if result :
72
72
result , = result
@@ -76,7 +76,7 @@ def geo_blockgroup(self, fields, geojson_geometry, year=None):
76
76
yield block_group , result
77
77
78
78
79
- def _state_place_area (self , method , fields , state , place , year = None , return_geometry = False ):
79
+ def _state_place_area (self , method , fields , state , place , year = None , return_geometry = False , ** kwargs ):
80
80
if year is None :
81
81
year = self .default_year
82
82
@@ -89,7 +89,7 @@ def _state_place_area(self, method, fields, state, place, year=None, return_geom
89
89
logging .info (place ['properties' ]['NAME' ])
90
90
place_geojson = place ['geometry' ]
91
91
92
- areas = method (fields , place_geojson , year )
92
+ areas = method (fields , place_geojson , year , ** kwargs )
93
93
94
94
features = []
95
95
for i , (feature , result ) in enumerate (areas ):
@@ -106,15 +106,23 @@ def _state_place_area(self, method, fields, state, place, year=None, return_geom
106
106
else :
107
107
return features
108
108
109
- def geo (self , fields , geojson_geometry , year = None , resolution = 'tract' , ignore_missing = False ):
109
+ def geo (self , fields , geojson_geometry , year = None , resolution = 'tract' , ignore_missing = False , ** kwargs ):
110
110
if year is None :
111
111
year = self .default_year
112
-
112
+
113
113
fields = census .core .list_or_str (fields )
114
114
115
- for field in fields :
116
- if self ._field_type (field , year ) is not int :
117
- raise ValueError ('{} is not a variable that can be aggregated your geography' .format (field ))
115
+ as_acs = kwargs .get ('as_acs' , False )
116
+ if as_acs :
117
+ acs_fields = self ._cross (fields )
118
+ for field in acs_fields :
119
+ if self ._field_type (field , year ) is not int :
120
+ raise ValueError ('{} is not a variable that can be aggregated your geography' .format (field ))
121
+ else :
122
+ for field in fields :
123
+ if self ._field_type (field , year ) is not int :
124
+ raise ValueError ('{} is not a variable that can be aggregated your geography' .format (field ))
125
+
118
126
119
127
resolutions = {'tract' : self .geo_tract ,
120
128
'blockgroup' : self .geo_blockgroup }
@@ -124,7 +132,7 @@ def geo(self, fields, geojson_geometry, year=None, resolution='tract', ignore_mi
124
132
except KeyError :
125
133
raise ValueError ('{} is not a valid resolution. Choose one of {}' .format (resolution , resolution .keys ()))
126
134
127
- features = geo_units (fields , geojson_geometry , year = year )
135
+ features = geo_units (fields , geojson_geometry , year = year , ** kwargs )
128
136
129
137
return self ._aggregate (fields , features , year , ignore_missing )
130
138
0 commit comments