get_altitude: Get altitude from coordinates

Description Usage Arguments Details Value Examples

Description

This function returns the altitude (elevation) in meters for coordinates.

Usage

1
2
3
get_altitude(.Data, .longitude = NULL, .latitude = NULL,
  .src = c("racemap", "geonames", "google", "openelevation"),
  .geonames.username = "demo", .google.api.key = NULL)

Arguments

.Data

data.table or data.frame with columns latitude and longitude. Either specify the .Data argument or specify .longitude and .latitude.

.longitude

Numeric vector.

.latitude

Numeric vector.

.src

Character value. Which API service to use? One of c("geonames", "mapzen", "google", "openelevation").

.geonames.username

Character value.

.google.api.key

Character value.

Details

Currently different services can be used:

It is recommended to use environment variables to pass secrets like your geonames username or API keys to the function.

Note that some APIs do not return values for ocean areas, e.g. at geonames those values are encoded as -32768.

Value

Numeric vector of altitudes.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
## Not run: 
Data <- data.frame(latitude = 48:50, longitude = 11:13)

# Geonames
get_altitude(Data, .src = "geonames")

# Set your geonames username as environment variable in .Renviron file before.
# get_altitude(Data, .src = "geonames", .geonames.username = Sys.getenv("GEONAMES_USERNAME"))

# Google
# get_altitude(Data, Data, .src = "google", .google.api.key = Sys.getenv("GOOGLE_API_KEY"))

# Racemap
get_altitude(Data, .src = "racemap")

# Open-Elevation
get_altitude(Data, .src = "openelevation")

## End(Not run)

markusdumke/altituder documentation built on May 31, 2019, 1:51 a.m.