Package 'wikimapR'

Title: Import Wikimapia Data as Simple Features via API
Description: Download and import of Wikimapia data as 'sf' objects. Wikimapia data is retrieved via the Wikimapia API and converted to `sf` objects retaining all recevied fields.
Authors: Egor Kotov [aut, cre]
Maintainer: Egor Kotov <[email protected]>
License: MIT + file LICENSE
Version: 0.1.2
Built: 2025-01-03 03:43:08 UTC
Source: https://github.com/e-kotov/wikimapR

Help Index


Set Wikimapia API Key

Description

Sets an API key to make it available for all wikimapR functions calls. See details

Usage

set_wikimapia_api_key(api_key)

Arguments

api_key

Wikimapia API key

Details

Use set_wikimapia_api_key to make API keys available for all Wikimapia API calls in a session so you don't have to keep specifying the wm_api_key argument each time.

References

mapdeck https://github.com/SymbolixAU/mapdeck code related to API key handling was used as a template.


Subdivide large bounding box into smaller ones

Description

Subdivide large bounding box into smaller ones.

Usage

subdivide_bbox(
  x,
  bbox_cell_size = 0.045,
  return_bbox_or_sf = "bbox",
  out_crs = 4326
)

Arguments

x

a numeric vector of length four, with xmin, ymin, xmax and ymax values; or a 'bbox' object that is an output of st_bbox. The values must be in WGS 84 (EPSG 4326)

bbox_cell_size

bounding box cell size is in degrees (need to somehow fix that to work with meters across the globe). Default of 0.045 is reasonably large, roughly equivalent to 2845x5010 meters. The grid will be created in WGS84 coordinate reference system and then transformed into CRS set by 'out_crs', which is also WGS84 by default (EPSG:4326).

return_bbox_or_sf

object type to retun. If set to default "bbox", returns objects of type 'bbox', "sf" - returns 'sf polygons' (good for plotting), "both" - returns a list of length 2 with both 'bbox' and 'sf' named accorgingly.

out_crs

EPSG code or proj4 string for the desired coordinate reference system of the output bounding box coordinates. The grid will be created in WGS84 coordinate reference system and then transformed into CRS set by 'out_crs'. Default value is 4326 for WGS84.

Value

an 'sf' object grid with consequtive IDs. Also prints out a message with the number of bounding boxes and the average cell dimensions in meters.


Import 'Wikimapia' Data as Simple Features via API

Description

Download and import of 'Wikimapia' data as 'sf' objects. 'Wikimapia' data are extracted via the 'Wikimapia' API and converted to 'sf' objects retaining all recevied fields.

Author(s)

Egor Kotov [email protected]

See Also

Useful links:


Get Wikimapia Objects by ID

Description

Retrieves Wikimapia objects by ID.

Usage

wm_get_by_id(
  ids,
  language = "en",
  wm_api_key = getOption("wikimapia_api_key", default = "example"),
  data_blocks = "main,geometry,edit,location,attached,photos,comments,translate"
)

Arguments

ids

a numeric or character vector with Wikimapia object IDs to fetch. You can get a list of objects to fetch using wm_get_from_bbox

language

Wikimapia language to retrieve. This is specified language in ISO 639-1 format. Default language is 'en'.

wm_api_key

Your wikimapia API Key. If not specified, the default 'example' key is used, however it is limited to about 1 request per 30 seconds and is for testing purposes only.

data_blocks

The comma-separated blocks of data you want to return: main, geometry, edit, location, attached, photos, comments, translate, similar_places, nearest_places, nearest_comments, nearest_streets, nearest_hotels. Default is "main,geometry,edit,location,attached,photos,comments,translate".

Details

Uses ['place.getbyid'](http://wikimapia.org/api#placegetbyid) Wikimapia API function to retrieve full object details.

Value

'sf' objects with nested details.


Get one Wikimapia object by ID

Description

Retrieves single Wikimapia object by ID.

Usage

wm_get_by_id_single(
  id,
  language = "en",
  wm_api_key = getOption("wikimapia_api_key", default = "example"),
  data_blocks = "main,geometry,edit,location,attached,photos,comments,translate"
)

Arguments

id

a numeric or characted vector of length 1 with Wikimapia object ID to fetch. You can get a list of objects to fetch using wm_get_from_bbox

language

Wikimapia language to retrieve. This is specified language in ISO 639-1 format. Default language is 'en'.

wm_api_key

Your wikimapia API Key. If not specified, the default 'example' key is used, however it is limited to about 1 request per 30 seconds and is for testing purposes only.

data_blocks

The comma-separated blocks of data you want to return: main, geometry, edit, location, attached, photos, comments, translate, similar_places, nearest_places, nearest_comments, nearest_streets, nearest_hotels. Default is "main,geometry,edit,location,attached,photos,comments,translate".

Details

Uses ['place.getbyid'](http://wikimapia.org/api#placegetbyid) Wikimapia API function to retrieve full object details.

Value

'sf' object with nested details.


Get Wikimapia Objects in a Bounding Box

Description

Retrieves objects in the given boundary box either with or without geometry. May also fetch just the metadata.

Usage

wm_get_from_bbox(
  x,
  page = 1,
  n_per_page = 100,
  language = "en",
  category = NULL,
  get_location = TRUE,
  wm_api_key = getOption("wikimapia_api_key", default = "example"),
  meta_only = FALSE
)

Arguments

x

a numeric vector of length 4, with xmin, ymin, xmax and ymax values; or a 'bbox' object that is an output of st_bbox. The values must be in WGS 84 (EPSG 4326)

page

This is page number. 1 is default. There are usually more objects in a bounding box than the limit of 100 objects per page. Therefore you need to specify page other than 1 to get other objects. The returned list object contains number of found features and the required number of pages to retrieve them all.

n_per_page

This is a variable that determines the number of results per page. 100 is default (5 min, 100 max). This is 'count' parameter in Wikimapia terminilogy, but different name is used here so that it does not conflict with the 'dplyr::count()' function.

language

Wikimapia language to retrieve. This is specified language in ISO 639-1 format. Default language is 'en'.

category

This is wikimapia category code: category=17 - Shop, category=203 - School etc. (a detailed list will be published later) or category text query in UTF-8: category=School, category=Church etc. Default is NULL to get all categories.

get_location

Specifies whether to get location (centroid) and polygon geometry. You may want to disable it if you are only using the wm_get_from_bbox to estimate the number of objects to reduce the returned object size.

wm_api_key

Your wikimapia API Key. If not specified, the default 'example' key is used, however it is limited to about 1 request per 30 seconds and is for testing purposes only.

meta_only

only return metadata from the response, do not return feature attributes or geometry.

Details

Currenlty only supports bbox parameter, but not &lon_min, &lat_min, &lon_max, &lat_max and not &x, &y, &z for tiles. 'Box“ endpoint is claimed to be deprecated, but the 'Place.Getbyarea' does not seem to work properly.

Value

If 'meta_only = FALSE' returns a list with data.frame of object attributes (and object geometry if 'get_location = TRUE'). If 'meta_only = TRUE' only returns metadata of the responce: the number of objects in the bounding box ('found'), version, language, current page, current 'n_per_page'. If 'get_location = TRUE' returns a list object with 'sf polygons' with all object attributes, 'sf points' with all object attributes (the centroids), and also the metadata described above.