| get_location | R Documentation |
Filter by name or id or use a spatial filter based on an sf object or geocoded street address. Optionally you can use an index list to match the type to a named list of URLs or sf objects.
get_location(
type,
name = NULL,
name_col = "name",
id = NULL,
id_col = "id",
location = NULL,
index = NULL,
union = FALSE,
crs = getOption("overedge.crs"),
label = NULL,
class = "sf",
...
)
type |
Type of location to return. Type can be an sf object, e.g. a data frame with multiple neighborhoods or a character string that can be passed to get_location_data. If index is provided, character can also be a character string to match the name of a list. |
name |
Location name to return. |
name_col |
Column name in type with name values, Default: 'name' Required if name provided. |
id |
Location id to return. id is coerced to character or numeric to match the class of the id_col for type. |
id_col |
Column name in type with id values, Default: 'id'. Required if id is provided. |
location |
An address, bounding box ( |
index |
Optional list used to match type to data, Default: |
union |
If |
crs |
Coordinate reference system to return; defaults to NULL which returns data using the same coordinate reference system as the provided type of location. |
label |
Label optionally added to "label" column; must be a length 1 or
match the number of rows returned based on the other parameters. If |
class |
Class of object to return; defaults to "sf". |
... |
Additional parameters passed to get_location_data if type
is character and index is |
A simple feature object from data provided to type.
nc <- read_sf_path(system.file("shape/nc.shp", package = "sf"))
# get_location works with a type sf object and name and id values
get_location(type = nc, name = "Warren", name_col = "NAME")
get_location(type = nc, id = 37185, id_col = "FIPSNO")
# type can also be a file path
get_location(
type = system.file("shape/nc.shp", package = "sf"),
name = "Hertford",
name_col = "NAME"
)
# type can also be an index name (if a named list of data sets, url values, or
# path values is passed to index)
get_location(
type = "smaller",
name = "Hertford",
name_col = "NAME",
index = list(
"smaller" = dplyr::filter(nc, AREA <= 0.10),
"larger" = dplyr::filter(nc, AREA > 0.15)
)
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.