GME

Geospatial Modelling Environment

r.sample

Creates a random or stratified random sample of records in a feature table

Description

This tool uses the R sample command to create a random or stratified random sample of records in a feature attribute table. Sampled records are coded with a 1 in a field in the attribute table, and all other records are 0. By default this field is named RNDSAMP, although you can specify any other field names using the 'field' parameter. This tool will not automatically overwrite an existing field unless you explicitly specify 'overwrite=TRUE'. Note that this tool does not alter the selection of features in ArcMap.

The number of features that are sampled can be specified as a count using the 'size' parameter, or as a proportion of the total number of records (or the number of records in that stratum in the case of stratified random sampling) using the 'proportion' parameter. If you specify a sample that is greater than the number of available records then a warning message will be generated, but all available features will be marked as being sampled.

It is a stochastic algorithm so is unlikely to yield exactly the same results each time you run it. The 'verbose' option can be useful for checking that this algorithm is working correctly.

The output comma delimited text file this command creates contains the summary of the statistical output of the tool: the number of records in each group, the within group sums of squares, and the coordinates of the centres of the clusters in n-dimensional space.

For further information on the R sample command, type '? sample' at the R prompt, and press Enter.

This command is driven by R. Type 'citation' to see the suggested citation for R.

Syntax

r.sample(in, size/proportion, [field], [stratified], [overwrite], [verbose], [where]);

inthe input feature data source
sizethe number of features to sample (integer); takes precedence over 'proportion' if both are specified
proportionthe proportion of features to sample (0.0-1.0)
[field]the field that will record the selection (if it exists the program will stop, but see the overwrite option below) (default=RNDSAMP)
[stratified]the field that describes the strata in the data (typically an integer field representing unique group ID's); the count or proportion options are applied at the level of the strata
[overwrite](TRUE/FALSE): if TRUE, if the output field already exists it will automatically be deleted and recreated, if FALSE the program stops with an error message if the field exists (default=FALSE)
[verbose](TRUE/FALSE): if TRUE, reports the sequence of sampled record numbers in the output window (default=FALSE)
[where]the selection statement that will be applied to the feature data source to identify a subset of features to process (see full Help documentation for further details)

Example

r.sample(in="C:\data\plots.shp", size=100, overwrite=TRUE);

r.sample(in="C:\data\locs.shp", field="STRSEL", proportion=0.1, stratified="ANIMALID", verbose=TRUE);


Messages

Please consider making a purchase to support the continued development of these tools  Read more...

An apology for failing to respond to correspondence in recent months  Read more...

Tips on how to use this interface efficiently  Read more...

Sign up for the newsletter if you wish to receive notification of updates, new functionality, bug fixes, and other related news

Links

Open Source GIS

Copyright © 2001-2010 Hawthorne L. Beyer, Spatial Ecology LLC