WikidataR (version 2.3.3)

get_geo_entity: Retrieve geographic information from Wikidata

Description

get_geo_entity retrieves the item ID, latitude and longitude of any object with geographic data associated with another object with geographic data (example: all the locations around/near/associated with a city).

Usage

get_geo_entity(entity, language = "en", radius = NULL, limit = 100, ...)

Arguments

entity

a Wikidata item (Q...) or series of items, to check for associated geo-tagged items.

language

the two-letter language code to use for the name of the item. "en" by default, because we're imperialist anglocentric westerners.

radius

optionally, a radius (in kilometers) around entity to restrict the search to.

limit

the maximum number of results to return.

\dots

further arguments to pass to httr's GET.

Value

a data.frame of 5 columns:

  • item the Wikidata identifier of each object associated with entity.

  • name the name of the item, if available, in the requested language. If it is not available, NA will be returned instead.

  • latitude the latitude of item

  • longitude the longitude of item

  • entity the entity the item is associated with (necessary for multi-entity queries).

See Also

get_geo_box for using a bounding box rather than an unrestricted search or simple radius.

Examples

Run this code
# NOT RUN {
# All entities
# }
# NOT RUN {
sf_locations <- get_geo_entity("Q62")
# }
# NOT RUN {
# Entities with French, rather than English, names
# }
# NOT RUN {
sf_locations <- get_geo_entity("Q62", language = "fr")
# }
# NOT RUN {
# Entities within 1km
# }
# NOT RUN {
sf_close_locations <- get_geo_entity("Q62", radius = 1)
# }
# NOT RUN {
# Multiple entities
# }
# NOT RUN {
multi_entity <- get_geo_entity(entity = c("Q62", "Q64"))
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab