osm_get_points_gps {osmapiR}R Documentation

Get GPS Points

Description

Use this to retrieve the GPS track points that are inside a given bounding box (formatted in a GPX format).

Usage

osm_get_points_gps(bbox, page_number = 0, format = c("R", "gpx"))

Arguments

bbox

Coordinates for the area to retrieve the notes from (⁠left,bottom,right,top⁠). Floating point numbers in degrees, expressing a valid bounding box. The maximal width (right - left) and height (top - bottom) of the bounding box is 0.25 degree.

page_number

Specifies which groups of 5,000 points, or page, to return. The API call does not return more than 5,000 points at a time. In order to retrieve all of the points for a bounding box, set page_number = -1. When this parameter is 0 (zero), the command returns the first 5,000 points; when it is 1, the command returns points 5,001–10,000, etc. A vector is also valid (e.g. 0:2 to get the first 3 pages).

format

Format of the output. Can be "R" (default) or "gpx".

Value

If format = "R", returns a list of data frames with the points for each trace. For public traces, the data frame include the attributes name, desc and url.

format = "gpx"

Returns a xml2::xml_document with the following format:

<?xml version="1.0" encoding="UTF-8"?>
<gpx version="1.0" creator="OpenStreetMap.org" xmlns="http://www.topografix.com/GPX/1/0">
	<trk>
		<name>20190626.gpx</name>
		<desc>Footpaths near Blackweir Pond, Epping Forest</desc>
		<url>https://api.openstreetmap.org/user/John%20Leeming/traces/3031013</url>
		<trkseg>
			<trkpt lat="51.6616100" lon="0.0534560">
				<time>2019-06-26T14:27:58Z</time>
			</trkpt>
			...
		</trkseg>
		...
	</trk>
	...
</gpx>

Note

In violation of the GPX standard when downloading public GPX traces through the API, all waypoints of non-trackable traces are randomized (or rather sorted by lat/lon) and delivered as one trackSegment for privacy reasons. Trackable traces are delivered, sorted by descending upload time, before the waypoints of non-trackable traces.

Private traces without name, desc and url can be separated in different items in the result if they get split due to server pagination. Public traces are united using matching URL.

See Also

Other get GPS' functions: osm_get_data_gpx(), osm_get_gpx_metadata(), osm_list_gpxs()

Examples

pts_gps <- osm_get_points_gps(bbox = c(-0.3667545, 40.2153246, -0.3354263, 40.2364915))
## bbox as a character value also works(bbox = "-0.3667545,40.2153246,-0.3354263,40.2364915").
pts_gps

## get attributes
lapply(pts_gps, function(x) attributes(x)[c("name", "desc", "url")])

[Package osmapiR version 0.1.0 Index]