A package for plotting maps in R with ggplot2

Overview

CRAN status Travis build status AppVeyor build status

Attention!

Google has recently changed its API requirements, and ggmap users are now required to register with Google. From a user’s perspective, there are essentially three ramifications of this:

  1. Users must register with Google. You can do this at https://cloud.google.com/maps-platform/. While it will require a valid credit card (sorry!), there seems to be a fair bit of free use before you incur charges, and even then the charges are modest for light use.

  2. Users must enable the APIs they intend to use. What may appear to ggmap users as one overarching “Google Maps” product, Google in fact has several services that it provides as geo-related solutions. For example, the Maps Static API provides map images, while the Geocoding API provides geocoding and reverse geocoding services. Apart from the relevant Terms of Service, generally ggmap users don’t need to think about the different services. For example, you just need to remember that get_googlemap() gets maps, geocode() geocodes (with Google, DSK is done), etc., and ggmap handles the queries for you. However, you do need to enable the APIs before you use them. You’ll only need to do that once, and then they’ll be ready for you to use. Enabling the APIs just means clicking a few radio buttons on the Google Maps Platform web interface listed above, so it’s easy.

  3. Inside R, after loading the new version of ggmap, you’ll need provide ggmap with your API key, a hash value (think string of jibberish) that authenticates you to Google’s servers. This can be done on a temporary basis with register_google(key = "[your key]") or permanently using register_google(key = "[your key]", write = TRUE) (note: this will overwrite your ~/.Renviron file by replacing/adding the relevant line). If you use the former, know that you’ll need to re-do it every time you reset R.

Your API key is private and unique to you, so be careful not to share it online, for example in a GitHub issue or saving it in a shared R script file. If you share it inadvertantly, just get on Google’s website and regenerate your key - this will retire the old one. Keeping your key private is made a bit easier by ggmap scrubbing the key out of queries by default, so when URLs are shown in your console, they’ll look something like key=xxx. (Read the details section of the register_google() documentation for a bit more info on this point.)

The new version of ggmap is now on CRAN soon, but you can install the latest version, including an important bug fix in mapdist(), here with:

if(!requireNamespace("devtools")) install.packages("devtools")
devtools::install_github("dkahle/ggmap")

ggmap

ggmap is an R package that makes it easy to retrieve raster map tiles from popular online mapping services like Google Maps and Stamen Maps and plot them using the ggplot2 framework:

library("ggmap")
#  Loading required package: ggplot2
#  Registered S3 methods overwritten by 'ggplot2':
#    method         from 
#    [.quosures     rlang
#    c.quosures     rlang
#    print.quosures rlang
#  Google's Terms of Service: https://cloud.google.com/maps-platform/terms/.
#  Please cite ggmap if you use it! See citation("ggmap") for details.

us <- c(left = -125, bottom = 25.75, right = -67, top = 49)
get_stamenmap(us, zoom = 5, maptype = "toner-lite") %>% ggmap() 
#  Map tiles by Stamen Design, under CC BY 3.0. Data by OpenStreetMap, under ODbL.

Use qmplot() in the same way you’d use qplot(), but with a map automatically added in the background:

library("dplyr")
#  
#  Attaching package: 'dplyr'
#  The following objects are masked from 'package:stats':
#  
#      filter, lag
#  The following objects are masked from 'package:base':
#  
#      intersect, setdiff, setequal, union
library("forcats")

# define helper
`%notin%` <- function(lhs, rhs) !(lhs %in% rhs)

# reduce crime to violent crimes in downtown houston
violent_crimes <- crime %>% 
  filter(
    offense %notin% c("auto theft", "theft", "burglary"),
    -95.39681 <= lon & lon <= -95.34188,
     29.73631 <= lat & lat <=  29.78400
  ) %>% 
  mutate(
    offense = fct_drop(offense),
    offense = fct_relevel(offense, c("robbery", "aggravated assault", "rape", "murder"))
  )

# use qmplot to make a scatterplot on a map
qmplot(lon, lat, data = violent_crimes, maptype = "toner-lite", color = I("red"))
#  Using zoom = 14...
#  Map tiles by Stamen Design, under CC BY 3.0. Data by OpenStreetMap, under ODbL.

All the ggplot2 geom’s are available. For example, you can make a contour plot with geom = "density2d":

qmplot(lon, lat, data = violent_crimes, maptype = "toner-lite", geom = "density2d", color = I("red"))

In fact, since ggmap’s built on top of ggplot2, all your usual ggplot2 stuff (geoms, polishing, etc.) will work, and there are some unique graphing perks ggmap brings to the table, too.

robberies <- violent_crimes %>% filter(offense == "robbery")

qmplot(lon, lat, data = violent_crimes, geom = "blank", 
  zoom = 14, maptype = "toner-background", darken = .7, legend = "topleft"
) +
  stat_density_2d(aes(fill = ..level..), geom = "polygon", alpha = .3, color = NA) +
  scale_fill_gradient2("Robbery\nPropensity", low = "white", mid = "yellow", high = "red", midpoint = 650)
#  Map tiles by Stamen Design, under CC BY 3.0. Data by OpenStreetMap, under ODbL.

Faceting works, too:

qmplot(lon, lat, data = violent_crimes, maptype = "toner-background", color = offense) + 
  facet_wrap(~ offense)
#  Using zoom = 14...
#  Map tiles by Stamen Design, under CC BY 3.0. Data by OpenStreetMap, under ODbL.

Google Maps and Credentials

Google Maps can be used just as easily. However, since Google Maps use a center/zoom specification, their input is a bit different:

get_googlemap("waco texas", zoom = 12) %>% ggmap()
#  Source : https://maps.googleapis.com/maps/api/staticmap?center=waco%20texas&zoom=12&size=640x640&scale=2&maptype=terrain&key=xxx
#  Source : https://maps.googleapis.com/maps/api/geocode/json?address=waco+texas&key=xxx

Moreover, you can get various different styles of Google Maps with ggmap (just like Stamen Maps):

get_googlemap("waco texas", zoom = 12, maptype = "satellite") %>% ggmap()
get_googlemap("waco texas", zoom = 12, maptype = "hybrid") %>% ggmap()
get_googlemap("waco texas", zoom = 12, maptype = "roadmap") %>% ggmap()

Google’s geocoding and reverse geocoding API’s are available through geocode() and revgeocode(), respectively:

geocode("1301 S University Parks Dr, Waco, TX 76798")
#  Source : https://maps.googleapis.com/maps/api/geocode/json?address=1301+S+University+Parks+Dr,+Waco,+TX+76798&key=xxx
#  # A tibble: 1 x 2
#      lon   lat
#    <dbl> <dbl>
#  1 -97.1  31.6
revgeocode(c(lon = -97.1161, lat = 31.55098))
#  Source : https://maps.googleapis.com/maps/api/geocode/json?latlng=31.55098,-97.1161&key=xxx
#  Multiple addresses found, the first will be returned:
#    1301 S University Parks Dr, Waco, TX 76706, USA
#    55 Baylor Ave, Waco, TX 76706, USA
#    1437 FM434, Waco, TX 76706, USA
#    Bear Trail, Waco, TX 76706, USA
#    Robinson, TX 76706, USA
#    Waco, TX, USA
#    McLennan County, TX, USA
#    Texas, USA
#    United States
#  [1] "1301 S University Parks Dr, Waco, TX 76706, USA"

There is also a mutate_geocode() that works similarly to dplyr’s mutate() function:

tibble(address = c("white house", "", "waco texas")) %>% 
  mutate_geocode(address)
#  Source : https://maps.googleapis.com/maps/api/geocode/json?address=white+house&key=xxx
#  "white house" not uniquely geocoded, using "1600 pennsylvania ave nw, washington, dc 20500, usa"
#  Source : https://maps.googleapis.com/maps/api/geocode/json?address=waco+texas&key=xxx
#  # A tibble: 3 x 3
#    address       lon   lat
#    <chr>       <dbl> <dbl>
#  1 white house -77.0  38.9
#  2 ""           NA    NA  
#  3 waco texas  -97.1  31.5

Treks use Google’s routing API to give you routes (route() and trek() give slightly different results; the latter hugs roads):

trek_df <- trek("houson, texas", "waco, texas", structure = "route")
#  Source : https://maps.googleapis.com/maps/api/directions/json?origin=houson,+texas&destination=waco,+texas&key=xxx&mode=driving&alternatives=false&units=metric
qmap("college station, texas", zoom = 8) +
  geom_path(
    aes(x = lon, y = lat),  colour = "blue",
    size = 1.5, alpha = .5,
    data = trek_df, lineend = "round"
  )
#  Source : https://maps.googleapis.com/maps/api/staticmap?center=college%20station,%20texas&zoom=8&size=640x640&scale=2&maptype=terrain&language=en-EN&key=xxx
#  Source : https://maps.googleapis.com/maps/api/geocode/json?address=college+station,+texas&key=xxx

(They also provide information on how long it takes to get from point A to point B.)

Map distances, in both length and anticipated time, can be computed with mapdist()). Moreover the function is vectorized:

mapdist(c("houston, texas", "dallas"), "waco, texas")
#  Source : https://maps.googleapis.com/maps/api/distancematrix/json?origins=dallas&destinations=waco,+texas&key=xxx&mode=driving
#  Source : https://maps.googleapis.com/maps/api/distancematrix/json?origins=houston,+texas&destinations=waco,+texas&key=xxx&mode=driving
#  # A tibble: 2 x 9
#    from          to               m    km miles seconds minutes hours mode  
#    <chr>         <chr>        <int> <dbl> <dbl>   <int>   <dbl> <dbl> <chr> 
#  1 houston, tex… waco, texas 298227  298. 185.    10257   171.   2.85 drivi…
#  2 dallas        waco, texas 152480  152.  94.8    5356    89.3  1.49 drivi…

Installation

  • From CRAN: install.packages("ggmap")

  • From Github:

if (!requireNamespace("devtools")) install.packages("devtools")
devtools::install_github("dkahle/ggmap")
Comments
  • get_map ignores the source argument

    get_map ignores the source argument

    I am trying to grab a map like this:

    get_map(location = c(6.815375, 51.217942), zoom = 11, source = "osm")

    Following error occures:

    Error in download.file(url, destfile = destfile, quiet = !messaging, mode = "wb") : can't open URL 'http://maps.googleapis.com/maps/api/staticmap?center=51.217942,6.815375&zoom=11&size=%20640x640&maptype=terrain&sensor=false'

    And an additional warning:

    W In download.file(url, destfile = destfile, quiet = !messaging, mode = "wb") : cannot open: HTTP status was '403 Forbidden'

    Why does ggmap query google, although source is set to "osm" ? And why is the status 403 forbidden?

    opened by grialex 90
  • GGMap error with aperm.default

    GGMap error with aperm.default

    I am trying to use GGmap to create a plot of vehicle car crashes by state. The map will have dots which are sized based on the number of car crashes in the state.

    In particular I am trying to recreate the usa-plot shown in the visualizing clusters section of this blog post.

    However, whenever I try to create the map I get this error.

    Error in aperm.default(map, c(2, 1, 3)) : 
      invalid first argument, must be an array
    

    I have setup the Google API and see that it is recieving hits. I have also enabled it and have the key.

    In addition I have installed GGmap from the github account using this command:

        devtools::install_github("dkahle/ggmap", ref = "tidyup", force=TRUE)
    

    since the CRAN one isn't updated.

    I have restarted and quit R several times as well but the error persists.

    Even if I just simply run:

        get_map()
    

    it still results in the error:

    Error in aperm.default(map, c(2, 1, 3)) : 
          invalid first argument, must be an array
    

    Below is my code, it is similar to the code in the blog post:

        mydata$State <- as.character(mydata$State)
        mydata$MV.Number = as.numeric(mydata$MV.Number)
        mydata = mydata[mydata$State != "Alaska", ]
        mydata = mydata[mydata$State != "Hawaii", ]
        devtools::install_github("dkahle/ggmap", ref = "tidyup", force=TRUE)
        library(ggmap)
        ggmap::register_google(key = "...") #my key is here
        for (i in 1:nrow(mydata)) {
          latlon = geocode(mydata[i,1])
          mydata$lon[i] = as.numeric(latlon[1])
          mydata$lat[i] = as.numeric(latlon[2])
        }
        mv_num_collisions = data.frame(mydata$MV.Number, mydata$lon, mydata$lat)
     
        colnames(mv_num_collisions) = c('collisions','lon','lat')
        usa_center = as.numeric(geocode("United States"))
    
    
        USAMap = ggmap(get_googlemap(center=usa_center, scale=2, zoom=4), 
        extent="normal")
        USAMap + 
           geom_point(aes(x=lon, y=lat), data=mv_num_collisions, col="orange", 
        alpha=0.4, size=mv_num_collisions$collisions*circle_scale_amt) +  
           scale_size_continuous(range=range(mv_num_collisions$collisions))
    

    I expect the map to output like this

    But I cannot seem to get passed this error.

    If anyone can help that would be great.

    Please let me know if you need any more information.

    Thank you.

    opened by SrikarMurali 30
  • again... API problem with ggmap...

    again... API problem with ggmap...

    Dear dkahle, I'm a very beginner in R coding... I used ggmap for the last 5 months now I have the problem with API. I read you previous discussion and that google has chenge the policy and that the new CRAN is not ready ... I also tried you suggestion code:

    key<-"i sued my daily key" resp <- github_api("/repos/hadley/httr")

    if(!requireNamespace("devtools")) install.packages("devtools") devtools::install_github("dkahle/ggmap", ref = "tidyup") ggmap(get_googlemap()) register_google(key = key)

    library(devtools) library(ggplot2) library(ggmap)

    but... when i run ...

    map<-get_map(location= c(lon =15.500414, lat = 42.128677), zoom=8, maptype = "satellite", source = "google", color = "bw")

    I recive the same error:

    Source : https://maps.googleapis.com/maps/api/staticmap?center=42.128677,15.500414&zoom=8&size=640x640&scale=2&maptype=satellite&language=en-EN&key=xxx Error in get_googlemap(center = location, zoom = zoom, maptype = maptype, : Forbidden (HTTP 403).

    How I can solve it? I'm a phd student and I need that map ... please help me.

    Thnkas

    Andrea

    opened by andreapierucci 29
  • object register_google not found

    object register_google not found

    I'm trying to run a simple geocode of some addresses and when it runs it keeps giving me the error the object register_google not found. I decided to install version 2.7, because of the api key implementation which could help me easily track how many geocodes I actually do in a given time period, but I keep getting that error. Any help would be appreciated.

    startTime = Sys.time() geocoded = data.frame(stringsAsFactors = FALSE)

    register_google(key = 'Keepinitprivate')

    #Loop through my address list for(i in 1:nrow(facdata)) { result = geocode(facdata$fac_adr[i], output = "latlona", source = "google") facdata$lon[i] = as.numeric(result[1]) facdata$lat[i] = as.numeric(result[2]) facdata$geoAddress[i] = as.character(result[3]) } endTime <- Sys.time()

    needs more information 
    opened by mrtrick8586 20
  • get_map error: file is not in PNG format

    get_map error: file is not in PNG format

    Hi, this just started today. I had been using ggmap with no problem. I tried the ?get_map example code and it threw the same error. Did google make a change or something? looks like the get_map is getting a jpeg instead of a png and is throwing an error. Thanks for a great package and any help on the error.

    opened by sco-lo-digital 15
  • Do not use OpenStreetMap export endpoint

    Do not use OpenStreetMap export endpoint

    The OpenStreetMap tile usage policy states

    Calls to /cgi-bin/export may only be triggered by direct end-user action. (For example: "click here to export".) The export call is an expensive (CPU+RAM) function to run and will frequently reject when server is under high load.

    Stitching images together like BigMap 2 or StaticMap do is a better option to avoid heavy load, but any usage of tile.openstreetmap.org still needs to follow the usage policy. I couldn't find a User-agent in the source, but all the technical usage requirements need to be met.

    cc @tomhughes

    bug 
    opened by pnorman 13
  • Error in get(

    Error in get("f", environment(CoordMap$train)) : object 'f' not found

    By trying to use the qmplot I am facing the following error:

    qmplot(Longitude, Latitude, data = geolocalized_crimes, maptype = "toner-lite", geom = "density2d", color = I("red")) Using zoom = 8... Error in get("f", environment(CoordMap$train)) : object 'f' not found

    Bellow is the session info, which may help to debug.

    > sessionInfo()
    R version 3.3.2 (2016-10-31)
    Platform: x86_64-pc-linux-gnu (64-bit)
    Running under: Debian GNU/Linux 8 (jessie)
    
    locale:
     [1] LC_CTYPE=en_GB.UTF-8       LC_NUMERIC=C              
     [3] LC_TIME=en_GB.UTF-8        LC_COLLATE=en_GB.UTF-8    
     [5] LC_MONETARY=en_GB.UTF-8    LC_MESSAGES=en_GB.UTF-8   
     [7] LC_PAPER=en_GB.UTF-8       LC_NAME=C                 
     [9] LC_ADDRESS=C               LC_TELEPHONE=C            
    [11] LC_MEASUREMENT=en_GB.UTF-8 LC_IDENTIFICATION=C       
    
    attached base packages:
    [1] stats     graphics  grDevices utils     datasets  methods   base     
    
    other attached packages:
    [1] ggmap_2.7         scales_0.4.1      reshape_0.8.6     plyr_1.8.4       
    [5] tidyr_0.6.1       data.table_1.10.0 ggplot2_2.2.1    
    
    loaded via a namespace (and not attached):
     [1] Rcpp_0.12.9       git2r_0.18.0      bitops_1.0-6      tools_3.3.2      
     [5] digest_0.6.12     memoise_1.0.0     tibble_1.2        gtable_0.2.0     
     [9] lattice_0.20-34   png_0.1-7         DBI_0.5-1         mapproj_1.2-4    
    [13] curl_2.3          proto_1.0.0       withr_1.0.2       stringr_1.1.0    
    [17] dplyr_0.5.0       httr_1.2.1        RgoogleMaps_1.4.1 maps_3.1.1       
    [21] devtools_1.12.0   grid_3.3.2        R6_2.2.0          jpeg_0.1-8       
    [25] tcltk_3.3.2       sp_1.2-4          reshape2_1.4.2    magrittr_1.5     
    [29] assertthat_0.1    geosphere_1.5-5   colorspace_1.3-2  stringi_1.1.2    
    [33] lazyeval_0.2.0    munsell_0.4.3     rjson_0.2.15 
    

    What is missing on my setup?

    opened by edumucelli 12
  • Using a personalized API key in geocode

    Using a personalized API key in geocode

    The geocode function doesn't allow users to use their personalized API key. If it did, the API limit could go from 2,500 requests / day to 100,000 / day.

    opened by LucasPuente 11
  • Installation error

    Installation error

    I have the dev version of ggplot2 and scales installed so perhaps that is causing problems:

    > install_github("dkahle/ggmap")
    Downloading github repo dkahle/[email protected]
    Installing ggmap
    Skipping 2 packages ahead of CRAN: ggplot2, scales
    '/Library/Frameworks/R.framework/Resources/bin/R' --no-site-file --no-environ  \
      --no-save --no-restore CMD INSTALL  \
      '/private/var/folders/wc/zv89d1fx5nxdljsysq40m6vr0000gn/T/RtmpYSGjDx/devtoolse2a716fe460/dkahle-ggmap-99653f1'  \
      --library='/Library/Frameworks/R.framework/Versions/3.2/Resources/library'  \
      --install-tests 
    
    * installing *source* package ‘ggmap’ ...
    ** R
    ** data
    *** moving datasets to lazyload DB
    ** inst
    ** preparing package for lazy loading
    Warning: replacing previous import by ‘grid::arrow’ when loading ‘ggmap’
    Warning: replacing previous import by ‘grid::unit’ when loading ‘ggmap’
    Warning: replacing previous import by ‘scales::alpha’ when loading ‘ggmap’
    Error in eval(expr, envir, enclos) : could not find function "eval"
    Error : unable to load R code in package ‘ggmap’
    ERROR: lazy loading failed for package ‘ggmap’
    * removing ‘/Library/Frameworks/R.framework/Versions/3.2/Resources/library/ggmap’
    * restoring previous ‘/Library/Frameworks/R.framework/Versions/3.2/Resources/library/ggmap’
    Error: Command failed (1)
    > sessionInfo()
    R version 3.2.1 (2015-06-18)
    Platform: x86_64-apple-darwin13.4.0 (64-bit)
    Running under: OS X 10.10.3 (Yosemite)
    
    locale:
    [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
    
    attached base packages:
    [1] stats     graphics  grDevices utils     datasets  methods   base     
    
    other attached packages:
    [1] devtools_1.8.0
    
    loaded via a namespace (and not attached):
     [1] httr_1.0.0      R6_2.1.0        magrittr_1.5    rversions_1.0.2
     [5] tools_3.2.1     curl_0.9.1      Rcpp_0.12.0     memoise_0.2.1  
     [9] xml2_0.1.1      stringi_0.5-5   git2r_0.10.1    stringr_1.0.0  
    [13] digest_0.6.8    fortunes_1.5-2 
    
    > library(ggplot2)
    > session_info()
    Session info -------------------------------------------------------------------
     setting  value                       
     version  R version 3.2.1 (2015-06-18)
     system   x86_64, darwin13.4.0        
     ui       X11                         
     language (EN)                        
     collate  en_US.UTF-8                 
     tz       America/Chicago             
    
    Packages -----------------------------------------------------------------------
     package    * version    date       source                         
     colorspace   1.2-6      2015-03-11 CRAN (R 3.2.0)                 
     curl         0.9.1      2015-07-04 CRAN (R 3.2.0)                 
     devtools   * 1.8.0      2015-05-09 CRAN (R 3.2.0)                 
     digest       0.6.8      2014-12-31 CRAN (R 3.2.0)                 
     fortunes     1.5-2      2013-12-14 CRAN (R 3.2.0)                 
     ggplot2    * 1.0.1.9002 2015-08-05 Github (hadley/[email protected])
     git2r        0.10.1     2015-05-07 CRAN (R 3.2.0)                 
     gtable       0.1.2      2012-12-05 CRAN (R 3.2.0)                 
     httr         1.0.0      2015-06-25 CRAN (R 3.2.0)                 
     magrittr     1.5        2014-11-22 CRAN (R 3.2.0)                 
     memoise      0.2.1      2014-04-22 CRAN (R 3.2.0)                 
     munsell      0.4.2      2013-07-11 CRAN (R 3.2.0)                 
     plyr         1.8.3      2015-06-12 CRAN (R 3.2.0)                 
     R6           2.1.0      2015-07-04 CRAN (R 3.2.0)                 
     Rcpp         0.12.0     2015-07-25 CRAN (R 3.2.0)                 
     rstudioapi   0.3.1      2015-04-07 CRAN (R 3.2.0)                 
     rversions    1.0.2      2015-07-13 CRAN (R 3.2.0)                 
     scales       0.2.5.9003 2015-08-05 Github (hadley/[email protected]) 
     stringi      0.5-5      2015-06-29 CRAN (R 3.2.0)                 
     stringr      1.0.0      2015-04-30 CRAN (R 3.2.0)                 
     xml2         0.1.1      2015-06-02 CRAN (R 3.2.0) 
    
    opened by cpsievert 11
  • Suddenly having problems with gglocator

    Suddenly having problems with gglocator

    Was working fine. Installed some new versions of various packages Now get "Error in grid.Call.graphics(L_downviewport, name$name, strict) : Viewport 'NA' was not found"

    Mac OS X

    R 3.2.2

    ggmap_2.6.1

    ggplot2_2.1.0

    Example from ?gglocator

    if(interactive()){

    • # only run for interactive sessions
      
    • df <- expand.grid(x = 0:-5, y = 0:-5)
      
    • (p <- qplot(x, y, data = df) +
      
    •     annotate(geom = 'point', x = -2, y = -2, colour = 'red'))
      
    • gglocator()
      
    • p +
      
    •     scale_x_continuous(expand = c(0,0)) +
      
    •     scale_y_continuous(expand = c(0,0))
      
    • gglocator(1, xexpand = c(0,0), yexpand = c(0,0))
      
    • } Error in grid.Call.graphics(L_downviewport, name$name, strict) : Viewport 'NA' was not found
    opened by teemo48 10
  • JPEG decompression error ggmap 3.0.0

    JPEG decompression error ggmap 3.0.0

    Reproducible Example

    It looks like the jpeg decompression error from earlier versions may have returned in ggmap 3.0.0 I get the following error message with the example below: Map from URL : http://tile.stamen.com/terrain-background/9/87/203.jpg Error in readJPEG(tmp) : JPEG decompression error: Not a JPEG file: starts with 0x89 0x50

    reprex::reprex({
        library(ggmap)
        ggmap(get_map(location = c(-118.6, 32.3, -116.1, 34.4),
                        maptype="terrain-background", source="stamen"))
    }, si = TRUE)
    
    opened by jockusch 9
  • R 4.2.2, Mac 13.0.1, ... unable to load shared object '/Library/Frameworks/R.framework/Resources/modules//R_X11.so':

    R 4.2.2, Mac 13.0.1, ... unable to load shared object '/Library/Frameworks/R.framework/Resources/modules//R_X11.so':

    Reproducible Example

    $ sw_vers ProductName: macOS ProductVersion: 13.0.1 BuildVersion: 22A400

    R.version
                   _                           
    platform       aarch64-apple-darwin20      
    arch           aarch64                     
    os             darwin20                    
    system         aarch64, darwin20           
    status                                     
    major          4                           
    minor          2.2                         
    year           2022                        
    month          10                          
    day            31                          
    svn rev        83211                       
    language       R                           
    version.string R version 4.2.2 (2022-10-31)
    nickname       Innocent and Trusting  
    >
    install.packages("ggmap")
    ...
    The downloaded binary packages are in
    	/var/folders/yb/7y90lr0d27v5bbmt9_8kf52m0000gn/T//RtmpnsQzxo/downloaded_packages
    Warning message:
    In doTryCatch(return(expr), name, parentenv, handler) :
      unable to load shared object '/Library/Frameworks/R.framework/Resources/modules//R_X11.so':
      dlopen(/Library/Frameworks/R.framework/Resources/modules//R_X11.so, 0x0006): Library not loaded: /opt/X11/lib/libSM.6.dylib
      Referenced from: <05451E21-B5F6-3B2F-9C0F-3EA08D57DC34> /Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/modules/R_X11.so
      Reason: tried: '/opt/X11/lib/libSM.6.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/X11/lib/libSM.6.dylib' (no such file), '/opt/X11/lib/libSM.6.dylib' (no such file), '/Library/Frameworks/R.framework/Resources/lib/libSM.6.dylib' (no such file), '/Library/Java/JavaVirtualMachines/jdk-17.0.1+12/Contents/Home/lib/server/libSM.6.dylib' (no such file)
    
    opened by anujgoyal 0
  • How to hide place names on the map

    How to hide place names on the map

    I have successfully found the place I need on the map, but the map also shows the names of many places in other countries. How do I get a map that does not display the place names, so as to highlight the places I marked. Thank you very much. Below is my R code: myMap <- get_map(location=myLocation, source="stamen", maptype="terrain-background", crop=FALSE) mymarkers <- read.delim('D:/my.txt', header=T) ggmap(myMap) + geom_point(aes(x=Long, y=Lat, color=population), data=mymarkers, size=4) + xlab("Longitude") + ylab("Latitude") + scale_color_manual(values=c("#C88AFF", "#EB746B", '#FCCC00', "#1EB5B8")) + theme(axis.text.x = element_text(color="black", size = 15), axis.text.y = element_text(color = 'black', size = 15), axis.title.x = element_text(color = 'black', size = 18), axis.title.y = element_text(color = 'black', size = 18), legend.position="none")

    opened by Chen-Xinlian 0
  • Feature Request: Flagging - not uniquely geocoded

    Feature Request: Flagging - not uniquely geocoded

    As I'm working with large sets of spatial data, I find that several of my locations are returning as not uniquely geocoded. For cleaning purposes, it would be nice for those that return as such to be flagged and then additional possible addresses to also be returned. See stackoverflow for current manual solution.

    feature request help wanted 
    opened by KLBoles 0
  • Feature Request: progress bar option for ggmap::geocode()

    Feature Request: progress bar option for ggmap::geocode()

    Hello,

    I don't know if this is the appropriate forum to submit feature requests, but...

    Would it be possible to develop a "progress bar" option for ggmap::geocode() and the related ggmap::mutate_geocode(), perhaps something similar to the progress bar returned by tidygeocoder::geocode()? This would help with managing workflow when attempting to geocode batches of addresses. Thanks!

    feature request help wanted 
    opened by ejvalencia 1
  • ggmap has bad test for `base_layer`

    ggmap has bad test for `base_layer`

    Reproducible Example

    Example:

    reprex::reprex({
        library(ggmap)
        library(ggplot2)
        ggmap(get_map(), base_layer = ggplot())
    }, si = TRUE)
    

    This example generates a warning if you run it:

    Warning message:
    In missing(base_layer) || base_layer == "auto" :
      'length(x) = 9 > 1' in coercion to 'logical(1)'
    

    The problem is with the test base_layer == "auto". Since base_layer is a ggplot object, it's a list of length 9, and so that test fails.

    A fix for this is to use

    missing(base_layer || identical(base_layer, "auto")
    

    or perhaps

    missing(base_layer) ||
      (is.character(base_layer) && length(base_layer) == 1) && base_layer == "auto")
    

    instead. (The second test is a bit more lenient: the argument could have names or other attributes and still pass.)

    help wanted 
    opened by dmurdoch 1
  • get_map returns HTTP 400 Bad Request

    get_map returns HTTP 400 Bad Request

    The example in the get_map() documentation produces an error in my environment and it seems I cannot get a map with this function at all. For some reason reprex does not return the same error I see when executing the expression without reprex, so I am pasting directly from my console:

    ggmap::get_map(c(-97.14667, 31.5493))
    Source : https://maps.googleapis.com/maps/api/staticmap?center=31.5493,-97.14667&zoom=10&size=640x640&scale=2&maptype=terrain&language=en-EN&key=xxx-I0PSI858s2k0wWLKygpbWC97Ot74U
    Error in aperm.default(map, c(2, 1, 3)) : 
      invalid first argument, must be an array
    In addition: Warning message:
    In get_googlemap(center = location, zoom = zoom, maptype = maptype,  :
      HTTP 400 Bad Request
    

    I get a similar error when I try get_googlemap() directly:

    ggmap::get_googlemap(c(-97.14667, 31.5493))
    Source : https://maps.googleapis.com/maps/api/staticmap?center=31.5493,-97.14667&zoom=10&size=640x640&scale=2&maptype=terrain&key=xxx-I0PSI858s2k0wWLKygpbWC97Ot74U
    Error in aperm.default(map, c(2, 1, 3)) : 
      invalid first argument, must be an array
    In addition: Warning message:
    In ggmap::get_googlemap(c(-97.14667, 31.5493)) : HTTP 400 Bad Request
    

    At this point I cannot get any maps with these functions. I am registered with Google and e.g. geocode() works properly. Any help with this would be highly appreciated. Many thanks.

    opened by stitam 0
Releases(v3.0.0)
Owner
David Kahle
David Kahle
Python script for writing text on github contribution chart.

Github Contribution Drawer Python script for writing text on github contribution chart. Requirements Python 3.X Getting Started Create repository Put

Steven 0 May 27, 2022
Python library that makes it easy for data scientists to create charts.

Chartify Chartify is a Python library that makes it easy for data scientists to create charts. Why use Chartify? Consistent input data format: Spend l

Spotify 3.2k Jan 01, 2023
A Python package for caclulations and visualizations in geological sciences.

geo_calcs A Python package for caclulations and visualizations in geological sciences. Free software: MIT license Documentation: https://geo-calcs.rea

Drew Heasman 1 Jul 12, 2022
This is a learning tool and exploration app made using the Dash interactive Python framework developed by Plotly

Support Vector Machine (SVM) Explorer This app has been moved here. This repo is likely outdated and will not be updated. This is a learning tool and

Plotly 150 Nov 03, 2022
Displaying plot of death rates from past years in Poland. Data source from these years is in readme

Average-Death-Rate Displaying plot of death rates from past years in Poland The goal collect the data from a CSV file count the ADR (Average Death Rat

Oliwier Szymański 0 Sep 12, 2021
EPViz is a tool to aid researchers in developing, validating, and reporting their predictive modeling outputs.

EPViz (EEG Prediction Visualizer) EPViz is a tool to aid researchers in developing, validating, and reporting their predictive modeling outputs. A lig

Jeff 2 Oct 19, 2022
A tool for creating SVG timelines from simple JSON input.

A tool for creating SVG timelines from simple JSON input.

Jason Reisman 432 Dec 30, 2022
Decision Border Visualizer for Classification Algorithms

dbv Decision Border Visualizer for Classification Algorithms Project description A python package for Machine Learning Engineers who want to visualize

Sven Eschlbeck 1 Nov 01, 2021
Visual Python is a GUI-based Python code generator, developed on the Jupyter Notebook environment as an extension.

Visual Python is a GUI-based Python code generator, developed on the Jupyter Notebook environment as an extension.

Visual Python 564 Jan 03, 2023
Simple addon for snapping active object to mesh ground

Snap to Ground Simple addon for snapping active object to mesh ground How to install: install the Python file as an addon use shortcut "D" in 3D view

Iyad Ahmed 12 Nov 07, 2022
plotly scatterplots which show molecule images on hover!

molplotly Plotly scatterplots which show molecule images on hovering over the datapoints! Required packages: pandas rdkit jupyter_dash ➡️ See example.

150 Dec 28, 2022
Render tokei's output to interactive sunburst chart.

Render tokei's output to interactive sunburst chart.

134 Dec 15, 2022
Streamlit component for Let's-Plot visualization library

streamlit-letsplot This is a work-in-progress, providing a convenience function to plot charts from the Lets-Plot visualization library. Example usage

Randy Zwitch 9 Nov 03, 2022
📊 Charts with pure python

A zero-dependency python package that prints basic charts to a Jupyter output Charts supported: Bar graphs Scatter plots Histograms 🍑 📊 👏 Examples

Max Humber 54 Oct 04, 2022
PyPassword is a simple follow up to PyPassphrase

PyPassword PyPassword is a simple follow up to PyPassphrase. After finishing that project it occured to me that while some may wish to use that option

Scotty 2 Jan 22, 2022
This tool is designed to help administrators get an overview of their Active Directory structure.

This tool is designed to help administrators get an overview of their Active Directory structure. In the group view you can see all elements of an AD (OU, USER, GROUPS, COMPUTERS etc.). In the user v

deexno 2 Oct 30, 2022
A little logger for machine learning research

Blinker Blinker provides a fast dispatching system that allows any number of interested parties to subscribe to events, or "signals". Signal receivers

Reinforcement Learning Working Group 27 Dec 03, 2022
A simple agent-based model used to teach the basics of OOP in my lectures

Pydemic A simple agent-based model of a pandemic. This is used to teach basic principles of object-oriented programming to master students. It is not

Fabien Maussion 2 Jun 08, 2022
A python script to visualise explain plans as a graph using graphviz

README Needs to be improved Prerequisites Need to have graphiz installed on the machine. Refer to https://graphviz.readthedocs.io/en/stable/manual.htm

Edward Mallia 1 Sep 28, 2021