Skip to content

Commit

Permalink
Use latest 2020 shapefiles everywhere
Browse files Browse the repository at this point in the history
  • Loading branch information
dgilmanAIDENTIFIED committed Nov 3, 2023
1 parent ac5ece0 commit 569abf2
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 14 deletions.
1 change: 1 addition & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ Changelog
3.2.0
~~~~~
* Relax constraint on jellyfish dependency
* Add the 2020 TIGER URLs to shapefile_urls()


3.1.1
Expand Down
21 changes: 13 additions & 8 deletions us/states.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,21 @@ def shapefile_urls(self) -> Optional[Dict[str, str]]:
if not fips:
return None

base = "https://www2.census.gov/geo/tiger/TIGER2010/"
base = "https://www2.census.gov/geo/tiger/TIGER2020/"
urls = {
"tract": urljoin(base, f"TRACT/2010/tl_2010_{fips}_tract10.zip"),
"cd": urljoin(base, f"CD/111/tl_2010_{fips}_cd111.zip"),
"county": urljoin(base, f"COUNTY/2010/tl_2010_{fips}_county10.zip"),
"state": urljoin(base, f"STATE/2010/tl_2010_{fips}_state10.zip"),
"zcta": urljoin(base, f"ZCTA5/2010/tl_2010_{fips}_zcta510.zip"),
"block": urljoin(base, f"TABBLOCK/2010/tl_2010_{fips}_tabblock10.zip"),
"blockgroup": urljoin(base, f"BG/2010/tl_2010_{fips}_bg10.zip"),
"tract": urljoin(base, f"TRACT/tl_2020_{fips}_tract.zip"),
"block": urljoin(base, f"TABBLOCK/tl_2020_{fips}_tabblock10.zip"),
"blockgroup": urljoin(base, f"BG/tl_2020_{fips}_bg.zip"),
"cd": urljoin(base, f"CD/CD118/tl_2020_{fips}_cd118.zip"),
"county": urljoin(base, "COUNTY/tl_2020_us_county.zip"),
"state": urljoin(base, "STATE/tl_2020_us_state.zip"),
"zcta": urljoin(base, "ZCTA5/tl_2020_us_zcta510.zip"),
}
# unicameral legislatures don't have a lower chamber
if self.abbr not in ["DC", "NE", "AS", "GU", "MP", "VI"]:
urls["lowerchamber"] = urljoin(base, f"SLDL/2022/tl_2020_{fips}_sldl.zip")
if self.abbr not in ["AS", "GU", "MP", "VI"]:
urls["upperchamber"] = urljoin(base, f"SLDU/tl_2020_{fips}_sldu.zip")

return urls

Expand Down
12 changes: 6 additions & 6 deletions us/tests/test_us.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,14 @@ def test_dc():
# shapefiles


@pytest.mark.skip
def test_head():
shapefile_urls = [url for state in us.STATES_AND_TERRITORIES for url in state.shapefile_urls().values()]

@pytest.mark.parametrize("url", shapefile_urls)
def test_shapefiles_head(url):
import requests

for state in us.STATES_AND_TERRITORIES:
for url in state.shapefile_urls().values():
resp = requests.head(url)
assert resp.status_code == 200
resp = requests.head(url)
assert resp.status_code == 200


# counts
Expand Down

0 comments on commit 569abf2

Please sign in to comment.