Geospatial Modelling Environment

genrandompnts (Generate Random Points)

Generates a sample of random points, with several optional constraint parameters


This tool generates a sample of random points. The command options can be combined in a variety of ways to produce different sampling outcomes. Although this tool is therefore very flexible, care must be taken to ensure that the parameters specified to not result in a problem that has no solution.

The spatial sampling domain can be defined in several ways. If the 'poly' option is used, points are only generated where there are polygons (but this is not a stratified sampling design - see the genstratrandompnts command for that option). If the 'raster' option is used, points are generated within the bounds of the raster. By default, the tool will prohibit points from occurring in NoData cells, although this behaviour can be overridden with the 'pnd' option). Finally, the 'extent' option can be used to define a rectangle within which points are generated. The extent can either be a feature data source (the extent of all the features is used), or as a set of four values that define the minimum x, maximum x, minimum y, and maximum y of the envelope.

The number of points to generate is defined by the 'samples' option. Points are generated using a simple rejection method algorithm: potential points are generated within the rectangular boundary that defines the feature space, raster space, or extent based on a bivariate uniform random distribution. They are then accepted if they conform to the acceptance criteria the user has defined.

The 'mindist' option will ensure that all output points are this minimum distance apart. This value should be specified in coordinate system units (e.g. meters for UTM). If this value is too large then the problem may have no solution. For example. it is not possible to generate 100 points in a square kilometer where the minimum distance between points is 500m.

The 'excl' option can be used to prevent points from being generated within the polygons of this dataset. For example, if you were to generate vegetation sampling points using a reference landcover raster, you might use a polygon layer representing lakes as the exclusion layer to prevent points from occurring in water. Again, there is a risk here of creating an unsolvable problem: if the exclusion polygons cover all of the reference polygons or reference raster then no random points can be generated.

The 'pnd' option only applied when using a raster reference data source (i.e the 'raster' option). It controls whether points can be generated within NoData cells. By default, this is not allowed but you can override this behaviour by setting pnd=FALSE. Note that not all raster formats support NoData values. The grid format does, as do geodatabase rasters. But the GeoTIFF and Imagine formats do not. In these cases there are no NoData values, so the pnd option has no effect. You can determine if your raster has a NoData value by looking at the properties for that layer in ArcMap.

The 'probsurf' option determines whether the raster layer is interpreted as a probability density surface or not. The default is that rasters are not interpreted in this way. If you set probsurf=TRUE, then the cell value is interpreted as the probability of a random point being generated within that cell. The program will automatically rescale the raster values to a probability (by dividing by the maximum value), thus your raster does not necessarily have to be scaled in the range 0-1 prior to running the tool.


genrandompnts([poly], [raster], [extent], sample, out, [mindist], [excl], [pnd], [probsurf], [where]);

[poly]the input reference polygon data source (points are only generated within polygons)
[raster]the input reference raster data source
[extent]the input reference data source, or coordinates, that defines the extent within which points are generated (without regard to the distribution of features or raster values within that extent)
samplethe sample size
outthe output point data source
[mindist]if specified, points are prevented from occurring within this minimum distance of each other (specified in coordinate system units of the reference layer); this option can be dangerous - see the help documentation for details
[excl]the polygon data source containing exclusion polygons: points are prevented from being generated within these polygons; this option can be dangerous - see the help documentation for details
[pnd](TRUE/FALSE) in the case of raster data sources, if TRUE points are prevented from being placed in NoData cells (i.e. pnd=prevent NoData) (default=TRUE)
[probsurf](TRUE/FALSE and applies only to the raster argument) if TRUE the raster is treated as a probability surface (see help documentation for further details) (default=FALSE)
[where](only applies to the 'poly' option) the filter/selection statement that will be applied to the feature class to identify a subset of features to process


genrandompnts(poly="C:\data\fields.shp", sample=1000, out="C:\data\samplepnts.shp");

genrandompnts(poly="C:\data\fields.shp", sample=1000, out="C:\data\samplepnts.shp", mindist=50, excl="C:\data\lakes.shp");

genrandompnts(raster="C:\data\landcov", sample=5000, out="C:\data\samplepnts.shp");

genrandompnts(raster="C:\data\rsf", sample=500, out="C:\data\samplepnts.shp", probsurf=TRUE);

genrandompnts(extent="C:\data\roads.shp", sample=50000, out="C:\data\samplepnts.shp");

genrandompnts(extent=c(346000,450600,4956300,5204300), sample=100000, out="C:\data\samplepnts.shp");


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

Tips on how to use this interface efficiently 


Open Source GIS

Copyright © 2001-2014 Hawthorne L. Beyer, Ph.D., Spatial Ecology LLC    Connect on LinkedIn