ggmap

Plotting static base map underneath a sf object

≯℡__Kan透↙ 提交于 2021-02-18 21:01:48
问题 I'm trying to plot a static base map underneath my sf object (for print). When using ggmap I first get a lot of errors, then I can't seem to figure out how to chain the base map to my ggplot2 object with a geom_sf . library(sf) # devtools::install_github("tidyverse/ggplot2") library(ggplot2) library(ggmap) nc <- st_read(system.file("shape/nc.shp", package="sf")) nc_map <- get_map(location = "North Carolina, NC", zoom = 7) ggmap(nc_map) nc_centers <- st_centroid(nc) nc_centers %>% ggplot() +

specific country map with district/cities using R

蓝咒 提交于 2021-02-17 05:33:23
问题 I am trying to draw some specific countries map such as, Bangladesh, Bhutan etc. with its district/cities in R. As an example, I can draw US map using the following lines of codes. Is there any such library/package that can give me any countries map with its cities/district/province? Any clue is appreciated. library(maps) states <- map_data("state") 回答1: You can download shapefile of any country from the following website https://www.diva-gis.org/gdata Then read and plot them in R using

geom_point color is not correct

爱⌒轻易说出口 提交于 2021-01-29 03:36:52
问题 I'm trying to plot points from a csv using ggmap. The input csv has latitude, longitude, and hex color value (as well as a seed used to create the color value). However, the hex for the point and the actual color of the point don't match. Why is that? The current output My code: library(ggmap) stores <- data.frame((read.csv(file="./mapData") # Fetch the map madison = get_map(location = location, source = "osm") # Draw the map madisonMap = ggmap(madison) # Add the points layer madisonMap =

Creating a Choropleth map with US county level data

放肆的年华 提交于 2021-01-29 03:00:36
问题 I'm trying to produce a choropleth map of county level data on COVID-19 infections using R. I'm a relative newbie to R so.... I've done some fairly basic stuff with ggmap to plot spatial data, but never anything quite like this. Typically I just have points of interest that I need to overlay on a map, so I can use geom_point and their lat/lon. In this case I need to construct the underlying map and then fill regions and I'm struggling with doing that in the ggplot world. I've followed some

Revisiting the “Format latitude and longitude axis labels in ggplot”

邮差的信 提交于 2021-01-28 05:10:30
问题 the question/problem is very similar to the original question: change the decimal degrees to degrees minutes seconds in the ggplot axis labels. I'm following these steps: library(ggplot2) library(ggmap) #get my map city<- get_map(location = c(lon= -54.847, lat= -22.25), maptype = "satellite",zoom = 11,color="bw") map<-ggmap(city,extent="normal")+ xlab("Longitude")+ ylab("Latitude") map In addition, I'm trying what @Jaap wrote: scale_x_longitude <- function(xmin=-180, xmax=180, step=1, ...) {

extracting city and state information from a google street address

China☆狼群 提交于 2020-08-25 06:56:38
问题 I have a data set that contained lat/long information for different point locations, and I would like to know which city and state are associated with each point. Following this example I used the revgeocode function from ggmap to obtain a street address for each location, producing the data frame below: df <- structure(list(PointID = c(1787L, 2805L, 3025L, 3027L, 3028L, 3029L, 3030L, 3031L, 3033L), Latitude = c(38.36648102, 36.19548585, 43.419774, 43.437222, 43.454722, 43.452643, 43.411949,

extracting city and state information from a google street address

岁酱吖の 提交于 2020-08-25 06:56:07
问题 I have a data set that contained lat/long information for different point locations, and I would like to know which city and state are associated with each point. Following this example I used the revgeocode function from ggmap to obtain a street address for each location, producing the data frame below: df <- structure(list(PointID = c(1787L, 2805L, 3025L, 3027L, 3028L, 3029L, 3030L, 3031L, 3033L), Latitude = c(38.36648102, 36.19548585, 43.419774, 43.437222, 43.454722, 43.452643, 43.411949,

Any way to plot multiple barplots on a map?

只谈情不闲聊 提交于 2020-04-13 06:33:29
问题 I'm attempting to plot multiple barplots on a map and am just looking for a place to start. I've looked at a few questions already (shown below).. Barplots on a Map Plotting bar charts on map using ggplot2? How to plot barchart onto ggplot2 map However, all of these seem out of date. Below is the data I am trying to plot. I'm looking to make 4 plots on one map with one in each geolocation. I want each plot to be a barpot of counts for each purpose at each respective location. geoloc purpose

Error: 'StatIdentity' is not an exported object from 'namespace:ggplot2' when calling ggmap in R [duplicate]

為{幸葍}努か 提交于 2020-03-27 06:57:05
问题 This question already has an answer here : How should I deal with “'someFunction' is not an exported object from 'namespace:somePackage'” error? [closed] (1 answer) Closed 23 days ago . I'm trying to create a map of board members for my nonprofit using ggmap . I'm located in San Diego so my code is as follows: mapPoints <- qmap('San Diego, CA', zoom = 10) + geom_point(data = membershipClean, aes(x = lon, y = lat, stat = "identity", size = Dues.Amount), alpha = .5) Where lat and lon are the