【问题标题】:error: unknown/unsupported geography heirarchy, when querying Census tracts错误:查询人口普查区域时,未知/不支持的地理层次结构
【发布时间】:2020-04-15 17:52:43
【问题描述】:

我正在关注 rcensusapiguide 检索数据以检索人口普查区域级数据。这是我的代码。

getCensus(
  name = "acs/acs5/cprofile",
  vintage = 2018,
  key = Sys.getenv("CENSUS_API"),
  vars = c("NAME","CP03_2014_2018_062E"),
  region = "tract:*",
  regionin = "state:12+county:033"
)

但是当我运行这段代码时,我得到了这个错误。

 Error in apiCheck(req) : 
  The Census Bureau returned the following error message:
 error: unknown/unsupported geography heirarchy 

【问题讨论】:

  • 这不是 R 问题;该表在区域级别不存在。来自API docs:“比较概况包括以下地区:国家、所有州(包括哥伦比亚特区和波多黎各)、所有大都市区、所有国会选区、所有县和所有人口超过 5,000 人的地方。”您需要比较表,还是可以从 5 年 ACS 详细表中计算出相同的东西?

标签: r census


【解决方案1】:

这个类似的查询似乎可以提供一个全县范围的数字。

getCensus(
  name = "acs/acs5/cprofile",
  vintage = 2018,
  key = Sys.getenv("CENSUS_API"),
  vars = c("NAME","CP03_2014_2018_062E"),
  region = "county:033",
  # region = "county",  # to get all counties in FL
  # region = "congressional district",  # to get all congressional districts in FL
  regionin = "state:12"
)

#  state county                     NAME CP03_2014_2018_062E
#1    12    033 Escambia County, Florida               49286

还可以使用上面的备用过滤器获取佛罗里达州所有县或国会选区的值。

但不幸的是,我认为不可能获得此特定查询的区域级详细信息。

https://api.census.gov/data/2018/acs/acs5/cprofile.html https://api.census.gov/data/2018/acs/acs5/cprofile/examples.html

从这些链接的帮助来看,该调查似乎在区域级别不可用。以下是来自hereregion 参数列出的地理级别。 (另外,正如@ThetaFC 在 cmets 中指出的那样,可以直接使用 listCensusMetadata(name = "acs/acs5/cprofile", vintage = 2018, type = "geography") 查询此列表。)

【讨论】:

  • 除了问题之外的好答案是相对于vintage=2018。您还可以运行此程序以查看您感兴趣的特定数据集的可用地理位置:listCensusMetadata(name = "acs/acs5/cprofile", vintage = 2018, type = "geography")
  • 谢谢,更新了我到 2018 年的链接——没有注意到网站导航让我进入了 2017 年的页面...
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-05-02
  • 2020-04-17
  • 2015-10-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多