ggmap

How to change ggplot legend labels and names with two layers?

若如初见. 提交于 2020-01-01 12:06:49
问题 I am plotting the longitude and latitude coordinates of two different data frames in São Paulo map using ggmap and ggplot packages and want to label manually each legend layer: update: I edited my code below to become fully reproducible (I was using the geocode function instead of get_map). update: I would like to do this without combining the data frames. require(ggmap) sp <- get_map('sao paulo', zoom=11, color='bw') restaurants <- data.frame(lon=c(-46.73147, -46.65389, -46.67610), lat=c(-23

How to change ggplot legend labels and names with two layers?

烂漫一生 提交于 2020-01-01 12:06:08
问题 I am plotting the longitude and latitude coordinates of two different data frames in São Paulo map using ggmap and ggplot packages and want to label manually each legend layer: update: I edited my code below to become fully reproducible (I was using the geocode function instead of get_map). update: I would like to do this without combining the data frames. require(ggmap) sp <- get_map('sao paulo', zoom=11, color='bw') restaurants <- data.frame(lon=c(-46.73147, -46.65389, -46.67610), lat=c(-23

How to change ggplot legend labels and names with two layers?

五迷三道 提交于 2020-01-01 12:06:05
问题 I am plotting the longitude and latitude coordinates of two different data frames in São Paulo map using ggmap and ggplot packages and want to label manually each legend layer: update: I edited my code below to become fully reproducible (I was using the geocode function instead of get_map). update: I would like to do this without combining the data frames. require(ggmap) sp <- get_map('sao paulo', zoom=11, color='bw') restaurants <- data.frame(lon=c(-46.73147, -46.65389, -46.67610), lat=c(-23

How do you rotate the view of a map in ggmap?

帅比萌擦擦* 提交于 2020-01-01 11:54:08
问题 I am looking to rotate the view within the ggmap object from the default of up = true north, to a custom angle of my choosing, but can't find the option within ggmap or get_map. Currently, I have the following code: map1 <- get_map(location=c(-78.872209, 35.050514), zoom = 17, maptype="hybrid") ggmap(map1) Which produces: I would like to rotate the image so that the main street shown (Person Street) is vertically-aligned, like this (which I just rotated manually in a screencapture software):

Geographical heat map of a custom property in R with ggmap

℡╲_俬逩灬. 提交于 2019-12-28 12:12:15
问题 The goal is to build something like http://rentheatmap.com/sanfrancisco.html I got map with ggmap and able to plot points on top of it. library('ggmap') map <- get_map(location=c(lon=20.46667, lat=44.81667), zoom=12, maptype='roadmap', color='bw') positions <- data.frame(lon=rnorm(100, mean=20.46667, sd=0.05), lat=rnorm(100, mean=44.81667, sd=0.05), price=rnorm(10, mean=1000, sd=300)) ggmap(map) + geom_point(data=positions, mapping=aes(lon, lat)) + stat_density2d(data=positions, mapping=aes(x

Justification of multiple legends in ggmap/ggplot2

对着背影说爱祢 提交于 2019-12-28 05:58:38
问题 I am trying to make a map with two legends denoting shape and colour ("Type" and "Org" in the example below), and have the legends inset. I can place the legends, but I would like them to be left justified so that their left edges line up. I can't make them anything other than centred with respect to each other: require(ggplot2) require(ggmap) require(grid) require(mapproj) data <- data.frame(Org=rep(c("ABCDEFG","HIJKLMNOP","QRSTUVWX"),4) , Type=rep(c("Y","Z"),6), Lat=runif(12,48,54.5) , Long

Accessing the internet with knitr

血红的双手。 提交于 2019-12-25 14:26:37
问题 When I run some code to draw a map using ggmap, in Rstudio it runs fine. When I run it using knitr it fails with the following error message:- Error in download.file(url, destfile = destfile, quiet = !messaging, mode = "wb") : cannot open URL 'http://maps.googleapis.com/maps/api/staticmap?center=-40.851253,172.799669&zoom=19&size=%20640x640&scale=%202&maptype=hybrid&sensor=false' Calls: ... eval -> eval -> get_map -> get_googlemap -> download.file In addition: Warning message: In download

Accessing the internet with knitr

狂风中的少年 提交于 2019-12-25 14:26:06
问题 When I run some code to draw a map using ggmap, in Rstudio it runs fine. When I run it using knitr it fails with the following error message:- Error in download.file(url, destfile = destfile, quiet = !messaging, mode = "wb") : cannot open URL 'http://maps.googleapis.com/maps/api/staticmap?center=-40.851253,172.799669&zoom=19&size=%20640x640&scale=%202&maptype=hybrid&sensor=false' Calls: ... eval -> eval -> get_map -> get_googlemap -> download.file In addition: Warning message: In download

For each type of function call to route & geom_leg

时光毁灭记忆、已成空白 提交于 2019-12-25 07:00:36
问题 I'm building up a route with multiple way points using ggmap but the route function doesn't seem to handle way points. I can only get it working with a single from/to. To overcome this I thought of creating the route leg by leg, with a call to route() and geom_leg() for each leg. This isn't ideal due to code repetition. I wonder if it's possible to vectorise this. As an example. Plot Base map For each vector of start/dest call route/geom_leg I've created sample code below. What's the ideal

inconsistent result with INVALID_REQUEST in R ggmap geocode()

你离开我真会死。 提交于 2019-12-24 16:33:42
问题 I'm trying to geocode a list of addresses, and I'm getting some INVALID_REQUEST errors, but I have no idea why. Check this out: # First check if I have permission: geocodeQueryCheck() 2478 geocoding queries remaining. # Enter data d <- c("Via del Tritone 123, 00187 Rome, Italy", "Via dei Capocci 4/5, 00184 Rome, Italy") # Ensure it's a character vector class(d) [1] "character" # Try to geocode library(ggmap) geocode(d) lon lat 1 NA NA 2 12.49324 41.89582 Warning message: geocode failed with