dkahle / dkahle/ggmap

a

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

Description

## Reproducible Example

I wonder if I've got something wrong here. I'm using [this polygon](https://data.ca.gov/dataset/e212e397-1277-4df3-8c22-40721b095f33/resource/b0007416-a325-4777-9295-368ea6b710e6/download/ca-county-boundaries.zip) to make CA counties, reading it in as an sf object, converting it to SpatialPolygonsDataFrame to solve alignment issues with the basemap, but cannot fill the polygons based on the "Freq" column, which contains integers in this example. I receive the error 'object not found'

```r
reprex::reprex({
library(sf)
library(ggmap)
Counties.sf <- read_sf("CA_Counties_TIGER2016.shp") #read in shapefile from WD as an sf object
Counties.sf$Freq <- sample(10, size=nrow(Counties.sf), replace=TRUE) #assign random #s 1-10 to each county
Counties.sf <- st_transform(Counties.sf, 4326) #set correct CRS
bbox.sf<-unname(st_bbox(Counties.sf)) #create bbox for basemap
my.stamen<- get_stamenmap(bbox=bbox.sf, maptype='terrain-background', zoom=8) #call basemap here
Counties.sp<-as_Spatial(Counties.sf) #converting data type to avoid poor alignment with geom_sf
ggmap(my.stamen)+
geom_polygon(data=Counties.sp, aes(x=long, y=lat, group=group, fill=factor(Freq)))
#map will not run, does not recognize the Freq attribute
}, si = TRUE)
```

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.