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?


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
    Commented 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.