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

tigris::roads() fails for some counties #185

Open
warnes opened this issue Feb 13, 2024 · 0 comments
Open

tigris::roads() fails for some counties #185

warnes opened this issue Feb 13, 2024 · 0 comments

Comments

@warnes
Copy link

warnes commented Feb 13, 2024

tigris::roads returns errors for counties which do not have a road file on the census server. For example

> packageVersion('tigris')
[1] ‘2.1> tigris::roads(state='60', county='030')
Previous download failed.  Re-download attempt 1 of 3...
  |===========================================================================================================================| 100%
Previous download failed.  Re-download attempt 2 of 3...
  |===========================================================================================================================| 100%
Previous download failed.  Re-download attempt 3 of 3...
  |===========================================================================================================================| 100%
Error: Download failed; check your internet connection or the status of the Census Bureau website
                 at http://www2.census.gov/geo/tiger/.

Examining the relevant directory https://www2.census.gov/geo/tiger/TIGER2021/ROADS/ shows that the relevant file tl_2021_60030_roads.zip is not present.

Attempting to download the (nonexistant) file using httr yields:

resp <- httr::GET('https://www2.census.gov/geo/tiger/TIGER2021/ROADS/tl_2021_60030_roads.zip')
> resp
Response [https://www2.census.gov/geo/tiger/TIGER2021/ROADS/tl_2021_60030_roads.zip]
  Date: 2024-02-13 15:15
  Status: 404
  Content-Type: text/html
  Size: 18.3 kB
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<!--Each page must contain this info, per OMB, update info as neccessary-->
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>U.S. Census Bureau: Page not found</title>
<meta name="DC.title" content="U.S. Census Bureau: Page not found" />
<meta name="DC.description" content="U.S. Census Bureau: Page not found" />
<meta name="description" content="U.S. Census Bureau: Page not found" />
...

Perhaps it would be worthwhile to check the return status of the GET call in tigris:::load_tiger to determine if the download succeeded, and if if failed to present an appropriate (helpful) diagnostic message to the user. Perhaps something extracting and displaying the DC.description meta tag content:

> tigris::roads(state='60', county='030')
Error: Download failed for 'https://www2.census.gov/geo/tiger/TIGER2021/ROADS/tl_2021_60030_roads.zip' : 'U.S. Census Bureau: Page not found'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant