Learn R Programming

spcosa (version 0.3-2)

spsample-methods: Spatial Sampling of Compact Strata

Description

Methods for sampling in compact strata.

Arguments

See Also

stratify for stratification, spsample for other types of spatial sampling, and estimate for inference.

Examples

Run this code
# Note: the example below requires the 'rgdal'-package.
# You may consider the 'maptools'-package as an alternative
if (require(rgdal)) {

    # read a vector representation of the `Farmsum' field
    shpFarmsum <- readOGR(
        dsn = system.file("maps", package = "spcosa"),
        layer = "farmsum"
    )

    # stratify `Farmsum' into 50 strata
    # NB: increase argument 'nTry' to get better results
    set.seed(314)
    myStratification <- stratify(shpFarmsum, nStrata = 50, nTry = 1)

    # sample two sampling units per stratum
    mySamplingPattern <- spsample(myStratification, n = 2)

    # plot the resulting sampling pattern on
    # top of the stratification
    plot(myStratification, mySamplingPattern)

}

Run the code above in your browser using DataLab