如何将coord_map与annotation_raster结合起来?

时间:2016-12-11 12:22:31

标签: r ggplot2 maps

我想创建一个包含自定义图像显示点的地图。

# Map with this data http://biogeo.ucdavis.edu/data/gadm2.8/rds/DEU_adm0.rds
map <- readRDS((".../DEU_adm0.rds")
map.f <- fortify(map)

# Coordinates
dat <- structure(list(Lat = c(53.0024118, 52.2263017), Lon = c(7.2665689, 
                                                                   10.7678071)), .Names = c("Lat", "Lon"), row.names = 1:2, class = "data.frame")
# Custom Image
img <- readPNG(system.file("img", "Rlogo.png", package="png"))

我已尝试在this answer中发布的代码:

ggplot(map.f) +
  geom_polygon(aes(x = long, y = lat, group = group), 
               fill = "white", colour = "black") +
  coord_map() +
  mapply(function(xx, yy) 
    annotation_raster(img, xmin=xx-1, xmax=xx+1, ymin=yy-0.2, ymax=yy+0.2),
    dat$Lon, dat$Lat) 

但是,我收到以下错误:

  

annotation_raster仅适用于笛卡尔坐标

我该怎么做?

0 个答案:

没有答案