spaMM (version 2.1.6)

seaMask: Masks of seas or lands

Description

These convenient masks can be added to maps of (parts of) the world to mask map information for these areas.

Usage

data(seaMask)
data(landMask)
data(worldcountries)
data(oceanmask)

Arguments

Format

seaMask and landMask are data frames with two variables, x and y for longitude and latitude. Its contents are suitable for use with polypath: they define different polygones, each separated by a row of NAs.

worldcountries and oceanmask are SpatialPolygonsDataFrame objects.

Details

A land mask can be produced out of worldcountries by filling the countries (i.e. fill="black" in the code for country.layer in the Examples in http://kimura.univ-montp2.fr/~rousset/spaMM/example_raster.html.

worldcountries and oceanmask were created from public domain shapefiles downloaded from www.naturalearth.com on 2015/10/21. These are suitable for plots involving geographical projections not available through map, and more generally for raster plots. Only the lowest-resolution data are included in spaMM, to minimize the size of the package archive, but higher-resolution files are available on www.naturalearth.com, from where they can be loaded as shown in the examples. worldcountries had to be edited for non-ASCII characters before inclusion in spaMM: worldcountries@data$formal_fr was removed and the “C<U+00F4>te d'Ivoire” level of some factor variables was renamed.

seaMask and landMask were created from the world map in the maps package. polypath requires polygons, while map(interior=FALSE,plot=FALSE) returns small segments. landMask is the result of reconnecting the segments into full coastlines of all land blocks.

See Also

http://kimura.univ-montp2.fr/~rousset/spaMM/example_raster.html for uses of worldcountries and oceanmask

Examples

Run this code
# NOT RUN {
if (spaMM.getOption("example_maxtime")>0.9) {

data(seaMask)
## plot of predictions of behaviour for a land bird:
if (require(maps)){
 data(blackcap)
 bfit <- corrHLfit(migStatus ~ means+ Matern(1|longitude+latitude),data=blackcap,
                  HLmethod="ML",
                  ranFix=list(lambda=0.5537,phi=1.376e-05,rho=0.0544740,nu=0.6286311))
 ## We add small masks to the points on small islands to see the predictions there
 ll <- blackcap[,c("longitude","latitude")]
 pointmask <- function(xy,r=1,npts=12) {
  theta <- 2*pi/npts *seq(npts)
  hexas <- lapply(seq(nrow(xy)),function(li){
    p <- as.numeric(xy[li,])
    hexa <- cbind(x=p[1]+r*cos(theta),y=p[2]+r*sin(theta))
    rbind(rep(NA,2),hexa) ## inital NA before each polygon
  })
  do.call(rbind,hexas)
 }
 pmasks <- pointmask(ll[c(2,4,5,6,7),],r=0.8) ## small islands only
 filled.mapMM(bfit,add.map=TRUE,
             plot.title=title(main="Inferred migration propensity of blackcaps",
                               xlab="longitude",ylab="latitude"),
             decorations=quote(points(pred[,coordinates],cex=1,pch="+")),
             plot.axes=quote({axis(1);axis(2);
                        polypath(rbind(seaMask,pmasks),border=FALSE,
                                 col="grey", rule="evenodd")
             }))
}
}

# }
# NOT RUN {
# All shape files can be found here: http://www.naturalearthdata.com/downloads/
# Once downloaded, they can be loaded into R by
if (require("rgdal", quietly = TRUE)) {
  worldcountries <- readOGR("ne_110m_admin_0_countries_lakes.shp",
                           layer="ne_110m_admin_0_countries_lakes")
}
# }

Run the code above in your browser using DataCamp Workspace