gs_census: gs_census

Description Usage Arguments Examples

Description

This function takes an input landscape, a user-defined land area as an [sf] polygon and returns the total population for that area for a given USA decadal census. The input polygon must be projected and must overlap a USA census area Data are returned for years 2000, or 2010; The default is 2010 For 2000 only the census block group data are available. For 2010 the block level information is available but can take a long time to download for larger polygons. By default the function downloads the block group level for 2010 but you can request the more detailed block data. NOTE: highly recommended that you load the [tigris] package and set [options(tigris_use_cache = TRUE)]

Usage

1
2
gs_census(landscape, year = 2010, spatial = TRUE, level = "block_group",
  api_key = Sys.getenv("CENSUS_API_KEY"))

Arguments

landscape

A spatial polygon of class "sf" (see package [sf]). Note: the object must be projected (i.e. has a coordinate reference system) and must overlap a USA census area.

year

Which census year do you want to use? In format YYYY. Currently the package supports census years 2000, and 2010 (default).

spatial

keep the spatial data? Default = TRUE

level

Choose the census reporting level: "block_group" (default) or "block". NOTE: for year = 2000 only "block_group" level is available; Both levels available for year = 2010.

api_key

Your Census API key. Obtain one at http://api.census.gov/data/key_signup.html; For more information see: https://hrecht.github.io/censusapi/index.html#api-key-setup.

Examples

1
2
3
4
# NOTE: this function requires a Census API key. Obtain one at http://api.census.gov/data/key_signup.html
# For more information see: https://hrecht.github.io/censusapi/index.html#api-key-setup

gs_census(buf20, year = 2010, spatial = TRUE, level = "block_group")

USEPA/goatscape documentation built on May 15, 2019, 1:27 p.m.