63
votes
Identifying duplicate attributes in field using QGIS
Another graphical, dynamic and most importantly simple way to detect duplicate attributes: use QGIS's expression builder.
Highlight duplicates in attribute table:
Suppose FieldWithDuplicates is the ...
55
votes
Understanding "Join Attributes by Location" in QGIS
Join Attributes by Location concatenates the following set of methods to compare geometries:
intersects if the intersection of both geometries is not empty
contains if the second geometry is ...
46
votes
Change style properties of several layers simultaneously?
This works for QGIS 3.4 =>
Create a group of all the layers you want to have the same style
Edit the style of one of the layers in the group to your liking
Right-click the correctly styled layer; '...
39
votes
Accepted
Summing data from column in Attribute table in QGIS
There are several approaches that I may suggest:
Approach 1 : toolbar
"Show statistical summary" tool from the Statistics panel (Ctrl+6).
Symbolized as a Sigma symbol(), placed in the main ...
32
votes
Grouping and counting attribute data in QGIS
With a "Virtual Layer" through Layer > Add Layer > Add/Edit Virtual Layer.... you can now use SQL on any layer in QGIS, for example the airport shapefile from the QGIS sample data:
To ...
32
votes
Renaming attributes/fields in shapefile attribute table using QGIS
Since QGIS 2.16 you no longer need a plugin to do this - you can double click a field name in a shapefile from the vector layer properties window and rename (set the layer as editable first)
29
votes
Accepted
Understanding "Join Attributes by Location" in QGIS
Don't think the QGIS docs has something as detailed as what is shown in the link in your comment (here is the link for English speakers). I would assume the terminology would be pretty much similar if ...
26
votes
Accepted
Adding text fields with more than 255 characters?
Shapefiles have a limitation of maximum 254 characters per field (See switchfromshapefile.org).
If you need more than that you will need to switch to a different format. If you don't know which file ...
26
votes
Accepted
Changing column order with Table Manager Plugin in QGIS 3
Yes, you can use the "Refactor fields" tool from the Toolbox:
25
votes
Using IN-operator in query builder in QGIS
You could use something like:
"Territory" IN ('India', 'China', 'Bhutan')
25
votes
Accepted
Getting field names of layer using PyQGIS
To get field names with fields() method or other field properties (length, type, comment, ...) you can use:
field_names = [field.name() for field in layer.fields()]
# ['id', 'attr1', 'attr2', 'attr3']
...
22
votes
Accepted
Can colon (":") character be used in shapefile field names?
Field name restrictions inside a shapefile are determined by dBase limitations. There are four single rules:
Up to 10 character max.
First character in field name must start with a letter.
Field ...
20
votes
Accepted
Maximum value of field of vector layer using PyQGIS
It is not necessary to get a complete list of field values. In QgsVectorLayer exists 'maximumValue' method. So, this works well and it's shorter:
layer = iface.activeLayer()
idx = layer....
20
votes
Accepted
Converting string field into date field in QGIS
I'm surprised I haven't seen this before. Maybe I'm overlooking something obvious :)
Although you're using a different locale to me, you're using the same date format as I do in the UK, dd/MM/yyyy. I ...
19
votes
QGIS, Populate field with self-updating formula (like spreadsheet)
Yes, this functionality is called virtual fields.
Open the field calculator and check the "virtual field" checkbox. The value will then be updated (or rather it is recalculated every time it is ...
19
votes
Accepted
Filling shape with labels or attributes in QGIS?
On Layer Properties window, select Single Symbol | Fill | Simple fill - Symbol Layer Type- Point pattern fill | Font marker. Then click Data defined override (field) and choose your field.
19
votes
Accepted
Creating predefined values in field using PyQGIS
You need to assign and configure a ValueMap widget to your layer's field in this way:
QGIS 3.x
fieldIndex = layer.fields().indexFromName( 'myField' )
editor_widget_setup = QgsEditorWidgetSetup( '...
19
votes
Accepted
AttributeError: 'QgsVectorLayer' object has no attribute 'fieldNameIndex'
In PyQGIS 3
Use one of the following methods from the QgsFields class:
indexFromName()
layer = iface.activeLayer()
layer_fields = layer.fields()
field_index = layer_fields.indexFromName("...
18
votes
Accepted
Updating text column of selected features in QGIS
make sure the layer is in edit mode (otherwise changes will not happen)
Select features to change (however you like)
then open attribute table
select the attribute to change
type in what you want it ...
18
votes
Changing fields order in QGIS
Open the attribute table. Right-click the column headings in the attribute table. Select "Organize columns" in the drop-down menu.
Then, just drag the heading to the position you want it to ...
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 ...
16
votes
Getting list of distinct values from shapefile field using QGIS
QGIS now has a tool that will list unique values in one or more fields in a layer. "This algorithm generates a report with information about the unique values found in a given attribute (or attributes)...
16
votes
Accepted
Adding Properties to a feature in Google Earth Engine
Yes, you can use the feature.set()option which Feature Overview covers with these examples:
// Make a feature and set some properties.
var feature = ee.Feature(ee.Geometry.Point([-122.22599, 37.17605]...
16
votes
Accepted
Getting dictionary for each feature with their attribute values using PyQGIS
The QgsJsonUtils class has exportAttributes method for getting attributes as a dict.
Solution 1:
Making a dictionary including feature "id" as key, attributes map as value:
{feature1.id: {...
15
votes
Sorting by multiple fields at same time in QGIS?
This can now be done without any plugins or database-specific work, at least for version 3.2+. To sort by multiple columns:
Right click on the attribute table column header and choose "Sort..."
Add ...
15
votes
Determining the centroid of polygons in QGIS
A more robust soulution to mike's answer:
long = toreal(regexp_substr(geom_to_wkt(centroid($geometry)), '(-?\\d+\\.?\\d*) -?\\d+\\.?\\d*'))
lat = toreal(regexp_substr(geom_to_wkt(centroid($geometry)),...
15
votes
Accepted
KeyError: '-1' when adding field and calculating expression with PyQGIS
The error you get says the field index is -1, so your new field wasn't found in your attribute table.
That may be happening because:
You need to use QVariant.Double instead of QVariant.Float.
You've ...
15
votes
Getting field names of layer using PyQGIS
List field names with dataProvider() method
from qgis.utils import iface
# get active layer if not already set
layer = iface.activeLayer()
prov = layer.dataProvider()
field_names = [field.name() ...
14
votes
Identifying duplicate attributes in field using QGIS
This is a good question onto which I just stumbled myself. I don't like any of the answers which have been given so far. I have a valid dataset with unique IDs that are non sequential and non integer. ...
14
votes
How to split text attribute by characters in QGIS?
You can use the Field calculator with the following expression:
string_to_array("Nombre", ' ')
The string_to_array() function splits string into an array using supplied delimiter.
If you want a ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
fields-attributes × 1836qgis × 770
arcgis-desktop × 316
attribute-table × 300
arcpy × 236
pyqgis × 188
field-calculator × 181
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