Learn R Programming

SDraw (version 2.1.13)

plotSample: Plot sample and frame

Description

Plot the sample and optionally the frame, background image (terrain), and lattice (if HAL sample).

Usage

plotSample(
  x,
  frame,
  lattice = FALSE,
  bbox = FALSE,
  add = FALSE,
  poly.fill = TRUE
)

Arguments

x

A SpatialPointsDataFrame produced by an SDraw sampling function. For example, as produced by sdraw(frame,n). This object is a standard Spatial PolygonsDataFrame object with additional attributes that record the sampling design.

frame

The sample frame used to draw the sample contained in x. This is either a SpatialPoints*, SpatialLines*, or SpatialPolygons* object.

lattice

Logical. Whether to plot the Halton Lattice if x is a HAL sample.

bbox

Logical. Whether to plot the bounding box if the sample has a bounding box attribute. This generally means x is a HAL or BAS sample. lattice==TRUE sets bbox == TRUE.

add

Logical. Whether to add to an existing plot. See Examples.

poly.fill

Logical. Whether to fill polygons (TRUE) or leave them transparent (FALSE). Only applies to SpatialPolygon* frames.

Value

Nothing (NULL is invisibly returned)

See Also

sdraw

Examples

Run this code
# NOT RUN {
data(WY)
samp <- sdraw(WY, 100, type="HIP", J=c(4,3))
plotSample( samp, WY )
plotSample( samp, WY, lattice=TRUE )

# A map-like background under frame and sample ----
# Requires 'OpenStreetMap' package and internet connection
# }
# NOT RUN {
library(OpenStreetMap)
# 1:convert to Lat-Long
WY.ll <- spTransform(WY, CRS("+init=epsg:4326"))
# 2:Specify bounding box for OpenStreetMap
bb.openmap <- bbox(WY.ll)
ULcoords <- c(bb.openmap[2,2], bb.openmap[1,1])
BRcoords <- c(bb.openmap[2,1], bb.openmap[1,2])
# 3:Fetch image (see 'openmap' help for 'type' parameter)
openMap <- OpenStreetMap::openmap(ULcoords, BRcoords, type = "esri")
# 4:Project background image to original coordinate system
openMap <- OpenStreetMap::openproj(openMap, projection = CRS(proj4string(WY))) 
# 5:plot background
plot(openMap)
# 6:plot frame and sample
plotSample(samp, WY, add=TRUE, poly.fill=FALSE)
# }

Run the code above in your browser using DataLab