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 ...
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 ...
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
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 `...
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&...
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
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 "<...
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.
...
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(
'...
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 ...
8
votes
Accepted
Using underscore when concatenating fields with expression in QGIS Field Calculator
You can use
concat("Fieldname1", '_', "Fieldname2")
Also:
"Fieldname1" || '_' || "Fieldname2"
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
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 ...
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.
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 ...
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, ...
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 ...
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 ...
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 ...
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 ...
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 ...
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(...
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 ...
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.
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:...
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
...
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....
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 ...
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 ...
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 ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
fields-attributes × 1840qgis × 773
arcgis-desktop × 316
attribute-table × 300
arcpy × 236
pyqgis × 188
field-calculator × 182
shapefile × 122
arcmap × 108
python × 78
qgis-3 × 76
layers × 73
attribute-joins × 69
arcgis-pro × 55
expression × 54
polygon × 53
point × 47
arcgis-10.2 × 43
symbology × 42
features × 38
arcgis-10.1 × 37
editing × 37
modelbuilder × 35
arcgis-10.0 × 33
labeling × 31