Learn R Programming

WikidataR (version 2.3.3)

get_geo_box: Get geographic entities based on a bounding box

Description

get_geo_box retrieves all geographic entities in Wikidata that fall between a bounding box between two existing items with geographic attributes (usually cities).

Usage

get_geo_box(
  first_city_code,
  first_corner,
  second_city_code,
  second_corner,
  language = "en",
  ...
)

Arguments

first_city_code

a Wikidata item, or series of items, to use for one corner of the bounding box.

first_corner

the direction of first_city_code relative to city (eg "NorthWest", "SouthEast").

second_city_code

a Wikidata item, or series of items, to use for one corner of the bounding box.

second_corner

the direction of second_city_code relative to city (eg "NorthWest", "SouthEast").

language

the two-letter language code to use for the name of the item. "en" by default.

\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_entity for using an unrestricted search or simple radius, rather than a bounding box.

Examples

Run this code
# NOT RUN {
# Simple bounding box
# }
# NOT RUN {
bruges_box <- get_geo_box("Q12988", "NorthEast", "Q184287", "SouthWest")
# }
# NOT RUN {
# Custom language
# }
# NOT RUN {
bruges_box_fr <- get_geo_box("Q12988", "NorthEast", "Q184287", "SouthWest",
                                        language = "fr")
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab