I'm trying to generate a shapefile of random points using FID from the attribute table. My attribute table has 800,000 features and I only need a sample of 240.
Is there a way to do it in arcpy or in the field calculator?
-
I suspect that this will be a duplicate of at least one question from gis.stackexchange.com/questions/tagged/randomPolyGeo– PolyGeo ♦2015年05月21日 08:53:33 +00:00Commented May 21, 2015 at 8:53
2 Answers 2
The easiest way to do this is to use Python (can be run in Python window in ArcMap if you are not familiar with any IDE or Python prompt):
import random
print random.sample(range(800000), 240)
This will give you a list of unique value (with no repeating), such as [1,2,5,12]
. Now you can use the Select By Attributes in ArcMap and select the features which have their FIDs in the list (just copy/paste the contents of the list):
FID in (1,2,5,12)
Right-click the layer in the TOC and choose Export data. Only selected features will be exported into a new shapefile.
-
In "print random.sample(range(800000), 240)" 80000 should be replaced by the feature number you have in that feature class and 240 will be replaced by the number of sample you want to draw from that space. I think other wise it would be biased sampling though all drawn samples are in the range of your records(features).Learner– Learner2015年05月25日 05:13:53 +00:00Commented May 25, 2015 at 5:13
You can use Hawth Analysis Tool . It is very easy to use . You need to specify the number of sample to be drawn. Installation process in arcgis is here. Just select and export the layer. demo
You can also use arcscirpt at here
Explore related questions
See similar questions with these tags.