walkerke / tidycensus

Load US Census boundary and attribute data as 'tidyverse' and 'sf'-ready data frames in R
https://walker-data.com/tidycensus
Other
639 stars 100 forks source link

Does get_decennial only support the metropolitan statistical area geography for 2010 census? #105

Closed buchmayne closed 6 years ago

buchmayne commented 6 years ago

I am running into a strange issue where I am getting an unsupported geography error in running get_decennial(), Error : Your API call has errors. The API message returned is error: unknown/unsupported geography heirarchy..

Here is my function call: get_decennial(geography = "metropolitan statistical area/micropolitan statistical area", variable = "H013001", year = 2000)

What is puzzling is that the same function call for 2010 doesn't throw an error, and returns the expected data, get_decennial(geography = "metropolitan statistical area/micropolitan statistical area", variable = "H013001", year = 2010).

Similarly, passing in a different geography to the function in 2000 also works (implying the issue isn't with the variable name). get_decennial(geography = "county", variable = "H013001", year = 2000)

On the "basic usage page" in the documentation it lists the "MSA" geography as being supported in get_decennial(), and it obviously is as the function works with the 2010 census.

Has anyone else encountered this problem? I am aware that the census is currently undergoing some changes to their API.

Also wanted to note while I am here, major thanks for creating such an incredible package. Tidycensus has dramatically improved my workflow, and saved me countless hours or brain damage in pulling and reshaping census data!!

(I am using R version 3.5.1 (2018-07-02), have tidycensus_0.8.1 installed, and am running osx Sierra)

walkerke commented 6 years ago

Hi @buchmayne - thanks for the kind words!

Your issue title is correct - metro areas are not supported in the 2000 decennial API, unfortunately. Supported geographies in the API are here: https://api.census.gov/data/2000/sf1/geography.html, and tidycensus can't do blocks or block groups either for 2000 as they are only available by Census tract, which would be quite slow for most queries.

I would recommend NHGIS (http://www.nhgis.org) for this task; it is excellent for historical Census data and allows you to avoid some limitations of the API. It does require data download but there is an R package, ipumsr, with helper functions.