Skip to main content
added 34 characters in body
Source Link
Taras
  • 34k
  • 4
  • 73
  • 148

Another option is to use the "Random selection" tool for selecting N randomselecting N random features features.

import processing
from qgis.utils import iface

layer = iface.activeLayer()

processing.run("qgis:randomselection", {
                    'INPUT' : layer,
                    'METHOD' : 0,
                    'NUMBER' : 5 -- specify a number here
                    })

To get more information about this algorithm, please run the following command processing.algorithmHelp("qgis:randomselection") in the Python Console (Ctrl+Alt+P).


References:

Another option is to use the "Random selection" tool for selecting N random features.

import processing

layer = iface.activeLayer()

processing.run("qgis:randomselection", {
                    'INPUT' : layer,
                    'METHOD' : 0,
                    'NUMBER' : 5 -- specify a number here
                    })

To get more information about this algorithm, please run the following command processing.algorithmHelp("qgis:randomselection") in the Python Console (Ctrl+Alt+P).


References:

Another option is to use the "Random selection" tool for selecting N random features.

import processing
from qgis.utils import iface

layer = iface.activeLayer()

processing.run("qgis:randomselection", {
                    'INPUT' : layer,
                    'METHOD' : 0,
                    'NUMBER' : 5 -- specify a number here
                    })

To get more information about this algorithm, please run the following command processing.algorithmHelp("qgis:randomselection") in the Python Console (Ctrl+Alt+P).


References:

Source Link
Taras
  • 34k
  • 4
  • 73
  • 148

Another option is to use the "Random selection" tool for selecting N random features.

import processing

layer = iface.activeLayer()

processing.run("qgis:randomselection", {
                    'INPUT' : layer,
                    'METHOD' : 0,
                    'NUMBER' : 5 -- specify a number here
                    })

To get more information about this algorithm, please run the following command processing.algorithmHelp("qgis:randomselection") in the Python Console (Ctrl+Alt+P).


References: