get_acs()是否支持“县细分”地理

时间:2018-12-14 19:39:48

标签: tidycensus

我正在尝试上载“县分区”的数据,作为tidycensus的get_acs()函数中地理选项的一部分。我知道Kyle Walker在他的页面上发布了几种地理选项。 https://walkerke.github.io/tidycensus/articles/basic-usage.html#geography-in-tidycensus

尽管它在州和县一级都可以正常工作,但因为您只需要将County =“ Monmouth”放进去即可。但是我似乎无法使语法在Monmouth县内的城市的城市细分级别正常工作。我在寻找其他tidycensus脚本,但没有找到任何使用县以下级别的地理信息的脚本。

有什么建议吗?

library(tidycensus)
library(tidyverse)
library(sf)

census_api_key("YOUR API KEY GOES HERE")

vars <- c(English = "C16002_002", 
      Spanish = "C16002_003")


language <- get_acs(geography = "county subdivision", 
                state = "NJ",
                county = "Monmouth",
                city = "Red Bank",
                table = "C16001")



rb_language <- get_acs(geography = "tract", 
                   variables = vars,
                   state = "NJ", 
                   county = "Monmouth", 
                   city = "Red Bank"
                   geometry = TRUE, 
                   summary_var = "C16002_001") %>%
  st_transform(26918)

1 个答案:

答案 0 :(得分:0)

我不清楚您是否要获取有关Red Bank县或普查范围内的普查数据。无论哪种情况,您都不能直接在 PowerManager powerManager = (PowerManager) getSystemService(POWER_SERVICE); if (powerManager != null) mWakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, WAKELOCK_TAG); if (mWakeLock != null) mWakeLock.acquire(TimeUnit.HOURS.toMillis(10));中执行,而是可以使用tidycensus获取县内的所有细分或区域,然后进一步过滤结果。

例如,如果您只需要Red Bank县分区的语言数据,则可以执行以下操作:

get_acs()

现在,如果您想在Red Bank内进行普查,则可以获取Monmouth的所有普查道,然后使用library(tidycensus) library(tidyverse) library(sf) library(tigris) vars <- c(English = "C16002_002", Spanish = "C16002_003") # get all subdivisions in monmouth county language_subdiv <- get_acs(geography = "county subdivision", state = "NJ", county = "Monmouth", table = "C16001") # only red bank borough language_subdiv %>% filter(str_detect(NAME, "Red Bank")) #> # A tibble: 38 x 5 #> GEOID NAME variable estimate moe #> <chr> <chr> <chr> <dbl> <dbl> #> 1 34025624… Red Bank borough, Monmouth County, N… C16001_0… 11405 171 #> 2 34025624… Red Bank borough, Monmouth County, N… C16001_0… 7227 451 #> 3 34025624… Red Bank borough, Monmouth County, N… C16001_0… 3789 425 #> 4 34025624… Red Bank borough, Monmouth County, N… C16001_0… 1287 247 #> 5 34025624… Red Bank borough, Monmouth County, N… C16001_0… 2502 435 #> 6 34025624… Red Bank borough, Monmouth County, N… C16001_0… 0 19 #> 7 34025624… Red Bank borough, Monmouth County, N… C16001_0… 0 19 #> 8 34025624… Red Bank borough, Monmouth County, N… C16001_0… 0 19 #> 9 34025624… Red Bank borough, Monmouth County, N… C16001_0… 42 40 #> 10 34025624… Red Bank borough, Monmouth County, N… C16001_0… 0 19 #> # ... with 28 more rows 来获取Red Bank的边界,最后过滤普查道以只得到那些包含在Red Bank边界内。

tigris::places()

reprex package(v0.2.1)于2018-12-24创建