Skip to content

Commit

Permalink
Merge pull request #155 from GeoDaCenter/update-herop-ids
Browse files Browse the repository at this point in the history
remove year suffix from HEROP_ID
  • Loading branch information
mradamcox authored Mar 26, 2024
2 parents 65da78b + 15372c6 commit 6d1eeb6
Show file tree
Hide file tree
Showing 25 changed files with 399,275 additions and 399,278 deletions.
4 changes: 1 addition & 3 deletions code/SpatialIds/add_csv_herop_ids.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,6 @@

rows = []
new_geoid_field = 'HEROP_ID'
# for the "latest" CSVs the year is 2018, for all older ones it's 2010
year_suffix = "2018" if "Latest" in str(path) else "2010"
with open(path, "r") as r:
reader = csv.DictReader(r)

Expand All @@ -82,7 +80,7 @@

for r in reader:
str_geoid = str(r[f_lookup[path.name]]).zfill(sl_lookup[geo]['id_length'])
new_geoid = f"{sl_lookup[geo]['code']}US{str_geoid}-{year_suffix}"
new_geoid = f"{sl_lookup[geo]['code']}US{str_geoid}"
r[new_geoid_field] = new_geoid
rows.append(r)

Expand Down
25 changes: 12 additions & 13 deletions code/SpatialIds/add_shp_herop_ids.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@
"county/counties2018.shp": "GEOID",
"tract/tracts2018.shp": "GEOID",
"zcta/zctas2018.shp": "GEOID10",
"tl_2010_state/states2010.shp": "STATEFP",
"tl_2010_county/counties2010.shp": "GEOID",
"tl_2010_tract/tracts2010.shp": "GEOID",
"state/states2010.shp": "STATEFP",
"county/counties2010.shp": "GEOID",
"tract/tracts2010.shp": "GEOID",
}

new_suffix = "bq"
Expand All @@ -68,11 +68,6 @@
raise Exception("unexpected input shapefile")

out_path = out_dir / Path(path).name
year = ''
if '2010' in str(out_path):
year = '2010'
if '2018' in str(out_path):
year = '2018'
with fiona.open(shp_path) as src:
dst_schema = src.schema
dst_schema['properties']['HEROP_ID'] = 'str'
Expand All @@ -86,9 +81,13 @@
) as dst:
for feat in src:
geo_id = str(feat.properties[f_lookup[path]]).zfill(sl['id_length'])
herop_id = f"{sl['code']}US{geo_id}-{year}"
props = Properties.from_dict(
**feat.properties,
HEROP_ID=herop_id,
)
herop_id = f"{sl['code']}US{geo_id}"
if "HEROP_ID" in feat.properties:
feat.properties['HEROP_ID'] = herop_id
props = feat.properties
else:
props = Properties.from_dict(
**feat.properties,
HEROP_ID=herop_id,
)
dst.write(Feature(geometry=feat.geometry, properties=props))
6,286 changes: 3,143 additions & 3,143 deletions data_final/full_tables/C_1980.csv

Large diffs are not rendered by default.

6,286 changes: 3,143 additions & 3,143 deletions data_final/full_tables/C_1990.csv

Large diffs are not rendered by default.

6,286 changes: 3,143 additions & 3,143 deletions data_final/full_tables/C_2000.csv

Large diffs are not rendered by default.

6,442 changes: 3,221 additions & 3,221 deletions data_final/full_tables/C_2010.csv

Large diffs are not rendered by default.

6,284 changes: 3,142 additions & 3,142 deletions data_final/full_tables/C_Latest.csv

Large diffs are not rendered by default.

102 changes: 51 additions & 51 deletions data_final/full_tables/S_1980.csv

Large diffs are not rendered by default.

102 changes: 51 additions & 51 deletions data_final/full_tables/S_1990.csv

Large diffs are not rendered by default.

102 changes: 51 additions & 51 deletions data_final/full_tables/S_2000.csv

Large diffs are not rendered by default.

104 changes: 52 additions & 52 deletions data_final/full_tables/S_2010.csv

Large diffs are not rendered by default.

102 changes: 51 additions & 51 deletions data_final/full_tables/S_Latest.csv

Large diffs are not rendered by default.

118,374 changes: 59,187 additions & 59,187 deletions data_final/full_tables/T_1980.csv

Large diffs are not rendered by default.

145,386 changes: 72,693 additions & 72,693 deletions data_final/full_tables/T_1990.csv

Large diffs are not rendered by default.

145,386 changes: 72,693 additions & 72,693 deletions data_final/full_tables/T_2000.csv

Large diffs are not rendered by default.

Loading

0 comments on commit 6d1eeb6

Please sign in to comment.