hrecht / censusapi

R package to retrieve U.S. Census data and metadata via API
https://www.hrecht.com/censusapi/
169 stars 31 forks source link

New 2010 hierarchy for blocks breaks getCensus example #51

Closed camille-s closed 5 years ago

camille-s commented 5 years ago

I'm not sure if this is related to the API changes already covered in #42 but I just noticed that the required hierarchy for blocks from the 2010 sf1 is now state --> county --> tract --> block, rather than the previous state --> county --> block. As a result, the example in the getCensus docs showing the use of that second hierarchy for 2010 sf1 no longer works; it has to be structured like the example given for the 2000 sf1.

library(censusapi)

# example from getCensus
data_no_tract <- getCensus(name = "dec/sf1", vintage = 2010,
                           vars = c("P001001", "H010001"),
                           region = "block:*", regionin = "state:36+county:027")
#> Error in apiCheck(req): The Census Bureau returned the following error message:
#>  error: unknown/unsupported geography heirarchy

data_with_tract <- getCensus(name = "dec/sf1", vintage = 2010,
                             vars = c("P001001", "H010001"),
                             region = "block:*", regionin = "state:36+county:027+tract:010000")
head(data_with_tract)
#>   state county  tract block P001001 H010001
#> 1    36    027 010000  1000      31      31
#> 2    36    027 010000  1011      17      17
#> 3    36    027 010000  1028      41      41
#> 4    36    027 010000  1001       0       0
#> 5    36    027 010000  1031       0       0
#> 6    36    027 010000  1002       4       4

Appreciate this package!

hrecht commented 5 years ago

Thanks so much for the heads up. This is due to changes on the Census Bureau end (cc @loganpowell). I'll change the example in the next version.

loganpowell commented 5 years ago

Indeed, these changes have adversely impacted a number of important users, including censusapi. We apologize for the breaking change and are working on fixing it as we speak.

hrecht commented 5 years ago

Closed in v0.6.0