Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update __init__.py #8

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
'state': 'States',
'unsd': 'Unified School Districts',
'zcta5': '5-Digit Zip Code Tabulation Area',
'tract': 'Census Tracts'
}

GEO_TYPES_LIST = sorted([
Expand Down
25 changes: 25 additions & 0 deletions helpers/csv_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def get_fields_for_csv(include_polygon=False):
'ALAND',
'INTPTLAT',
'INTPTLON',
'TRACTCE',
]
if include_polygon:
field_list.append('GEOMETRY')
Expand Down Expand Up @@ -77,6 +78,7 @@ def make_basic_row(feature, item, geo_type, item_options):
'ALAND': feature.GetField("ALAND"),
'INTPTLAT': feature.GetField("INTPTLAT"),
'INTPTLON': feature.GetField("INTPTLON"),
'TRACTCE' : None,
})
if item_options['include_polygon']:
_geom = feature.GetGeometryRef()
Expand Down Expand Up @@ -270,3 +272,26 @@ def make_zcta5_row(feature, item, geo_type, item_options):
})
return item


def make_tract_row(feature, item, item_options):
# Tracts
_sumlev = '140'
_namelsad = feature.GetField("NAMELSAD")
_name = feature.GetField("NAME")
item.update({
'FULL_GEOID': _build_full_geoid(_sumlev, item_options),
'SUMLEV': _sumlev,
'NAMELSAD': _namelsad,
'TRACTCE' : feature.GetField("TRACTCE"),
'STATEFP' : feature.GetField("STATEFP"),
'COUNTYFP' : feature.GetField("COUNTYFP"),
'ALAND' : feature.GetField("ALAND"),
'INTPTLAT' : feature.GetField("INTPTLAT"),
'INTPTLON' : feature.GetField("INTPTLON"),
})
if item_options['include_polygon']:
_geom = feature.GetGeometryRef()
item.update({
'GEOMETRY': str(_geom),
})
return item