geolocation: Convert the coordinates into formatted addresses

View source: R/geolocation.R

geolocationR Documentation

Convert the coordinates into formatted addresses

Description

Convert the coordinates into formatted addresses

Usage

geolocation(data, longitude, latitude, ncore = 999)

Arguments

data

The dataset, a data.frame or data.table

longitude

The column having longitude

latitude

The column having latitude

ncore

The specific number of CPU cores used (ncore = 999 by default, which indicates the maximum of CPU cores minus 1 were used in parallel computing if your CPU is less than 999 cores)

Value

a data.table which adds the formatted address in the original data set.

Note

The value of "longitude" or "latitude" should be digits in numeric or character format. If not, the function may return empty result for this coordinate automatically.

References

Amap. Official documents for developers: Web Service API. https://lbs.amap.com/api/webservice/summary

Examples

## Not run: 
library(amapR)
options(amap.key = "xxxxxxxxxxxxxxxx")

# Completed data
test <- data.frame(n = 1:5000, lng = c(114.4345,104.0837), lat = c(30.51105, 30.63087))
results <- geolocation(data = test, longitude = "lng", latitude = "lat")

# When the column 'lng' has missing value
test <- data.frame(n = 1:5000, lng = c(114.4345,''), lat = c(30.51105, 30.63087))
results <- geolocation(data = test, longitude = "lng", latitude = "lat")

# When the column 'lng' has special characters
test <- data.frame(n = 1:5000, lng = c(114.4345,'?'), lat = c(30.51105, 30.63087))
results <- geolocation(data = test, longitude = "lng", latitude = "lat")

## End(Not run)


xiaojunlin/amap documentation built on Sept. 29, 2022, 6:35 a.m.