我无法用栅格数据(来自 ggplot2 geom_tile)覆盖地图(来自地图包)?
library(ggplot2)
library(ggmap)
library(maps)
library(mapdata)
这是我的数据
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
这是地图
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)
我无法将我的栅格数据与地图结合起来..
ggplot() + geom_raster(data = mydata, aes(longitude,latitude, fill =
seasonalTavg_Ens))
感谢您的任何见解!我愿意使用 geom_raster 或 geom_tile。