> Script Details
Random Sample / Points-in-Polygon (updated)
report inappropriate content
Dr Michael Sawada
Aug 20 2004
Status of work
ArcScripts is intended for the free exchange of scripts and tools related to ESRI software products. Please alert the moderator if this script is a demo, trial-version, or an advertisement for a retail product.
Updated Aug 20: compatible with ArcGIS 9.0 by removal of references to esriCore.
Updated on May 16: Now creates shapefiles with one record for each random point about 100 times faster. This is the default (previously a multipoint was generated by default and the user had to manually opt for a single point shapefile)
Updated on April 26: Fixed random number seed generator.
This program creates a set of n random points within a selected polygon (multipart or single part) within a polygon layer. A shapefile is created in the DataFrame projection (Coordinate System) and is automatically added as a layer. It's use is simple:
1. Select a polygon layer
2. Select a single polygon in that layer
3. Run the program (detailed in the readme.pdf).
4. Choose how many points are to be placed in the polygon.
5. Optionally specify random z-values to associate with each point within a user-specified range.
6. Choose to output the shapefile as either a multipoint or point shapefile.
• Outputting as a multipoint creates one record in the feature table containing all the n random points. Output as a single point shapefile has one record for each of the n-random points.
All points are ZAware.
If output as a single point shapefile then there is a field of z-values appended to the feature table.
See the readme.pdf for notes on the computation.
This program won't install random points in every polygon in the layer but only for selected polygons.
Written in Visual Basic for Applications (VBA) and requires ArcGIS 8.1. A single user form is to be associated with a UIControlButton. This procedure is in the readme.pdf file within the zip archive.