Skip to content

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

@warnes

Description

@warnes

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'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions