dkahle / dkahle/ggmap

ggmap does not seem to work with ggplot2::geom_sf

Open
#160 22 comments 8 reactions 0 assignees View on GitHub
question
Dominant language
R
Stars
778
Forks
234
PR merge metrics
No merged PRs in 30d

Description

This might be an issue with `geom_sf` or an issue with how ggmap sets up the dataframe for ggmap or something else. I'm not sure, so I'm submitting it here and to [`ggplot2`](https://github.com/tidyverse/ggplot2/issues/2130)
``` r
library(sf)
library(ggmap)

nc_map <- get_map(c(-81, 35), zoom = 6)
#> Map from URL : http://maps.googleapis.com/maps/api/staticmap?center=35,-81&zoom=6&size=640x640&scale=2&maptype=terrain&language=en-EN&sensor=false
ggmap(nc_map)
```
![](http://i.imgur.com/JaCRzUG.png)

``` r
nc <- st_read(system.file("shape/nc.shp", package="sf"))
ggplot(nc) + geom_sf()
```
![](http://i.imgur.com/rS13QWT.png)

``` r
ggmap(nc_map) + geom_sf(data = nc)
#> Error in FUN(X[[i]], ...): object 'lon' not found
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.