ggmap

geocode from ggmap fails on shiny server

烈酒焚心 提交于 2019-12-06 18:16:29
I have an app where the user can provide a specific address and the app returns the geocode which is later used to subset the data. The snippet of the code is as simple as: library(ggmap) geocode("2020 walnut street pa") This works perfectly when I run it on my local machine. I get the below output: Information from URL : http://maps.googleapis.com/maps/api/geocode/json?address=2020%20walnut%20street%20pa&sensor=false lon lat 1 -75.17508 39.95034 However when I run this same code on the shiny server, I get the below error: > library(ggmap) Loading required package: ggplot2 > geocode("2020

What is the “Simplest” way to add a scale to a map in ggmap

◇◆丶佛笑我妖孽 提交于 2019-12-06 15:34:17
问题 For real, I searched everywhere, and coding a scale in a map is so hard... Adding scale bar to ggplot map Is there a way to add a scale bar (for linear distances) to ggmap? Could it be possible to make a simple line that scale differently to the zoom preset that we select in the function? I have this simple map: library(ggmap) pngMAP_df2 = get_map(location = c(-90.5, -0.5), source = "google", zoom = 8,color = "bw") s = ggmap(pngMAP_df2) s I wanted to add as well GPS coordinate in this graph:

Binning longitude/latitude labeled data by census block ID

怎甘沉沦 提交于 2019-12-06 14:58:57
问题 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

Creating base_layer for ggmap not recognizing data.frame

梦想的初衷 提交于 2019-12-06 12:44:14
问题 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

r heatmap on ggmap from kriging data

安稳与你 提交于 2019-12-06 12:29:05
问题 I want to plot a heatmap on a ggmap. library(ggmap) turku<-get_map('turku', zoom=13) turkumap<-ggmap(turku, extent="device", legend="topleft") turkumap turkumap+geom_density2d(mapping=aes(x = lon, y = lat),data = test, ) We have made a measurement campaign, so I have 4460 geo-referentiated points. To have a prediction map, I created a grid 400*400, for a total of 160000 points in which I calculate the prediction with kriging. To have a full picture of the phenomenon in my 3 km *3 km i think

Retrieve Census tract from Coordinates [closed]

只谈情不闲聊 提交于 2019-12-06 06:09:49
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed last year . I have a dataset with longitude and latitude coordinates. I want to retrieve the corresponding census tract. Is there a dataset or api that would allow me to do this? My dataset looks like this: lat lon 1 40.61847 -74.02123 2 40.71348 -73.96551 3 40.69948 -73.96104 4 40.70377 -73.93116 5 40.67859 -73.99049 6 40

Non-square (rectangular) maps in R-ggmap

血红的双手。 提交于 2019-12-06 03:53:51
问题 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? 回答1: 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) #

Map county borders on to a ggmap

…衆ロ難τιáo~ 提交于 2019-12-06 03:31:15
问题 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

Trouble reading in geojson/json file into R for plotting on map

梦想与她 提交于 2019-12-06 03:09:31
I'm trying to read in a json file which contains polylines into R for plotting in leaflet or ggmap. The file is in the geojson format. The file can be found at: http://datasets.antwerpen.be/v4/gis/statistischesector.json I've tried: library(rgdal) library(jsonlite) library(leaflet) geojson <- readLines("statistischesector.json", warn = FALSE) %>% paste(collapse = "\n") %>% fromJSON(simplifyVector = FALSE) This actually reads in the file but it seems to be in a wrong format for further processing. Alternatively: readOGR(dsn="~/statistischesector.json", layer="OGRGeoJSON") Returns: Error in

Parsimonious way to add north arrow and scale bar to ggmap

假装没事ソ 提交于 2019-12-05 22:44:08
问题 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