5

I would like to split a shapefile made up of approximately 8200 elements into five having an equal number of elements. I don't want to base this division on an attribute. There is a simple way to do that in QGIS?

3
  • 1
    What geometry type? What's the spatial distribution (clustering?) of the features? Can you add a screenshot?
    – Babel
    Commented Jun 2, 2021 at 17:13
  • Thank you for your attention. The records have a point geometry. I don't care about the geographic relations amonst them. For me it is ok just to select the first 8474/5 elements, then another group of equal number, ect.ect. I tried to do it manually, but it is very hard and not efficient. The problem is working with the "selection by expression" function, I think. I can select by field, but as I mention, existing fields do not help me.
    – Geo_it
    Commented Jun 2, 2021 at 17:21
  • Please use the edit button beneath your question to revise it with any requested clarifications.
    – PolyGeo
    Commented Jun 3, 2021 at 3:21

1 Answer 1

9

You can create a new attribute field which bins the 8474 elements into 5 bins:

bin_size = 8474/5, or approx. 1750 elements per bin.

Go to field calculator and generate a new integer field called 'bin' with this expression:

ceil(@row_number/1750)

If you want it to be more dynamic, you can do this, which uses the size of the table as a parameter for the number of elements per bin. Replace 'fid' with the name of a different field if your table doesn't have a field named fid.

ceil(@row_number/(count('fid')/5))

enter image description here

Then use bin as the field to split by in the Split tool.

enter image description here

1
  • That is very usueful, many thanks.
    – Geo_it
    Commented Jun 13, 2021 at 8:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.