Coder Social home page Coder Social logo

Comments (11)

walkerke avatar walkerke commented on August 25, 2024

Thanks, this will be a quick fix. The issue is with the geometry for those years, so if you set geometry to FALSE it'll work for now. I'll get this taken care of shortly.

from tidycensus.

walkerke avatar walkerke commented on August 25, 2024

This is fixed in 02e3b11. tidycensus uses the cartographic boundary files available from tigris by default, but can fetch the regular TIGER/Line files with the keyword argument cb = FALSE. However, cartographic boundary files do not exist for 2011 and 2012, so tidycensus now uses the TIGER/Line files by default for those years.

from tidycensus.

philiporlando avatar philiporlando commented on August 25, 2024

I'm getting a similar error for Detroit's metro area. Setting cb = F returns geometries without error, but I'm confused as to why we're still seeing this error for the default year?

dma <- get_acs(
  geography = 'block group'
  ,state = 'MI'
  ,county = c('Oakland', 'Macomb', 'Wayne')
  ,variables = c('B22010_001E','B22010_002E')
  ,geometry = T
  ,output = 'wide'
  ,cb = T # throws an error if TRUE!
)
Getting data from the 2013-2017 5-year ACS
Downloading feature geometry from the Census website.  To cache shapefiles for use in future sessions, set `options(tigris_use_cache = TRUE)`.
Getting data from the 2013-2017 5-year ACS
Downloading feature geometry from the Census website.  To cache shapefiles for use in future sessions, set `options(tigris_use_cache = TRUE)`.
Using FIPS code '26' for state 'MI'
Using FIPS code '125' for 'Oakland County'
Cannot open layer cb_2017_26_bg_500k
Error in CPL_read_ogr(dsn, layer, query, as.character(options), quiet,  : 
  Opening layer failed.
In addition: Warning message:
In unzip(file_loc, exdir = tmp) : error 1 in extracting from zip file

Setting cb = F is working for me.

dma <- get_acs(
  geography = 'block group'
  ,state = 'MI'
  ,county = c('Oakland', 'Macomb', 'Wayne')
  ,variables = c('B22010_001E','B22010_002E')
  ,geometry = T
  ,output = 'wide'
  ,cb = F # throws an error if TRUE!
)
Getting data from the 2013-2017 5-year ACS
Downloading feature geometry from the Census website.  To cache shapefiles for use in future sessions, set `options(tigris_use_cache = TRUE)`.
Getting data from the 2013-2017 5-year ACS
Downloading feature geometry from the Census website.  To cache shapefiles for use in future sessions, set `options(tigris_use_cache = TRUE)`.
Using FIPS code '26' for state 'MI'
Using FIPS code '125' for 'Oakland County'
Getting data from the 2013-2017 5-year ACS
Downloading feature geometry from the Census website.  To cache shapefiles for use in future sessions, set `options(tigris_use_cache = TRUE)`.
Using FIPS code '26' for state 'MI'
Using FIPS code '099' for 'Macomb County'
Getting data from the 2013-2017 5-year ACS
Downloading feature geometry from the Census website.  To cache shapefiles for use in future sessions, set `options(tigris_use_cache = TRUE)`.
Using FIPS code '26' for state 'MI'
Using FIPS code '163' for 'Wayne County'

from tidycensus.

walkerke avatar walkerke commented on August 25, 2024

@philiporlando thanks for bringing this up. I've also been experiencing similar behavior intermittently, though I just ran your problem code successfully.

Specifically, connections to the Census shapefiles via httr GET requests (which is used deep under the hood here) have been known to occasionally fail. I've generally noticed these errors when R is used in a server environment - both on Windows and Linux. I've pinged Census about this, but the error has been tough to isolate as they've had to dig through server logs and the problem generally goes away.

Give it another try and hopefully it'll work as it did for me. If not I'll touch base with Census again.

from tidycensus.

janemumei avatar janemumei commented on August 25, 2024

I've been getting this error as well, even on the latest version of R (3.5.1), the ACS 5-year published in 2010, 2011, 2012, 2013, and 2014.

> get_acs(geography = "place",
          state     = "NY",
          variables = c("B01003_001E"),
          year = 2013,
          survey = "acs5",
          geometry = FALSE)
Getting data from the 2009-2013 5-year ACS
Using FIPS code '36' for state 'NY'
Client error Not Found Client error: (404) Not Found
Error in as.character(x) : 
  cannot coerce type 'closure' to vector of type 'character'

from tidycensus.

mfherman avatar mfherman commented on August 25, 2024

Hi @jonoyuan, I just ran this code succesfully. It could be that Census API was experiencing problems or your internet connectivity was spotty when you tried to run it.

library(tidycensus)

get_acs(geography = "place",
        state     = "NY",
        variables = c("B01003_001E"),
        year = 2013,
        survey = "acs5",
        geometry = FALSE)
#> Getting data from the 2009-2013 5-year ACS
#> # A tibble: 1,190 x 5
#>    GEOID   NAME                       variable   estimate   moe
#>    <chr>   <chr>                      <chr>         <dbl> <dbl>
#>  1 3600155 Accord CDP, New York       B01003_001      873   487
#>  2 3600199 Adams village, New York    B01003_001     1769   277
#>  3 3600232 Adams Center CDP, New York B01003_001     2286   383
#>  4 3600276 Addison village, New York  B01003_001     1840   154
#>  5 3600342 Afton village, New York    B01003_001     1048   184
#>  6 3600408 Airmont village, New York  B01003_001     8692    34
#>  7 3600441 Akron village, New York    B01003_001     2862    18
#>  8 3601000 Albany city, New York      B01003_001    98142    70
#>  9 3601011 Albertson CDP, New York    B01003_001     5260   481
#> 10 3601033 Albion village, New York   B01003_001     5595   285
#> # ... with 1,180 more rows

Created on 2019-04-24 by the reprex package (v0.2.1)

from tidycensus.

jefunes avatar jefunes commented on August 25, 2024

I am trying to retrieve some data from ACS but I keep getting error just for specific tables, see below
life_phy_ssc_var <- c("C24010_010"," C24010_046")
life_phy_ssc_DC <- get_acs(geography = "County", variables = life_phy_ssc_var, state="DC", year=2018)
Getting data from the 2014-2018 5-year ACS
Using FIPS code '11' for state 'DC'
No encoding supplied: defaulting to UTF-8.
Error: Your API call has errors. The API message returned is .

from tidycensus.

jefunes avatar jefunes commented on August 25, 2024

the for census tract
life_phy_ssc_var <- c("C24010_010"," C24010_046")
life_phy_ssc <- get_acs(geography = "tract", variables = life_phy_ssc_var, state="DC", geometry = TRUE, year=2018)

Getting data from the 2014-2018 5-year ACS
Downloading feature geometry from the Census website. To cache shapefiles for use in future sessions, set options(tigris_use_cache = TRUE).
Using FIPS code '11' for state 'DC'
No encoding supplied: defaulting to UTF-8.
Error: Your API call has errors. The API message returned is .

from tidycensus.

walkerke avatar walkerke commented on August 25, 2024

@jefunes your code works fine for me once the space is removed prior to the second variable (you're sending the space to the API in the variable name which it is not understanding).

That said I was unable to reproduce your first error. Could you make sure all of your packages are updated? If that does not solve it, could you paste the results of your sessionInfo() here?

from tidycensus.

jefunes avatar jefunes commented on August 25, 2024

space made a difference

from tidycensus.

jefunes avatar jefunes commented on August 25, 2024

thanks!

from tidycensus.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.