Closed MathieuMarauri closed 6 years ago
Hi Mathieu,
Thanks! The typo is now corrected and geom_sf
should work.
The following is a reproducible example (replacing the key
with your Google Maps API key)
library(mapsapi)
library(ggplot2)
# Get routes
key = "GOOGLE API KEY"
doc = mp_directions(
origin = c(34.81127, 31.89277),
destination = c(34.781107, 32.085003),
departure_time = Sys.time(),
alternatives = TRUE,
key = key
)
r = mp_get_routes(doc)
# Plot with 'ggplot2'
ggplot() +
geom_sf(
data = r,
aes(colour = factor(alternative_id))
)
Here is the resulting plot -
Best regards,
Michael
Great, thank you 👍
Hello,
I am trying out your package and I am having fun using it.
I wanted to get the direction from one point to another one and I noticed that when you use
mp_get_routes
to get an sf object from the result ofmp_direction
the geometry column is called geomerty. It is far from a big deal but if you want to then plot it withggplot2
you might get an error depending on the way you callgeom_sf()
.ggplot(data = direction) + geom_sf()
will give an error.Thank you for your package.
Cheers,
Mathieu