I'm having trouble overlaying a map (from map package) with raster data (from ggplot2 geom_tile)?
library(ggplot2)
library(ggmap)
library(maps)
library(mapdata)
Here's my data
mydata = read.csv("Seasonal_Temp.csv")
head(mydata)
> head(mydata)
longitude latitude seasonalTavg_Ens
1 -111.688 40.500 3.435
2 -111.688 40.563 3.183
3 -111.688 40.625 3.488
4 -111.625 40.500 3.437
5 -111.625 40.563 3.395
6 -111.625 40.625 3.429
Here's the map
states <- map_data("state")
dim(states)
ut_df <- subset(states, region == "utah")
head(ut_df)
counties <- map_data("county")
ut_county <- subset(counties, region == "utah")
head(ut_county)
area <- subset(ut_county, subregion %in% c("summit", "wasatch", "salt lake",
"utah"))
area_map <- ggplot(data = area, mapping = aes(x = long, y = lat, group =
group)) +
coord_fixed(1.3) +
geom_polygon(color = "black", fill = "white")
area_map + theme_bw()
area_map + coord_fixed(xlim = c(-111.438, -111.688), ylim = c(40.5, 40.625),
ratio = 1.3)
I'm not able to combine my raster data with the map..
ggplot() + geom_raster(data = mydata, aes(longitude,latitude, fill =
seasonalTavg_Ens))
Thank you for any insights! I'm open to using geom_raster or geom_tile.