ggmap

ggmap extended zoom or boundaries

旧时模样 提交于 2019-12-01 05:27:16
问题 I am trying to fix the following problem. I use ggplot2 to plot a map of an island: island = get_map(location = c(lon = -63.247593, lat = 17.631598), zoom = 14, maptype = "satellite") islandMap = ggmap(island, extent = "panel", legend = "bottomright") RL = geom_point(aes(x = longitude, y = latitude), data = data, size = 4, color = "#ff0000") islandMap + RL Coordinates of the RL points: data = data.frame( ID = as.numeric(c(1:8)), longitude = as.numeric(c(-63.27462, -63.26499, -63.25658, -63

Plot spatial area defined by multiple polygons

不打扰是莪最后的温柔 提交于 2019-12-01 01:22:33
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 region is quite complex and described by putting together multiple parts. 3) Often it is a mix of both

Generating spatial heat map via ggmap in R based on a value

那年仲夏 提交于 2019-11-30 16:27:11
I'd like to generate a choropleth map using the following data points: Longitude Latitude Price Here is the dataset - https://www.dropbox.com/s/0s05cl34bko7ggm/sample_data.csv?dl=0 . I would like the map to show the areas where the price is higher and the where price is lower. It should most probably look like this (sample image): Here is my code: library(ggmap) map <- get_map(location = "austin", zoom = 9) data <- read.csv(file.choose(), stringsAsFactors = FALSE) data$average_rate_per_night <- as.numeric(gsub("[\\$,]", "", data$average_rate_per_night)) ggmap(map, extent = "device") + stat

Plotting points from a data.frame using OpenStreetMap

南笙酒味 提交于 2019-11-30 12:18:33
问题 I am a complete novice with spacial data. I have the following code that successfully plots a bounded map. I would like to add, as points the data.frame stores. I apologize in advance for not being able to figure this out from the OpenStreetMap documentation...code below: library(OpenStreetMap) stores <- data.frame(name=c("Commercial","Union","Bedford"), longitude=c(-70.25042295455933,-70.26050806045532,-70.27726650238037), latitude=c(43.657471302616806,43.65663299041943,43.66091757424481))

ggmap::get_map doesn't allow the exact specification of my map's corners?

佐手、 提交于 2019-11-30 11:45:31
I am using R package ggmap. ?get_map says: location: an address, longitude/latitude pair (in that order), or left/bottom/right/top bounding box My code: library(ggmap) library(mapproj) lat_bottom = 52.33 # bottom latitude of Berlin lat_top = 52.5 # top latitude of Berlin lon_left = 13.0 # left longitude of Berlin lon_rigth = 13.95 # right longitude of Berlin mymap <- get_map(location = c(lon_left,lat_bottom,lon_rigth,lat_top), source="google") ggmap(mymap) Why is it giving me a warning: Warning: bounding box given to google - spatial extent only approximate. converting bounding box to center

Loop for Reverse Geocoding in R

£可爱£侵袭症+ 提交于 2019-11-30 08:19:51
问题 I am trying to reverse geocode a large data-set (around 100k). I used the revgeocode function from the package ggmap . I got the result for 1 entry 48 Grand View Terrace, San Francisco, CA 94114, USA 48 Grand View Terrace Eureka Valley San Francisco San Francisco County California United States postal_code postal_code_suffix , but I need to automate the process and use it for the entire data-set. I tried r <- lapply(revgeocode(location = (c(z$lon),c(z$lat)), output = "more", messaging = FALSE

Plot circle with a certain radius around point on a map in ggplot2

只愿长相守 提交于 2019-11-30 06:46:55
问题 I have a map with the 8 points plotted on it: library(ggplot2) library(ggmap) data = data.frame( ID = as.numeric(c(1:8)), longitude = as.numeric(c(-63.27462, -63.26499, -63.25658, -63.2519, -63.2311, -63.2175, -63.23623, -63.25958)), latitude = as.numeric(c(17.6328, 17.64614, 17.64755, 17.64632, 17.64888, 17.63113, 17.61252, 17.62463)) ) island = get_map(location = c(lon = -63.247593, lat = 17.631598), zoom = 13, maptype = "satellite") islandMap = ggmap(island, extent = "panel", legend =

Plotting coordinates of multiple points at google map in R

元气小坏坏 提交于 2019-11-30 05:30:59
I wanted to plot the coordinates on a Google Map in the presence of point id: Sample of data: coordinates id 1 (7.1735, 45.8688) 2 2 (7.17254, 45.8689) 3 3 (7.17164, 45.8692) 4 4 (7.18018, 45.8716) 5 5 (7.17807, 45.8701) 6 6 (7.17723, 45.8692) 7 7 (7.17524, 45.8681) 8 8 (7.18141, 45.8718) 9 9 (7.1793, 45.8702) 10 10 (7.17836, 45.8707) 11 11 (7.17519, 45.8697) 12 12 (7.17938, 45.8708) 13 13 (7.17551, 45.8693) 14 14 (7.17684, 45.8694) 15 15 (7.18099, 45.8726) 17 16 (7.18015, 45.8725) 18 17 (7.18122, 45.8736) 19 18 (7.17491, 45.8692) 20 19 (7.15497, 45.8706) 25 20 (7.1534, 45.8695) 28 21 (7.15265

Format latitude and longitude axis labels in ggplot

隐身守侯 提交于 2019-11-30 05:14:18
I have a ggplot map, for example: library(ggmap) ggmap(get_map()) I'd like the axis labels to be automatically labeled as N-S / W-E: in the above case, for example, instead of lon -95.4 it should show 95.4°E. I have tried to mess with the scales package and using scale_x_continuous and scale_y_continuous labels and breaks options, but I have not managed to make it work. It would be awesome to have a scale_y_latitude and scale_x_longitude . EDIT: Thanks to @Jaap 's answer I got to the following: scale_x_longitude <- function(xmin=-180, xmax=180, step=1, ...) { ewbrks <- seq(xmin,xmax,step)

Determining the distance between two ZIP codes (alternatives to mapdist)

白昼怎懂夜的黑 提交于 2019-11-29 22:35:28
I want to calculate the distance between approx. 100,000 different ZIP codes. I know about the mapdist function in the ggmap package mapdist works perfectly: library(ggmap) mapdist('Washington', 'New York', mode = 'driving') # from to m km miles seconds minutes hours # 1 Washington New York 366284 366.284 227.6089 13997 233.2833 3.888056 mapdist('20001', '10001', mode = 'driving') # from to m km miles seconds minutes hours # 1 20001 10001 363119 363.119 225.6421 13713 228.55 3.809167 However, mapdist relies on the Google Geocoding API which is subject to a query limit of 2,500 geolocation