kml_coords: Extract KML coordinates (longitude, latitude or altitude).

Description Usage Arguments Value Note See Also Examples

View source: R/kml_coords.R

Description

Extract KML coordinates (longitude, latitude or altitude).

Usage

1
kml_coords(x, coord, verbose = TRUE)

Arguments

x

A character vector of KML coordinates, of the form "longitude,latitude[,altitude]".

coord

Which coordinate to extract: either 1 (longitude), 2 (latitude) or 3 (altitude). The function also accepts "lon", "lat" and "alt".

verbose

Whether to report invalid coordinates and/or negative altitudes (below sea level); defaults to TRUE. See 'Note'.

Value

A numeric vector.

If coord has been set to return altitude and there are no altitude values in the KML coordinates, the function returns a numeric vector of NA values of the same length as x.

Note

KML coordinates are lon,lat[,alt] tuples.

Invalid coordinates are longitudes outside of [-180, 180] (angular distance in degrees, relative to the Prime Meridian) and latitudes outside of [-90, 90] (angular distance in degrees, relative to the Equator).

Altitude is the distance from the earth's surface, in meters. Depending on the altitude mode used in the KML source, altitude might be computed in absolute terms (relative to sea level), or from the actual ground elevation of a particular location.

See Also

Google Developers. KML Reference: <Camera> Element. https://developers.google.com/kml/documentation/kmlreference#camera

Examples

1
2
3
4
5
6
7
# longitude
kml_coords("11.0,22.0,-99.0", 1)
# latitude
kml_coords("11.0,22.0,-99.0", 2)
# altitude
kml_coords("11.0,22.0,-99.0", "alt")
kml_coords("11.0,22.0,-99.0", "alt", verbose = FALSE)

briatte/tidykml documentation built on May 11, 2017, 5:37 p.m.