19 votes
Accepted

Selecting features with equal field value interactively on QGIS map

Very nice use case for yet another handy QGIS feature: Layer actions! Here the steps to configure your layer action: Open your layer Properties dialog. Click on menu Actions. Click on the green cross ...
Germán Carrillo's user avatar
17 votes
Accepted

Select by Attributes - Strings with < 5 characters

Using the Select by Attributes tool, you could enter the following SQL query to select all features with less than 5 characters in the ZIP field: CHAR_LENGTH("ZIP") < 5
Joseph's user avatar
  • 75.6k
15 votes
Accepted

Selecting multiple attributes, greater and less than

I think you need to use the following instead: "GRIDCODE" >= 10 AND "GRIDCODE" < 15 You need to switch the => operators and specify again the attribute field for the second term (i.e. < ...
Joseph's user avatar
  • 75.6k
13 votes

Selecting all features except one using QGIS?

How about "ONScode" != '17UB' != means "not equal to".
Alex Hajnal's user avatar
12 votes

Select features using an expression, QGIS

There are two possibilities when you want to select several value. The first is to use the OR operator : "Parametro" = 'alfa-Hexaclorociclohexano' OR "Parametro" = 'beta-Hexaclorociclohexano' OR "...
J.R's user avatar
  • 15.7k
12 votes
Accepted

Sorting/ordering selected features by attribute in QgsVectorLayer using PyQGIS

You can also use addOrderBy method of QgsFeatureRequest in this way: request = QgsFeatureRequest().addOrderBy("City") for f in vLayer.getSelectedFeatures(request): print(f["City&...
Kadir Şahbaz's user avatar
12 votes
Accepted

QGIS Select points within ONE polygon in a different layer

If you check "Select features only" option for the polygon layer, you can select the points within the selected polygon.
Kadir Şahbaz's user avatar
11 votes
Accepted

Selecting multiple field values using range in QGIS

Use this expression: ("ALTURA_SOB" >=500 AND "ALTURA_SOB" <= 1200) OR ("ALTURA_SOB" >=2000 AND "ALTURA_SOB" <= 2500)
Noura's user avatar
  • 3,429
10 votes

Deleting selected features using PyQGIS

There is also a possibility of using the deleteSelectedFeatures() method from the QgsVectorLayer class for deleting selected features: # choose an active layer layer = iface.activeLayer() # make own ...
Taras's user avatar
  • 32.6k
10 votes

Selecting polygon with the largest area in QGIS

You would be better off using "Select by expression" instead of "Select by attribute". Your expression should be something like: "AREA" = maximum("AREA") ...
nash's user avatar
  • 1,976
10 votes
Accepted

Processing tool to invert/switch selection in Graphical Modeler

Yes, you can use "select by expression" tool and insert if(is_selected() is false,true,false) as expression. This will allow inverting your selection in graphical modeler. Result:
MrXsquared's user avatar
  • 33.8k
10 votes
Accepted

Exporting features when column value between specific percentiles

You can create a new function which returns a percentile value, then, compare the field value. Open Select Feature by Expression tool Create new function in the Function Editor using the script below....
Noura's user avatar
  • 3,429
10 votes
Accepted

Selecting latest record by date

QDateTimeobject is returned from maximum, but inspection_date is probably QDate. And to_date converts the result to QDate object. "inspection_date" = to_date(maximum("inspection_date&...
Kadir Şahbaz's user avatar
10 votes

Sorting/ordering selected features by attribute in QgsVectorLayer using PyQGIS

Try the snippet below. You can store selected features and an associated attribute as key, value pairs into a dictionary, then sort by the field value. After that, you can access the feature object ...
Ben W's user avatar
  • 21.2k
10 votes

QGIS Select points within ONE polygon in a different layer

Using selection by expression: overlay_within ( LAYER:= 'POLYGON', filter:= "COD_PROV" = 88)
pigreco's user avatar
  • 4,435
10 votes
Accepted

Selecting items in the attribute column based on items of another layer in QGIS

I can suggest a PyQGIS solution. Proceed with Plugins > Python Console > Show Editor and paste the script below from qgis.core import QgsProject layer1 = QgsProject.instance().mapLayersByName('...
Taras's user avatar
  • 32.6k
9 votes
Accepted

Saving/exporting selected features in QGIS

For QGIS 2.x versions You are doing fine, but just need to go to next step. Tick on Save only selected features.
Kazuhito's user avatar
  • 30.7k
9 votes

Showing string that contains specific number in QGIS

It is unclear to me what you want to do exactly. The expression you are using is correct. It highlights the points with the correct expression because you are using "Select By Expression" ...
ahmadhanb's user avatar
  • 40.7k
9 votes

Exporting features when column value between specific percentiles

You can use Select by expression and paste this expressions (see also screenshots below): For the lowest 10%: "value" <= array_get( array_sort ( array_agg ("value"...
Babel's user avatar
  • 70.4k
9 votes

Sorting/ordering selected features by attribute in QgsVectorLayer using PyQGIS

This also works: sorted_list = sorted(vLayer.selectedFeatures(), key=lambda el: el['City']) for feature in sorted_list: print(feature['City'])
Emma's user avatar
  • 422
9 votes

Selecting features in one layer based on mutual field with another layer in QGIS

Use "Select by expression" with this expresstion on layer 1: array_contains( aggregate( 'points1', -- change this to the name of your layer1 'array_agg', name1 ...
Babel's user avatar
  • 70.4k
9 votes
Accepted

Selecting features with values whose difference is greater than 20 in QGIS

You are interested in the absolute difference between the two columns: abs(col1-col2) > 20
Ian Turton's user avatar
  • 81k
8 votes

Assign multiple colors to features within a single vector layer

Alternatively to categorized styling, if you want to play a bit with colour you can try to code it by yourself: CASE WHEN Field = 'Value1' THEN color_rgb(0, 176, 80) WHEN Field = 'Value2' ...
wastek's user avatar
  • 303
8 votes
Accepted

Selection by attribute string with wildcard as part of name in ArcGIS Desktop?

From the page on SQL reference for query expressions used in ArcGIS To include the percent symbol or underscore in your search string, use the ESCAPE keyword to designate another character as the ...
Richard Morgan's user avatar
8 votes
Accepted

Why does the Select by expression dialog not show field values?

The information you are looking for is hidden in a panel that is collapsed/minimized on the right-hand side of the dialog. Here's how you can access it:
underdark's user avatar
  • 84k
8 votes
Accepted

AttributeError:'QgsVectorLayer' object has no attribute 'setSelectedFeatures' PyQGIS 3.0

According to the pyqgis api documentation there is a method layer.selectByIds([s.id() for s in selection]) And for some performance improvements and good practice, don't request any attributes or ...
Matthias Kuhn's user avatar
8 votes
Accepted

Display Multiple Symbols for a single point feature by field attribute vale

You can work with a rule based symbology and use different displacemet values for each symbol in your rules, like in the attached image: With some more work, you can add some datadefinded overrides ...
eurojam's user avatar
  • 10.7k
8 votes
Accepted

Select features from the attributes table without opening it in QGIS

Sure, here some options: Use the processing toolbox and one of these tools: Select by Expression Select by Attribute Select by Location Or directly extract them via processing tools: Extract by ...
MrXsquared's user avatar
  • 33.8k
8 votes

Sorting/ordering selected features by attribute in QgsVectorLayer using PyQGIS

@Ben W, thank you so much, I have marked your answer as correct. Even so I have found a solution to solve it in one operation. It is a combination of your answer and the instructions on this website ...
RBenet's user avatar
  • 770
8 votes
Accepted

Select values that are the same in another column in another layer

The aggregate() function in QGIS is both ridiculously powerful and also difficult to understand, but it's exactly what you need. Conceptually this is what we're going to do: First you need to create ...
TeddyTedTed's user avatar
  • 5,995

Only top scored, non community-wiki answers of a minimum length are eligible