7
votes
Calculating two columns at once in QGIS
QGIS has an algorithm for that :
Statistics by categories (official documentation)
You have to select your layer, your category field (here "Cover") and the field to calculate statistics (...
6
votes
Accepted
Using QGIS field calculator to create an 'fid' column according to a value from another column
Hacky solution using the field calculator:
array_find(
array_agg(
expression := to_int(substr("Row name", 5))*10*maximum("Col")+"Col",
order_by := to_int(...
5
votes
Accepted
Displaying milliseconds in Attribute Table using PyQGIS
The comment by @Matt was already pointing in a correct direction. QgsDateTimeFieldFormatter is indeed needed to modify the display of DateTime values.
The following code example replaces the default ...
5
votes
Accepted
Converting number with leading zeros in integer in QGIS
Try this expression with the to_int() function:
to_int("baumnummer")
-- to_int('000001') -> 1
If you wish to maintain the string field type, you could expand the expression above with ...
4
votes
Accepted
Converting text field with special characters to field with floats in QGIS
regexp_substr( "stringfield", '(-?\\d+\\.?\\d*)')
https://www.tutorialspoint.com/How-to-extract-numbers-from-a-string-in-Python
4
votes
Accepted
Is there non spatial Virtual Layer in QGIS?
As was mentioned by @J.Monticolo in his comment it is possible to exclude the geometry simply by choosing 'No geometry' in the 'Geometry' tab
Also as was mentioned by @MrXsquared in his/her comment: ...
4
votes
Accepted
Renaming categorical attribute values in QGIS attribute table: merge two different strings to the same name
Just run Field calculator, update the field by typing this expression:
if (
"Species" in ('DD', 'Delphinus Delphinus'),
'Delphinus Delphinus',
"Species"
)
Here I ...
2
votes
Counting number of selected features in QGIS
This works fine for me:
from qgis.core import *
import qgis.utils
layer = iface.activeLayer()
features = layer.selectedFeatures()
print ("Total count", layer.featureCount())
print (...
1
vote
Merging Attribute Table Field Values for Same File in QGIS
one way to do this is to concatenate fields together in the QGIS Field Calculator, using the following equation:
"field1" || "field2"
or to put a space between your fields:
&...
1
vote
Categorizing field and summing attributes for label in QGIS
Use QGIS expressions with the aggregate function sum(), grouping it by the common part of the "CFSAUID" attribute. For this, define an expression that returns this common part, here ...
1
vote
Counting number of selected features in QGIS
There are several methods that I may refer you to:
1. Press Shift + F6 to open attribute table with selected features only. There will be two values that represent the number of selected features: '...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
attribute-table × 1912qgis × 967
arcgis-desktop × 450
fields-attributes × 223
field-calculator × 217
arcmap × 171
shapefile × 130
attribute-joins × 101
pyqgis × 100
arcpy × 99
qgis-3 × 76
python × 70
raster × 66
arcgis-10.2 × 61
editing × 61
expression × 57
arcgis-10.1 × 56
arcgis-10.0 × 50
select-by-attribute × 49
excel × 45
arcgis-pro × 44
csv × 44
polygon × 42
point × 38
print-composer × 38