8 votes
Accepted

Field contains X and Y coordinates

You need a string type field, and you need to use pipes (||), like $x||','||$y $x and $y you already know, and the pipes concatenate characters. The output could be an integer value, or you can chime ...
user avatar
  • 12.8k
8 votes
Accepted

Excluding zero values in proportion calculation in QGIS

Use this expression: array_mean( array_remove_all( array("field1", "field2", ...), 0 ) )
user avatar
  • 1,107
8 votes
Accepted

Getting index of selected rows in QGIS Field Calculator

In the Field Calculator, under the Record and Attributes header, you've got the is_selected() function which returns True if the feature is selected.
user avatar
  • 141
7 votes
Accepted

Midpoint coordinates from line in Field Calculator (QGIS)

To plot the midpoint of a polyline using the field calc: line_interpolate_point ($geometry, $length / 2) To visualize the point, add a style layer with the geometry generator: $length: Returns the ...
user avatar
  • 3,747
6 votes

Ordering polygons from north to south in QGIS

You can create a new field with this expression : array_find( -- find the current feature id in the list array_reverse( -- reverse the order of the list, so greastest Y coordinate (= Northest) is ...
user avatar
  • 12.5k
5 votes

Getting list of values from column in QGIS

You can create a virtual layer to fetch the distinct values Go to the menu Layer > Add Layer > Add/Edit Virtual Layer... and enter the query: SELECT DISTINCT "column D" FROM myLayer; ...
user avatar
  • 34.7k
4 votes
Accepted

QGIS - expressions with fields from a related layer

Yes, there is an easier way using expressions. In Layer Styling select the expression builder next to the attribute dropdown (circled red in image below). (For the example expression using aggregate() ...
user avatar
  • 951
4 votes
Accepted

Ordering polygons from north to south in QGIS

Use Order by expression if you just want to reorder the features: y(centroid($geometry))
user avatar
  • 52.5k
3 votes
Accepted

Update Attribute Table on clipped shapefiles using QGIS

You can use a virtual field in your table. This will be updated automatically and will be part of the layer style. Copying the style and giving it to a second layer will keep the virtual field and ...
user avatar
  • 7,785
2 votes
Accepted

How to save model parameters into the attribute table in QGIS?

The parameter function is used to get input parameters of the current tool. So create an input in the model designer and then you can call it by @Description, Description being the name of the input. ...
user avatar
  • 1,107
2 votes
Accepted

How to use CalculateField_management if I add values from a list?

You can use da.UpdateCursor like this: import arcpy fc = r'C:\GIS\data\data.gdb\rutnat' #Change fieldToUpdate = 'fruits' #Change #Create a long list by repeating the list using the number of input ...
user avatar
  • 52.5k
2 votes

Getting line length of geometry of parent feature as default value in child feature in QGIS

update: answer below is only relevant when adding new features in child layer. Question has since been clarified to the child form that appears when adding feature to parent layer, and using a default ...
user avatar
  • 7,459
2 votes
Accepted

Aggregating child features with parent attribute values in QGIS

It's a bit hard to tell exactly where the error is, perhaps syntax (when mixing up aggregate() and attribute() you need to be careful about when to use single vs double quotes to refer to layers), or ...
user avatar
  • 7,459
2 votes

Add a consecutive number at the end of a text in attribute table

Use @row_number with case: concat('GI_', case when length(@row_number)<2 then '0' else '' end, @row_number-1)
user avatar
  • 52.5k
2 votes

Add a consecutive number at the end of a text in attribute table

Try this expression 'GI_' + lpad($id, 2, 0)
user avatar
  • 1,107
2 votes
Accepted

Subtracting the two consecutive attribute values in attribute table (QGIS)

Try this: attributes( get_feature_by_id( 'Layer_id', $id + 1 ) )['Reference'] - "Reference" Replace Layer_id with the id of your layer. Remember that the ...
user avatar
  • 1,107
1 vote

Adding field and calculating field values based on a current field using ArcPy

You can achieve this with a simple if/then/else logic in a field calculate tool, see examples in How To: Use IF statements in the Field Calculator.
user avatar
  • 39k
1 vote
Accepted

QGIS field calculator get value of spefici cell

Suppose we have this table: id value_shp001 value_shp002 value_shp003 name 1 23 10 254 QGIS LTR 2 34 25 32 QGIS RC 3 100 150 541 QGIS dev to access the cell value_shp002, id = 2, just use the ...
user avatar
  • 3,747
1 vote

QGIS field calculator get value of spefici cell

Use the get_feature() function to pick out a specific feature from a layer, and then use the attributes() function to specify an attribute to pull from that feature. So to get the "height" ...
user avatar
  • 4,528
1 vote

Subtracting the two consecutive attribute values in attribute table (QGIS)

Another possible solution using arrays: with_variable('array_field', array_agg("Reference"), @array_field[$id]-@array_field[$id-1] )
user avatar
  • 3,747
1 vote

Subtracting area of a specific set of raster values from polygon area using QGIS

Use the Reclassify by table tool in order to isolate the classes you want to subtract. Create a reclassification table with only one row: Table: (Minimum: 0 Maximum: 12 Value(New): 1 Output no data ...
user avatar
  • 1,107
1 vote
Accepted

Nearest points from different id

On layer b, use this expression to get the closest point on layer a with the same id. Use Geometry Generator or Geometry by expression (see here for details): with_variable ( 'id', id, ...
user avatar
  • 41.1k

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