ggmap

R geom_point and ggmap

倖福魔咒の 提交于 2019-11-28 11:39:55
I want to plot a ggmap in R, for example, of Australia and have a layer of data points with markers corresponding to the size specified by the following data: sitename lat lon sitenum Sydney -34 151 1 Melbourne -37 144 4 Adelaide -34 138 7 Here's my code, but it's not working... library(ggmap) map <- get_map(location = 'Australia', zoom = 4) mapPoints <- ggmap(map) + geom_point(aes(x = lon, y = lat, size = sitenum), alpha = .5) You need to pass the points as the data argument to geom_points . If they are in the data.frame pp , then the following will owrk ggmap(map) + geom_point(data = pp, aes

Filled contour plot with R/ggplot/ggmap

邮差的信 提交于 2019-11-28 10:25:55
I'm having trouble plotting a filled contour plot on top of a map with ggmap/ggplot2 in R. My data are regularly spaced lat/lon coordinates with a z value indicating rainfall > head( flood ) lat lon rain 1 22.51916 -105.9318 1.486188e-05 2 22.59956 -105.9318 1.735962e-05 3 22.67996 -105.9318 2.024598e-05 4 22.76037 -105.9318 2.357599e-05 5 22.84077 -105.9318 2.741153e-05 6 22.92117 -105.9318 3.182212e-05 After getting the base map with ggmap, I'm trying to overplot filled contours of rain map = ggmap( baseMap ) + geom_contour( data = flood, aes( x = lon, y = lat, z = rain ) ) + scale_fill

Error in get_map using ggmap in R

痴心易碎 提交于 2019-11-28 08:57:31
About 90% of the time, when using get_map in ggmap , I get the following error. Can someone please tell me why? map <- get_map(location = 'Australia', zoom = 4) Error in download.file(url, destfile = destfile, quiet = !messaging, mode = "wb") : cannot open URL ' http://maps.googleapis.com/maps/api/staticmap?center=Australia&zoom=4&size=%20640x640&scale=%202&maptype=terrain&sensor=false ' In addition: Warning message: In download.file(url, destfile = destfile, quiet = !messaging, mode = "wb") : cannot open: HTTP status was '403 Forbidden' The problem is likely related to your API project not

Small ggplot2 plots placed on coordinates on a ggmap

浪尽此生 提交于 2019-11-28 08:48:18
I would like to first use ggmap to plot a specific area with longitude and latitude as axes. Then I would like to put small ggplot2 plots on the specific locations, given their longitude and latitude. These can be barplots with minimal theme. My database may have the columns: 1. town 2. longitude 3. latitude 4. through 6. value A, B, C I generate a plot (pseudocode) p <- ggmap(coordinates) and I have my minimal ggplot2 design q<-ggplot2()+geom_bar(....)+ ... x-axis null y axis null minimal template How to combine the two designs to have a ggmap with small minimal ggplot plots imposed on

How to put a geom_sf produced map on top of a ggmap produced raster

跟風遠走 提交于 2019-11-28 07:46:30
I tried the following code: library(ggplot2) library(ggmap) library(sf) nc <- st_read(system.file("shape/nc.shp", package = "sf")) str(nc) Classes ‘sf’ and 'data.frame': 100 obs. of 15 variables: $ AREA : num 0.114 0.061 0.143 0.07 0.153 0.097 0.062 0.091 0.118 0.124 ... $ PERIMETER: num 1.44 1.23 1.63 2.97 2.21 ... $ CNTY_ : num 1825 1827 1828 1831 1832 ... $ CNTY_ID : num 1825 1827 1828 1831 1832 ... $ NAME : Factor w/ 100 levels "Alamance","Alexander",..: 5 3 86 27 66 46 15 37 93 85 ... $ FIPS : Factor w/ 100 levels "37001","37003",..: 5 3 86 27 66 46 15 37 93 85 ... $ FIPSNO : num 37009

Increase the api limit in ggmap's geocode function (in R)

半世苍凉 提交于 2019-11-28 05:31:14
I'm trying to use the geocode function from the ggmaps library in R to get coordinates for specific locations. I'm able to use the function fine so far. The issue I'm running into is that I would like to increase my daily limit from 2,500 to 100,000 . The official Google documentation says that this is readily possible if you enable billing on the project, which I'm happy to do. When you proceed with this process, the Google Developers Console gives you a personalized API key. However, the geocode function doesn't have an option to put in this personalized API key. Instead, it asks for the

Plot coordinates on map

纵然是瞬间 提交于 2019-11-28 03:12:19
I am trying to plot my coordinates using R. I have tried already to follow different post ( R: Plot grouped coordinates on world map ; Plotting coordinates of multiple points at google map in R ) but I am not having much success with my data. I am trying to achieve a flat map of the world with my gps coordinate as colored dots (each area a specific color): area lat long Agullhas -38,31 40,96 Polar -57,59 76,51 Tasmanian -39,47 108,93 library(RgoogleMaps) lat <- c(-38.31, -35.50) #define our map's ylim lon <- c(40.96,37.50) #define our map's xlim center = c(mean(lat), mean(lon)) #tell what

Add raster to ggmap base map: set alpha (transparency) and fill color to inset_raster() in ggplot2

三世轮回 提交于 2019-11-27 23:54:07
I want to plot a map with a raster overlaying a GoogleMaps base map in ggplot2. Therefore, I used get_map() and insert_raster() like this: library(ggplot2) library(ggmap) bm <- ggmap(get_map(location = "Bangkok", maptype = "hybrid")) bm + inset_raster(as.raster(r), xmin = r@extent[1], xmax = r@extent[2], ymin = r@extent[3], ymax = r@extent[4]) Is there any possibility to set a alpha and change the fill color? The result looks like this: Even Faster without fortify : read the original post below for further information From this blog entry I found that we can use spatial polygons directly in

ggplot piecharts on a ggmap: labels destroy the small plots

我是研究僧i 提交于 2019-11-27 22:42:29
问题 My ggmap on which I would like small piecharts with labels is generated with the code: p <- get_googlemap( "Poland", maptype = "roadmap", zoom = 6, color = "bw", crop = T, style = 'feature:all|element:labels|visibility:off' #'feature:administrative.country|element:labels|visibility:off' or 'feature:all|element:labels|visibility:off' ) %>% ggmap() + coord_cartesian() + scale_x_continuous(limits = c(14, 24.3), expand = c(0, 0)) + scale_y_continuous(limits = c(48.8, 55.5), expand = c(0, 0)) I am

Justification of multiple legends in ggmap/ggplot2

萝らか妹 提交于 2019-11-27 22:05:18
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=runif(12,-133.5,-122.5)) osmMap <- get_map(location=c(-134,47.5,-122,55), source = 'osm') points <-