ggmap

Dynamic data point label Positioning in ggmap

懵懂的女人 提交于 2019-12-05 08:07:30
I'm working with the ggmap package in R and I am relatively new to geospatial data visualizations. I have a data frame of eleven latitude and longitude pairs that I would like to plot on a map, each with a label. Here is the dummy data: lat<- c(47.597157,47.656322,47.685928,47.752365,47.689297,47.628128,47.627071,47.586349,47.512684,47.571232,47.562283) lon<-c(-122.312187,-122.318039,-122.31472,-122.345345,-122.377045,-122.370117,-122.368462,-122.331734,-122.294395,-122.33606,-122.379745) labels<-c("Site 1A","Site 1B","Site 1C","Site 2A","Site 3A","Site 1D","Site 2C","Site 1E","Site 2B","Site

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

家住魔仙堡 提交于 2019-12-05 07:12:41
问题 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? 回答1: Okay, adding this one as a second

ggmap changing size of map

随声附和 提交于 2019-12-05 02:48:28
I would like to create a map that is not perfectly square but rectangular and is the size I dictate. require(ggmap) tenmile <- get_map(location = c(lon = -122.486328, lat = 48.862813), color = "color", source = "google", maptype = "roadmap", zoom = 12) tenmile.map <- ggmap(tenmile, extent = "device", ylab = "Latitude", xlab = "Longitude")+ggtitle("GEOMean for Data from Oct 2013-Nov 2014") tenmile.map + geom_point(data=pp, aes(x=lon, y=lat, size=geomean), color="red", alpha=0.5) + geom_text(data=pp, aes(x=lon, y=lat, label = site), size=3, vjust = 1.25, hjust = -0.1) I would post pictures of

I'm having trouble adding a shapefile to my ggmap due to differing geographic units

纵然是瞬间 提交于 2019-12-05 01:18:26
问题 I am trying to add an ESRI shapefile (.shp) to a ggmap plot of the state of North Carolina, which has the following code: x <- get_map(location="North Carolina", zoom=6, maptype="terrain") ggmap(x) + geom_polygon(data=citylim83.df, aes(x=long, y=lat), fill="red", alpha=0.2) The shapefile I've loaded and fortified into citylim83.df . Here is the code used to load the shapefile into ggplot: epsgs <- make_EPSG() citylim <- readOGR(dsn=".", layer="MunicipalBoundaries_polys")` The units of the

Binning longitude/latitude labeled data by census block ID

人走茶凉 提交于 2019-12-04 21:24:20
I have two data sets, one for crime in Chicago, labeled with longitude and latitude coords and a shapefile of census blocks also in Chicago. Is it possible in R to aggregate crimes within census blocks, given these two files? The purpose is to be able to map out the crimes by census block. Location for download of Chicago census tract data: https://data.cityofchicago.org/Facilities-Geographic-Boundaries/Boundaries-Census-Blocks-2000/uktd-fzhd Location for download of crime data: https://data.cityofchicago.org/Public-Safety/Crimes-2001-to-present/ijzp-q8t2 Some code that I have pruned down from

Creating base_layer for ggmap not recognizing data.frame

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-04 18:51:10
I am trying to use ggmap to plot locations on a map. Because I want to use faceting, I have to supply the base_layer argument to ggmap . I am also trying to wrap this in a function. I have variables that define the bounding box of my map: long.range <- c(-71.5, -67.5) lat.range <- c(42.5, 44.5) And a data.frame that defines the data I want to plot: test.data <- data.frame("Name" = c("site1","site2","site3"), "LAT" = c(43.25,43.4,44), "LONG" = c(-71.25,-69.5,-68.5)) I have a function that goes out and grabs the map and applies the data.frame as the base_layer: CreateBaseMap <- function(lat

R Create a Spatial Bubble Plot That Overlays A basemap of the US and other spatial layers as needed

不问归期 提交于 2019-12-04 17:01:11
I'm trying to produce a nice bubble plot overlaid on top of a basemap of the US (i could import a shapefile if that is preferred but i've been using the R basemaps. library(ggplot2,sp,raster,maps,mapdata,maptools,ggmap,rgeos) myData = data.frame(name=c("Florida","Colorado","california","Harvard","Yellowstone"), lat=c(28.1,39,37,42,44.6), long=c(-81.6,-105.5,-120,-71,-110), pop=c(280,156,128,118,202)) Using this code below, that i adapted from another stack overflow post ( Create bubble plot in R using satellite map ), i am able to overlay a bubble plot on a map of the US. However this renders

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

主宰稳场 提交于 2019-12-04 11:25:10
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.57462, -23.56360, -23.53748)) suppliers <- data.frame(lon=c(-46.70819,-46.68155, -46.74376), lat=c(-23

ggmap stamen watercolor png error

烂漫一生 提交于 2019-12-04 10:55:31
问题 I would really appreciate some help / ideas about a problem I am having with ggmap and stamen watercolor. I keep getting the same error message every time I try to create a stamen watercolor map: "Error in readPNG(destfile) : file is not in PNG format" Here are some examples of simple code that is returning this error: qmap("new-york", zoom=13, source="stamen", maptype="watercolor") or get_map(location='Auckland', source="stamen", maptype="watercolor", zoom=13) I am using r version: [Default]

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

孤街醉人 提交于 2019-12-04 10:50:27
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): My goal, of course, is to still have a horizontal and vertical x and y axis as the original image, but