Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/65.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 在ggplot上打印形状文件 库(光栅) 图书馆(GG2) map.shp_R_Ggplot2_Shapefile_Sp - Fatal编程技术网

R 在ggplot上打印形状文件 库(光栅) 图书馆(GG2) map.shp

R 在ggplot上打印形状文件 库(光栅) 图书馆(GG2) map.shp,r,ggplot2,shapefile,sp,R,Ggplot2,Shapefile,Sp,我认为有多种方法可以实现这一点,但一种简单的方法是使用cowplot和ggdraw: 我正在使用sf以及geom\u sf的开发版本ggplot2,可在devtools::install\u github(“hadley/ggplot2”) require(ggplot2) 要求(整流罩图) 要求(sf) 需要(光栅) map.shp%st_as_sf() 是的。这就是我试图实现的目标。谢谢 library(raster) library(ggplot2) map.shp <- getD

我认为有多种方法可以实现这一点,但一种简单的方法是使用
cowplot
ggdraw

我正在使用
sf
以及
geom\u sf
的开发版本
ggplot2
,可在
devtools::install\u github(“hadley/ggplot2”)

require(ggplot2)
要求(整流罩图)
要求(sf)
需要(光栅)
map.shp%st_as_sf()

是的。这就是我试图实现的目标。谢谢
library(raster)
library(ggplot2)

map.shp <- getData('GADM', country='FRA', level=1)

plot(map.shp)
ggplot(mtcars, aes(x = hp, y = disp)) + geom_point()
require(ggplot2)
require(cowplot)
require(sf)
require(raster)

map.shp <- getData('GADM', country='FRA', level=1) %>% st_as_sf()



plot.cars <- ggplot(mtcars, aes(x = hp, y = disp)) + geom_point()
plot.map <- ggplot() + geom_sf(data=map.shp)

inset_map <- ggdraw() +
  draw_plot(plot.cars, 0, 0, 1, 1)+
  draw_plot(plot.map, 0.5, 0.52, 0.5, 0.4)