Skip to main content
deleted 4 characters in body
Source Link
Matthias Kuhn
  • 28.2k
  • 3
  • 89
  • 130

You can simply do:

features = l.getFeatures('"Counties" = \'Norwich\'')

The QGIS expression engine is also able to do this using the QgsFeatureRequest.setFilterExpression( unicode str) method (Since QGIS 2.2)

request = QgsFeatureRequest().setFilterExpression( u'"Counties"'"Counties" = \'Norwich\'' )
it = l.getFeatures( request )

Starting with QGIS 2.10 it is even possible that filtering in such a way will give you some extra performance over other types of filtering (like python implementations).

Basically this applies if the following three conditions are met:

  • You are using a layer with the postgis provider At the moment (2.16) many more than just postgis provider implement this (spatialite, ogr, oracle...).
  • Your expression is not overly complicated (things like >, =, IN, NOT NULL ... are supported)
  • You have enabled this feature in Settings > Options > Data Sources > Data Source Handling > Execute expression on postgres server-side
  • The performance benefit is optimal with appropriate indexes on the database tables

With QGIS 3.0 it is even possible to simply do

features = l.getFeatures('"Counties" = \'Norwicth\'')

The QGIS expression engine is able to do this using the QgsFeatureRequest.setFilterExpression( unicode ) method (Since QGIS 2.2)

request = QgsFeatureRequest().setFilterExpression( u'"Counties" = \'Norwich\'' )
it = l.getFeatures( request )

Starting with QGIS 2.10 it is even possible that filtering in such a way will give you some extra performance over other types of filtering (like python implementations).

Basically this applies if the following three conditions are met:

  • You are using a layer with the postgis provider At the moment (2.16) many more than just postgis provider implement this (spatialite, ogr, oracle...).
  • Your expression is not overly complicated (things like >, =, IN, NOT NULL ... are supported)
  • You have enabled this feature in Settings > Options > Data Sources > Data Source Handling > Execute expression on postgres server-side
  • The performance benefit is optimal with appropriate indexes on the database tables

With QGIS 3.0 it is even possible to simply do

features = l.getFeatures('"Counties" = \'Norwicth\'')

You can simply do:

features = l.getFeatures('"Counties" = \'Norwich\'')

The QGIS expression engine is also able to do this using the QgsFeatureRequest.setFilterExpression(str) method (Since QGIS 2.2)

request = QgsFeatureRequest().setFilterExpression( '"Counties" = \'Norwich\'' )
it = l.getFeatures( request )

Starting with QGIS 2.10 it is even possible that filtering in such a way will give you some extra performance over other types of filtering (like python implementations).

Basically this applies if the following three conditions are met:

  • You are using a layer with the postgis provider At the moment (2.16) many more than just postgis provider implement this (spatialite, ogr, oracle...).
  • Your expression is not overly complicated (things like >, =, IN, NOT NULL ... are supported)
  • You have enabled this feature in Settings > Options > Data Sources > Data Source Handling > Execute expression on postgres server-side
  • The performance benefit is optimal with appropriate indexes on the database tables
added 132 characters in body
Source Link
Matthias Kuhn
  • 28.2k
  • 3
  • 89
  • 130

The QGIS expression engine is able to do this using the QgsFeatureRequest.setFilterExpression( unicode ) method (Since QGIS 2.2)

request = QgsFeatureRequest().setFilterExpression( u'"Counties" = \'Norwich\'' )
it = l.getFeatures( request )

Starting with QGIS 2.10 it is even possible that filtering in such a way will give you some extra performance over other types of filtering (like python implementations).

Basically this applies if the following three conditions are met:

  • You are using a layer with the postgis provider At the moment (2.16) many more than just postgis provider implement this (spatialite, ogr, oracle...).
  • Your expression is not overly complicated (things like >, =, IN, NOT NULL ... are supported)
  • You have enabled this feature in Settings > Options > Data Sources > Data Source Handling > Execute expression on postgres server-side
  • The performance benefit is optimal with appropriate indexes on the database tables

With QGIS 23.180 it is even possible to simply do

features = l.getFeatures('"Counties" = \'Norwicth\'')

The QGIS expression engine is able to do this using the QgsFeatureRequest.setFilterExpression( unicode ) method (Since QGIS 2.2)

request = QgsFeatureRequest().setFilterExpression( u'"Counties" = \'Norwich\'' )
it = l.getFeatures( request )

Starting with QGIS 2.10 it is even possible that filtering in such a way will give you some extra performance over other types of filtering (like python implementations).

Basically this applies if the following three conditions are met:

  • You are using a layer with the postgis provider At the moment (2.16) many more than just postgis provider implement this (spatialite, ogr, oracle...).
  • Your expression is not overly complicated (things like >, =, IN, NOT NULL ... are supported)
  • You have enabled this feature in Settings > Options > Data Sources > Data Source Handling > Execute expression on postgres server-side
  • The performance benefit is optimal with appropriate indexes on the database tables

With QGIS 2.18 it is even possible to simply do

features = l.getFeatures('"Counties" = \'Norwicth\'')

The QGIS expression engine is able to do this using the QgsFeatureRequest.setFilterExpression( unicode ) method (Since QGIS 2.2)

request = QgsFeatureRequest().setFilterExpression( u'"Counties" = \'Norwich\'' )
it = l.getFeatures( request )

Starting with QGIS 2.10 it is even possible that filtering in such a way will give you some extra performance over other types of filtering (like python implementations).

Basically this applies if the following three conditions are met:

  • You are using a layer with the postgis provider At the moment (2.16) many more than just postgis provider implement this (spatialite, ogr, oracle...).
  • Your expression is not overly complicated (things like >, =, IN, NOT NULL ... are supported)
  • You have enabled this feature in Settings > Options > Data Sources > Data Source Handling > Execute expression on postgres server-side
  • The performance benefit is optimal with appropriate indexes on the database tables

With QGIS 3.0 it is even possible to simply do

features = l.getFeatures('"Counties" = \'Norwicth\'')
added 132 characters in body
Source Link
Matthias Kuhn
  • 28.2k
  • 3
  • 89
  • 130

The QGIS expression engine is able to do this using the QgsFeatureRequest.setFilterExpression( unicode ) method (Since QGIS 2.2)

request = QgsFeatureRequest().setFilterExpression( u'"Counties" = \'Norwich\'' )
it = l.getFeatures( request )

Starting with QGIS 2.10 it is even possible that filtering in such a way will give you some extra performance over other types of filtering (like python implementations).

Basically this applies if the following three conditions are met:

  • You are using a layer with the postgis provider At the moment (2.16) many more than just postgis provider implement this (spatialite, ogr, oracle...).
  • Your expression is not overly complicated (things like >, =, IN, NOT NULL ... are supported)
  • You have enabled this feature in Settings > Options > Data Sources > Data Source Handling > Execute expression on postgres server-side
  • The performance benefit is optimal with appropriate indexes on the database tables

With QGIS 2.18 it is even possible to simply do

features = l.getFeatures('"Counties" = \'Norwicth\'')

The QGIS expression engine is able to do this using the QgsFeatureRequest.setFilterExpression( unicode ) method (Since QGIS 2.2)

request = QgsFeatureRequest().setFilterExpression( u'"Counties" = \'Norwich\'' )
it = l.getFeatures( request )

Starting with QGIS 2.10 it is even possible that filtering in such a way will give you some extra performance over other types of filtering (like python implementations).

Basically this applies if the following three conditions are met:

  • You are using a layer with the postgis provider At the moment (2.16) many more than just postgis provider implement this (spatialite, ogr, oracle...).
  • Your expression is not overly complicated (things like >, =, IN, NOT NULL ... are supported)
  • You have enabled this feature in Settings > Options > Data Sources > Data Source Handling > Execute expression on postgres server-side
  • The performance benefit is optimal with appropriate indexes on the database tables

The QGIS expression engine is able to do this using the QgsFeatureRequest.setFilterExpression( unicode ) method (Since QGIS 2.2)

request = QgsFeatureRequest().setFilterExpression( u'"Counties" = \'Norwich\'' )
it = l.getFeatures( request )

Starting with QGIS 2.10 it is even possible that filtering in such a way will give you some extra performance over other types of filtering (like python implementations).

Basically this applies if the following three conditions are met:

  • You are using a layer with the postgis provider At the moment (2.16) many more than just postgis provider implement this (spatialite, ogr, oracle...).
  • Your expression is not overly complicated (things like >, =, IN, NOT NULL ... are supported)
  • You have enabled this feature in Settings > Options > Data Sources > Data Source Handling > Execute expression on postgres server-side
  • The performance benefit is optimal with appropriate indexes on the database tables

With QGIS 2.18 it is even possible to simply do

features = l.getFeatures('"Counties" = \'Norwicth\'')
added 107 characters in body
Source Link
Matthias Kuhn
  • 28.2k
  • 3
  • 89
  • 130
Loading
deleted 84 characters in body
Source Link
Matthias Kuhn
  • 28.2k
  • 3
  • 89
  • 130
Loading
added 294 characters in body
Source Link
Matthias Kuhn
  • 28.2k
  • 3
  • 89
  • 130
Loading
edited body
Source Link
Matthias Kuhn
  • 28.2k
  • 3
  • 89
  • 130
Loading
added 320 characters in body
Source Link
Matthias Kuhn
  • 28.2k
  • 3
  • 89
  • 130
Loading
deleted 21 characters in body
Source Link
Matthias Kuhn
  • 28.2k
  • 3
  • 89
  • 130
Loading
added 2 characters in body
Source Link
Matthias Kuhn
  • 28.2k
  • 3
  • 89
  • 130
Loading
Source Link
Matthias Kuhn
  • 28.2k
  • 3
  • 89
  • 130
Loading