A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/michaeldorman/mapsapi/ below:

michaeldorman/mapsapi: 'sf'-Compatible Interface to Google Maps APIs

The mapsapi package provides an interface to the Google Maps APIs, currently four of them:

Functions mp_directions, mp_matrix and mp_geocode are used to access the Directions, Matrix and Geocode APIs, respectively. They return an xml_document object (package xml2) with the response contents.

The fourth function mp_map is used to access the Maps Static API. It returns a stars raster RGB image, which can be used as background in maps.

The CRAN version can be installed with:

install.packages("mapsapi")

The development version can be installed using remotes:

install.packages("remotes")
remotes::install_github("michaeldorman/mapsapi")

Once installed, the package can be loaded with library:

Note: due to new Google Maps API policy, starting from June 2018 the functions require an API key.

The complete documentation can be found at https://michaeldorman.github.io/mapsapi/.

The following code section obtains (and plots) the driving directions from New-York to Los Angeles.

# Get routes (XML document)
doc = mp_directions(
  origin = "New-York",
  destination = "Los Angeles",
  alternatives = TRUE,
  key = key, 
  quiet = TRUE
)

# Extract lines 'sf' layer
r = mp_get_routes(doc)

# Plot
library(maps)
library(sf)
#> Linking to GEOS 3.8.0, GDAL 3.0.4, PROJ 6.3.1
map("state", fill = FALSE, col = "grey")
plot(st_geometry(r), col = c("red", "green", "blue"), add = TRUE)


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4