I am using QGIS 2.18.11 and need to select 250 points from the existing points in a map. I know that I can randomly select points through Vector> Research Tools> Random Selection but I don't know how to make it "reproducible" (replicable). I don't know much about Python.
For making reproducible a random selection you need to use in a PyQGIS script, for instance, 'random.seed' method from numpy. Assuming that you have 10.000 points in your layer, next code select same 250 points each time is running (with seed equal 0).
import numpy as np np.random.seed(0) random_numbers =  n = 0 while (n < 250): number = np.random.randint(0,10000) if number not in random_numbers: random_numbers.append(number) n = len(random_numbers) print random_numbers registry = QgsMapLayerRegistry.instance() Points = registry.mapLayersByName('Points') feats = [ feat for feat in Points.getFeatures() ] epsg = Points.crs().postgisSrid() selected_features =  for number in random_numbers: selected_features.append(feats[number]) uri = "Point?crs=epsg:" + str(epsg) + "&field=id:integer""&index=yes" mem_layer = QgsVectorLayer(uri, 'selected_points', 'memory') prov = mem_layer.dataProvider() for i, feat in enumerate(selected_features): feat.setAttributes([i]) prov.addFeatures(selected_features) registry.instance().addMapLayer(mem_layer)
I tried it out with next point layer having 10.000 points:
After running the script 5 times, it can be observed that selected points were always the same: