You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I wonder if I've got something wrong here. I'm using this polygon 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'
reprex::reprex({
library(sf)
library(ggmap)
Counties.sf<- read_sf("CA_Counties_TIGER2016.shp") #read in shapefile from WD as an sf objectCounties.sf$Freq<- sample(10, size=nrow(Counties.sf), replace=TRUE) #assign random #s 1-10 to each countyCounties.sf<- st_transform(Counties.sf, 4326) #set correct CRSbbox.sf<-unname(st_bbox(Counties.sf)) #create bbox for basemap my.stamen<- get_stamenmap(bbox=bbox.sf, maptype='terrain-background', zoom=8) #call basemap hereCounties.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)
The text was updated successfully, but these errors were encountered:
acookpb
changed the title
Unable to code map via "fill=" in aes() function with sp objects
a
Jan 11, 2023
Reproducible Example
I wonder if I've got something wrong here. I'm using this polygon 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'
The text was updated successfully, but these errors were encountered: