whereiam
is a geolocation package for R
.
You can install whereiam
from github
using the devtools
package
require(devtools)
install_github('whereiam', 'drodriguezperez')
whereiam
allow to access to IP based geolocation services from R
. The package also includes access to different services of geocoding and reverse geocoding.
The coordinates can be stored in objects that allows performing calculations such as distance, the half-way point or the bearing of two points.
The external IP can be obtained using
ip = getExternalIP()
The function returns a string with the IP address, if there is no IP address, for example by not being connected to the Internet, will return NULL
. From the IP address it can be obtained geographical location information using:
cord <- getIpCoordinates(ip)
Finally it is possible to get the address by using the geographic coordinates using reverse geocoding services with the function:
info <- reverseGeocoding(cord$latitude, cord$longitude)
It is possible to create new geographic points through introduce the latitude and longitude in the method Coordinate
:
posc <- Coordinate(42.8806027, -8.5445684)
and calculate different values
haversineDistance(cord, posc)
midpoint(cord, posc)
bearing(cord, posc)
GNU General Public License, version 3
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.