18 votes
Accepted

Copying & pasting multiple values from one feature to other features in the same layer in QGIS

There is the AttributePainter plugin (https://plugins.qgis.org/plugins/attributePainter/) for this. Usage: Click on Pick source feature and select a sample feature on the map. On the table, a ...
Kadir Şahbaz's user avatar
11 votes
Accepted

Removing unwanted data in the cell of the QGIS Attribute table

Use this expression based on regular expressions to: find the first special character - special character understood as everything else than letters from a to z (upper and lower case), number 0 to 9 ...
Babel's user avatar
  • 67.4k
10 votes

Displaying label if field contains 'X' or 'Y' value in QGIS

Use this: CASE WHEN "Status" IN ('Week', 'Active') THEN "Drilled ID" END
Kadir Şahbaz's user avatar
10 votes

QGIS: Compare two concatenate fields and add similar strings to new column

It can be achieved by converting the RefSpecies and Sightings strings to arrays and checking whether each element of the Sightings array appears in the RefSpecies array: -- create arrays of the `...
Matt's user avatar
  • 14.9k
10 votes
Accepted

Auto incremental field filled with filtered by other field value in QGIS Attribute Form

You need to specify the second parameter group_by as "CATEG" for the maximum() function. if(maximum("ORDER", "CATEG") is NULL, 1, maximum("ORDER", "CATEG&...
Kadir Şahbaz's user avatar
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
  • 80.5k
9 votes

"AttributeError: 'dict' object has no attribute 'fields'" error when creating and deleting fields in the attribute table using PyQGIS

I could get the same error: Traceback (most recent call last): File "C:\PROGRA~1\QGIS32~1.0\apps\Python39\lib\code.py", line 90, in runcode exec(code, self.locals) File "<...
Taras's user avatar
  • 31.4k
9 votes
Accepted

Using attributes tables as variables in QGIS

Absolutely, you can set a variable in your map layout that correlates to the unique key of the map layout attributes table loaded in your project. Then use attribute() to get the corresponding values. ...
she_weeds's user avatar
  • 10.8k
8 votes
Accepted

Is it possible to join the same table twice in QGIS?

What you want to do is not joining layers, but creating two new attributes. You can achieve this with field calculator using this expression on the lines layer: attribute ( get_feature( '...
Babel's user avatar
  • 67.4k
8 votes
Accepted

QGIS Symbology - Display more symbols for each point depending on attribute numeric value

You can use the Geometry Generator in the Layer Style definition. With one Geometry Generator entry for each relevant category. These will be used to generate: "Bananas" points, starting ...
Kasper's user avatar
  • 3,142
8 votes
Accepted

Using underscore when concatenating fields with expression in QGIS Field Calculator

You can use concat("Fieldname1", '_', "Fieldname2") Also: "Fieldname1" || '_' || "Fieldname2"
ahmadhanb's user avatar
  • 40.5k
8 votes
Accepted

Displaying label if field contains 'X' or 'Y' value in QGIS

I found another solution. Case When "Status" like 'Active' or "Status" like 'Week' Then "Drilled ID" End
Antyant's user avatar
  • 269
8 votes

Converting multiple fields with abbreviations to one field with full names in QGIS

I would recommend using arrays to concatenate your data, especially as you will have some blank/null results which will make typical concatenate (||) not work well and you would need to wrap each ...
she_weeds's user avatar
  • 10.8k
8 votes

QGIS extracting values from a shapefile

Use the QGIS Extract by expression algorithm with the following expression: "Field" > 0 Replace Field with your field name, set where to save the results and then run the algorithm.
Mayo's user avatar
  • 3,757
8 votes

Using all columns to find the minimum with QGIS expression

There might be a simple solution for simple cases (where non-numeric columns are of no concern and simply ALL columns can be aggregated). I created a more sophisticated and flexible approach, using a ...
Honeybear's user avatar
  • 2,334
7 votes

Permanently sorting table so that field of interest is sorted in the same order as the fid in QGIS

One can try the setSortExpression() and setSortOrder() methods of the QgsAttributeTableConfig class. from qgis.core import QgsProject def sorting_table_by_column(layer_name: str, column_name: str, ...
Taras's user avatar
  • 31.4k
7 votes

Permanently sorting table so that field of interest is sorted in the same order as the fid in QGIS

You can use GeoPandas to sort the field "field_a" in ascending order and save it back to the GeoPackage with a new name. Here is a sample code: import geopandas as gpd # update the path to ...
ahmadhanb's user avatar
  • 40.5k
7 votes
Accepted

Filling attribute column with numbers 1-50 on repeat in QGIS

If you want a number going from 1 to 50 and repeat, you can use the modulo % operator combined with the @id variable (older versions of QGIS can use $id instead) : @id % 50 + 1 (the color can be ...
J. Monticolo's user avatar
  • 15.7k
7 votes

How to make a hyperlink for a point layer in QGIS so that you can go to Google Maps

Google Maps URL is like: https://www.google.de/maps/@52.3967404,1.4891383,12.04z The first 2 numbers after maps/@ are you coordinates (lat, long). Be careful you have the correct order! The last ...
fsg's user avatar
  • 652
7 votes

Field calculator formula converting DMS coordinate to decimal

Use to_decimal() function, introduced in QGIS 3.16: to_decimal ("Field") Example: if Field value is '17-42-35.244', the output is 17.70979 For QGIS versions older than 3.16, change your ...
Babel's user avatar
  • 67.4k
7 votes

Failed to export from shapefile to CSV in QGIS

The error message is quite explicit and clear: a field with this name already exists. It seems you have two fields with the same name (maybe truncated by the fieldname length constraint in ...
Babel's user avatar
  • 67.4k
7 votes
Accepted

Merging values from two fields into third field using PyQGIS

You can use or like this, i think it is called Ternary operators: layer = iface.activeLayer() p = layer.dataProvider() field_to_update = "field3" fieldindex = layer.fields().indexOf(...
BERA's user avatar
  • 68.9k
7 votes
Accepted

Performing the same mathematical operation on many attributes at once with QGIS

Another option is to use Menu Processing > Toolbox > Refactor Fields. In the field Source Expression, include your mathematical operation. In the field "Name", you can change the field ...
Babel's user avatar
  • 67.4k
7 votes

Deleting contents of all entries in field in QGIS Attribute table

You could use the field calculator to update the field to '', aka an empty field. Beware that this is not NULL. As J.R pointed out in the comments, null provides a NULL-value in your field.
Erik's user avatar
  • 15.7k
6 votes
Accepted

Permanently sorting table so that field of interest is sorted in the same order as the fid in QGIS

Create a "Virtual Layer" through Layer > Add Layer > Add/Edit Virtual Layer... with this query, than make it permanent/export/save it: select * from my_layer order by field_a Be aware:...
Babel's user avatar
  • 67.4k
6 votes
Accepted

Fetching and combining field values from vector layer to another in QGIS

You can use "Join attributes by location" tool: Takes an input vector layer and creates a new vector layer that is an extended version of the input one, with additional attributes in its ...
BERA's user avatar
  • 68.9k
6 votes

QGIS: Compare two concatenate fields and add similar strings to new column

Use field calculator to: Create your custom function (Function editor tab): @qgsfunction(args="auto", group='Custom') def myFunc(f1, f2, feature, parent): l1 = [x.strip() for x in f1....
RainForest's user avatar
  • 1,140
6 votes

Deleting specific attributes of layer using PyQGIS

clip.field must be clip.fields processing.runAndLoadResult method returns a dictionary like {"OUTPUT": 'result/file/temporary/path'}. So clip is a dictionary. fields is a QgsVectorLayer ...
Kadir Şahbaz's user avatar
6 votes

Prioritise label by field containing data importance in the data QGIS

You need to use data-driven label priority, in the layer's Label settings, Placement sub-tab. There's a slider for Priority there which sets priority for all the label of the layer, but to its right ...
Houska's user avatar
  • 7,808
6 votes

Joining attribute tables without columns with the same name in QGIS

To do an attribute join you need two columns containing the same / matching data. Note that they also need to have the same datatype. E.g. Integer to string won't match. The names of the columns do ...
MrXsquared's user avatar

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