Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/83.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
从wrld_Simp全球地图中删除南极洲_R_Ggplot2_Raster - Fatal编程技术网

从wrld_Simp全球地图中删除南极洲

从wrld_Simp全球地图中删除南极洲,r,ggplot2,raster,R,Ggplot2,Raster,我在ggplots中使用wrld_Simp作为背景,并希望删除南极洲。但我不知道怎么做。谢谢你的帮助 library(maptools) data("wrld_simpl") plot(wrld_simpl) wrld_simpl[wrld_simpl@data$ISO3 != "ATA"] 脚本示例: library(ggplot2) p <- ggplot() + geom_polygon(data = wrld_simpl, aes(x = long, y = lat, gr

我在ggplots中使用wrld_Simp作为背景,并希望删除南极洲。但我不知道怎么做。谢谢你的帮助

library(maptools)
data("wrld_simpl")
plot(wrld_simpl)
wrld_simpl[wrld_simpl@data$ISO3 != "ATA"]
脚本示例:

library(ggplot2)

p <- ggplot() +
  geom_polygon(data = wrld_simpl, aes(x = long, y = lat, group = group), colour = "black", fill = "grey") 
p <- p + geom_raster(data = df , aes(x = x, y = y, fill = layer))
p <- p + coord_equal() +  theme_bw()  + labs(x="", y="") 
p <- p + scale_fill_gradientn(colours = rev(terrain.colors(10)))
p <- p + labs(list(title = ""))  
p
p <- ggplot() +
  geom_polygon(data = wrld_simpl[wrld_simpl@data$UN!="10",], aes(x = long, y = lat, group = group), colour = "black", fill = "grey") 
p <- p + geom_raster(data = df , aes(x = x, y = y, fill = layer))
p <- p + coord_equal() +  theme_bw()  + labs(x="", y="") 
p <- p + scale_fill_gradientn(colours = rev(terrain.colors(10)))
p <- p + labs(list(title = ""))  
p
库(ggplot2)

p我没有特别使用该包,但是
ggplot2::map_data()
maps
包调用maps。然后您可以像使用任何数据帧一样使用
dplyr::filter
对其进行子集划分

library(dplyr)
library(maps)
library(ggplot2)

map_data("world") %>% 
  filter(region != "Antarctica") %>% 
  ggplot(aes(long, lat, group = paste(region, group))) + 
  geom_polygon() + 
  coord_fixed()

这里有一个去除南极洲的解决方案(相应的联合国代码=10)

脚本示例:

library(ggplot2)

p <- ggplot() +
  geom_polygon(data = wrld_simpl, aes(x = long, y = lat, group = group), colour = "black", fill = "grey") 
p <- p + geom_raster(data = df , aes(x = x, y = y, fill = layer))
p <- p + coord_equal() +  theme_bw()  + labs(x="", y="") 
p <- p + scale_fill_gradientn(colours = rev(terrain.colors(10)))
p <- p + labs(list(title = ""))  
p
p <- ggplot() +
  geom_polygon(data = wrld_simpl[wrld_simpl@data$UN!="10",], aes(x = long, y = lat, group = group), colour = "black", fill = "grey") 
p <- p + geom_raster(data = df , aes(x = x, y = y, fill = layer))
p <- p + coord_equal() +  theme_bw()  + labs(x="", y="") 
p <- p + scale_fill_gradientn(colours = rev(terrain.colors(10)))
p <- p + labs(list(title = ""))  
p
p