R 我怎样才能在澳大利亚地图上遮住海洋

R 我怎样才能在澳大利亚地图上遮住海洋,r,map,plot,mask,R,Map,Plot,Mask,我想在一张澳大利亚的地图上遮住海洋 以下是我的出发点: library(maps) library(mapdata) image(x=110:155, y =-40:-10, z = outer(1:45, 1:30, "+"), xlab = "lon", ylab = "lat") 然后,按照此处发布的解决方案()设置polypath: outline <- map("worldHires", plot=FALSE) # returns a list of x/y coords

我想在一张澳大利亚的地图上遮住海洋

以下是我的出发点:

library(maps)
library(mapdata)
image(x=110:155, y =-40:-10, z = outer(1:45, 1:30, "+"), 
  xlab = "lon", ylab = "lat")
然后,按照此处发布的解决方案()设置polypath:

outline <- map("worldHires", plot=FALSE) # returns a list of x/y coords
xrange <- range(outline$x, na.rm=TRUE) # get bounding box
yrange <- range(outline$y, na.rm=TRUE)
xbox <- xrange + c(-2, 2)
ybox <- yrange + c(-2, 2)
# create the grid path in the current device
polypath(c(outline$x, NA, c(xbox, rev(xbox))),
 c(outline$y, NA, rep(ybox, each=2)),
 col="light blue", rule="evenodd")][1]

outline感谢此解决方案的R-help邮件列表():

明确说明区域名称(“澳大利亚”):


感谢此解决方案的R-help邮件列表():

明确说明区域名称(“澳大利亚”):

map(“worldHires”,regions=“australia”,bg=“light blue”,fill=TRUE,xlim=c(110155),ylim=c(-40,-10))
map(“worldHires”,regions=“australia”,bg=“light blue”,fill=TRUE,xlim=c(110155),ylim=c(-40,--10))是否足够?
library(maps)
library(mapdata)

image(x=110:155, y =-40:-10, z = outer(1:45, 1:30, "+"),
  xlab = "lon", ylab = "lat")
outline <- map("worldHires", regions="Australia", exact=TRUE, plot=FALSE) # returns a list of x/y coords
xrange <- range(outline$x, na.rm=TRUE) # get bounding box
yrange <- range(outline$y, na.rm=TRUE)
xbox <- xrange + c(-2, 2)
ybox <- yrange + c(-2, 2)
subset <- !is.na(outline$x)
# create the grid path in the current device
polypath(c(outline$x[subset], NA, c(xbox, rev(xbox))),
  c(outline$y[subset], NA, rep(ybox, each=2)),
  col="light blue", rule="evenodd")