View source: R/countieswithindrivingdistance.R
countieswithindrivingdistance | R Documentation |
generate a list of counties within a particular driving distance of a location
countieswithindrivingdistance(
centerlocation,
drivingtime = 90,
considerationradius = drivingtime * 1.5,
countymaps = NULL,
fipscodes = NULL,
output = c("all", "nearbydf", "mapdata", "hobsonslist", "map"),
key = Sys.getenv("GOOGLE_MAPS_KEY")
)
centerlocation |
a character string of a location acting as the center from which you want to measure |
drivingtime |
numeric value of time, in minutes, that you want to drive |
considerationradius |
numeric value of distance, in miles, that you want to consider. Limits the number of geocoded counties. Recommended to be much larger than drivingtime, perhaps 50 percent larger, to ensure that all counties are considered. |
countymaps |
a spatialpolygonsdataframe. If NA, data is downloaded and read from the US Census via getcountymaps(). |
fipscodes |
a data frame of fips codes for all counties with bannerized codes added. If NA, data from the tigris package is modified to work |
output |
a character vector describing what output you want. Available options include, "nearbydf", "mapdata", "hobsonslist" and "map" |
key |
a Google Maps user API key |
this function is not vectorized–you cannot pass in vector of centerlocations (or more usefully, a vector of centerlocations and a second vector of driving distances). Use lapply() for this.
if more than one output is selected, a list containing values of each. If only one output is selected, the object itself is returned, without being wrapped in a list. Outputs include:
"nearbydf" a data frame of nearby counties and their distance to centerlocation
"mapdata" a SpaitalPolygonsDataFrame of the nearby counties appropriate for use in a leaflet map
"hobsonslist" a character vector ready to paste into a Hobsons filter
"map" a pre-generated leaflet map
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.