ggmap

Using gg_animate to create a gif

☆樱花仙子☆ 提交于 2019-12-04 10:20:38
Is there a way to implement gg_animate in R to produce a gif. I already have my ggmaps created and saved as PDFs. I would like to create an animation which scrolls through those maps maybe holding on each image for 1 or 2 seconds. Is there a way to do this in R or should I use some sort of gif creator - if so any suggestions? Thanks much Update Jul2018 : gganimate() has undergone a rewrite and is now much improved . The previous API is only available through the archived version and should not be expected to work with the new version. With the new version: library(gapminder) library(gganimate)

Plot geocode: ggmap error

耗尽温柔 提交于 2019-12-04 09:38:15
I want to visualize a dataframe with R and the ggmap package. df: | lon | lat | |-----------|-----------| | 6.585863 | 51.09021 | | 8.682.127 | 50.11092 | | 7.460.367 | 5.152.755 | I created a map with mapImageData <- get_googlemap( + "Germany", + zoom=15 + ) And then wanted to add the geocodes: ggmap(mapImageData) + + geom_point(aes(x=lon, y=lat), data=df, colour="red", size=5) But I get the error: Error: geom_point requires the following missing aesthetics: x, y What am I doing wrong? You have three problems: More than one deicmal point in some values & decimal points probably not at the

Non-square (rectangular) maps in R-ggmap

笑着哭i 提交于 2019-12-04 07:32:37
I need to plot spatial data in a non-square map. I have been using ggmap, and supposedly you can get non squared maps giving low-west-corner and upper-right-corner coordinates. However, actually it seems it doesn't work (reported here and here ). Anyone knows how to get rectangular maps in R/ggmap? If you can live without Google Maps, there are easy, immediate alternatives (I'd've included CloudMade but I don't have an enterprise account): library(ggmap) loc <- c(-96, 29.4, -94, 30.2) # gmaps tx_map_gmaps <- get_map(location=loc, source="google", maptype="terrain") gg <- ggmap(tx_map_gmaps) gg

Map county borders on to a ggmap

六月ゝ 毕业季﹏ 提交于 2019-12-04 07:11:05
I am generating a few maps and I would like show the borders of counties on top of a ggmap roadmap. Here is an example using part of Texas. library(ggmap) map = get_map(location = c(-95.31619, 28.42460), zoom = 6, source = "google", maptype="roadmap") map.plot = ggmap(map) # get texas counties counties <- map_data("county") tx_county <- subset(counties, region == 'texas') map.plot + theme_nothing() + geom_polygon(data = tx_county, aes(x=long, y=lat), fill = NA, color = "red") However, the resulting figure has lines crossing counties instead of just the borders. Any thoughts on what I am doing

Get boundaries to come through on states

泪湿孤枕 提交于 2019-12-04 06:43:22
问题 Edit 7 : After quite a bit of help, I've been able to get a map that is getting close to the results I need. But I still need to have the state boundaries come through on the map, but I can't figure it out. In order to make a reproducible example that would be appropriate I need to link to the data set since the dput is so large. To make things easy, I subset only three states, but where the boundary lines do not show up. I would like to be able to have the boundary lines come through the

Parsimonious way to add north arrow and scale bar to ggmap

大城市里の小女人 提交于 2019-12-04 03:53:22
I am trying to use ggmap to create a map of the protected areas I am working in with a satellite image from google earth underneath. I can make a very satisfactory image except that it lacks a north arrow and scale bar: I'm aware that there are very long winded ways to add these elements (e.g. here ) but there must surely be a more parsimonious way to do it! I've tried using map.scale and north.arrow but these both give me: Error in polygon(xb + arrow.x * s, yb + arrow.y * s, ...) : plot.new has not been called yet I can get both map.scale and north.arrow to work in base R using plot but then

R: Mapping multiple Routes using ggmap

こ雲淡風輕ζ 提交于 2019-12-03 23:10:00
I have been trying to make a different this lovely flowing data visualization for some time this week but keep hitting a snag in the final implementation. Here is the data set I'm using. I have melded it into a frame with the three key bits of information I want to display: startinglatlong, endinglatlong, and number of trips. I got closest using the idea posted here , but two hit a snag on two items: 1) making the size of the line change based on the number of trips 2) getting the google api to allow me to call this many rows (I have 55,704 in my data set). counts is the name of my full df,

Why is bins parameter unknown for the stat_density2d function? (ggmap)

故事扮演 提交于 2019-12-03 22:48:31
I have been stuck with this for hours. When I run this : library(ggmap) set.seed(1) n=100 df <- data.frame(x=rnorm(n, 0, 1), y=rnorm(n, 0, 1)) TestData <- ggplot (data = df) + stat_density2d(aes(x = x, y = y,fill = as.factor(..level..)),bins=4, geom = "polygon",) + geom_point(aes(x = x, y = y)) + scale_fill_manual(values = c("yellow","red","green","royalblue", "black")) I get this error message : Error: Unknown parameters: bins Does anyone know why? Okay, adding this one as a second answer because I think the descriptions and comments in the first answer are useful and I don't feel like

Plot spatial area defined by multiple polygons

梦想的初衷 提交于 2019-12-03 22:14:17
问题 I have a SpatialPolygonsDataFrame with 11589 spatial objects of class "polygons". 10699 of those objects consists of exactly 1 polygon. However, the rest of those spatial objects consist of multiple polygons (2 to 22). If an object of consists of multiple polygons, three scenarios are possible: 1) The additional polygons could describe a "hole" in the spatial area described by the first polygon . 2) The additional polygons could also describe additional geographic areas, i.e. the shape of the

ggplot US state map; colors are fine, polygons jagged - r

放肆的年华 提交于 2019-12-03 17:59:46
问题 I'm trying to plot a US map where each state is shaded by the count that it has. I've gotten the shading to work just fine. The problem I'm running into, however, is that the polygons look very jagged (I'm assuming something happened when I tried to merge the map_data('state') with my data frame of counts per state). My data frame before merging has 49 rows (Nevada was missing data in my set), and after merging has many more rows (expected for the long/lat items for the states) but the data