mapit is an R package designed to assist in mapping tasks. Its prominent tool is the wrapper for the Texas A & M Geoservices that provides R based geocoding. Users can sign up for an API key HERE.
To download the development version of mapit:
Download the zip ball or tar ball, decompress and run R CMD INSTALL
on it, or use the devtools package to install the development version:
# install.packages("devtools")
library(devtools)
install_github("mapit", "trinker")
Note: Windows users need Rtools and devtools to install this way.
Note: Mac users might be required to install the appropriate version XTools from the Apple Developer site in order to install the development version. You may need to register as an Apple developer. An older version of XTools may also be required.
You are welcome to: submit suggestions and bug-reports at: https://github.com/trinker/mapit/issues send a pull request on: https://github.com/trinker/mapit/ * compose a friendly e-mail to: tyler.rinker@gmail.com
This is an R implementation of Jan Philip Matuschek's bounding box article: Finding Points Within a Distance of a Latitude/Longitude Using Bounding Coordinates.
So here we can look at the area within one square mile of the White House:
bounding_box(38.89768, -77.03653, 1)
## min max
## lng -77.06 -77.02
## lat 38.88 38.91
Let's apply it. Here's an example plotting a bounding box around the 2012 Olympic Stadium:
library(ggplot2); library(ggmap)
bb <- bounding_box(lon = -0.016179, lat = 51.538525, 1)
mapImageData <- get_map(location = c(lon = -0.016179, lat = 51.538525),
color = "color",
source = "google",
maptype = "hybrid",
zoom = 14)
ggmap(mapImageData,
extent = "device",
ylab = "Latitude",
xlab = "Longitude") +
geom_rect(aes(xmin = bb[1, 1], xmax = bb[1, 2], ymin = bb[2, 1],
ymax = bb[2, 2]), color="red", fill=NA, size=2) +
geom_point(data=data.frame(lon = -0.016179, lat = 51.538525), size=7,
color="yellow")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.