Learn R Programming

ohsome (version 0.2.2)

ohsome_boundary: Create an ohsome_boundary object

Description

Creates an ohsome_boundary object from various classes of input geometries. The ohsome_boundary object is used to set the bpolys, bboxes or bcircles parameter of an ohsome_query object.

Usage

ohsome_boundary(boundary, ...)

# S3 method for ohsome_boundary ohsome_boundary(boundary, ...)

# S3 method for character ohsome_boundary(boundary, ...)

# S3 method for sf ohsome_boundary(boundary, digits = 6, ...)

# S3 method for sfc ohsome_boundary(boundary, ...)

# S3 method for sfg ohsome_boundary(boundary, ...)

# S3 method for bbox ohsome_boundary(boundary, ...)

# S3 method for matrix ohsome_boundary(boundary, ...)

# S3 method for list ohsome_boundary(boundary, ...)

Value

An ohsome_boundary object which contains the following elements:

  • boundary: the boundary in textual format

  • type of the boundary (bpolys, bcircles, or bboxes).

Arguments

boundary

Bounding geometries specified by WGS84 coordinates in the order lon,lat. The geometries of sf are transformed to WGS84 if the CRS of the object is known. The following classes are supported:

  • sf with (MULTI)POLYGON geometries

  • sfc with (MULTI)POLYGON geometries

  • sfg with (MULTI)POLYGON geometries and WGS 84 coordinates

  • bbox created with sf::st_bbox() or tmaptools::bb()

  • matrix created with sp::bbox() or osmdata::getbb()

  • character providing textual definitions of bounding polygons, boxes or circles as allowed by the ohsome API (see ohsome API - Boundaries ):

    • bboxes: WGS84 coordinates in the following format: "id1:lon1,lat1,lon2,lat2|id2:lon1,lat1,lon2,lat2|..." OR "lon1,lat1,lon2,lat2|lon1,lat1,lon2,lat2|..."

    • bcircles: WGS84 coordinates + radius in meter in the following format: "id1:lon,lat,r|id2:lon,lat,r|..." OR "lon,lat,r|lon,lat,r|..."

    • bpolys: WGS84 coordinates given as a list of coordinate pairs (as for bboxes) or GeoJSON FeatureCollection. The first point has to be the same as the last point and MultiPolygons are only supported in GeoJSON.

  • list of bbox, matrix or character. Bounding geometry types of all list elements must be the same. Does not work with GeoJSON FeatureCollections.

...

Additional arguments other than digits are ignored.

digits

integer; number of decimal places of coordinates in the resulting GeoJSON when converting sf to GeoJSON (defaults to 6).

Examples

Run this code
# Defintion of a bounding circle (lon,lat,radius in meters)
ohsome_boundary("8.6528,49.3683,1000") 

# Definition of two named bounding circles
ohsome_boundary("Circle 1:8.6528,49.3683,1000|Circle 2:8.7294,49.4376,1000")

# Definition of two named bounding circles with a character vector
ohsome_boundary(c("Circle 1:8.6528,49.3683,1000", "Circle 2:8.7294,49.4376,1000"))

# Use franconia from the mapview package as bounding polygons
# \donttest{
ohsome_boundary(mapview::franconia, digits = 4)
# }
 
# Use the bounding box of franconia
# \donttest{
ohsome_boundary(sf::st_bbox(mapview::franconia))
# }

# Get bounding box of the city of Berlin from OSM
if (FALSE) {
ohsome_boundary(osmdata::getbb("Berlin"))
}
 
# Use a list of two bounding boxes
if (FALSE) {
ohsome_boundary(list(osmdata::getbb("Berlin"), sf::st_bbox(mapview::franconia)))
}

Run the code above in your browser using DataLab