TransWikia.com

Increment value based on grouped field

Geographic Information Systems Asked by Guts on January 19, 2021

I’ve got a dataset of buildings roof segments in shapefiles. I need to sequentially number the roof segments from 1 to n of each building. Is there a way to do it with the QGIS field calculator?

Actual:

enter image description here

Expected:

enter image description here

It’s pretty similar to that question on arcpy: Auto increment by group in ArcGIS ModelBuilder

One Answer

You can use this expression:

array_find(array_agg("BUILDING"||'_'||-$id,"BUILDING"),"BUILDING"||'_'||-$id)+1

Result:

enter image description here

Correct answer by MrXsquared on January 19, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP