1

I have a shapefile with more than 180,000 rows. Whenever I want to apply the field calculator (e.g. for $id or $area), QGIS crashes (waiting to respond). My PC has 32GB RAM.

Any idea what I can do?

3
  • 2
    When I faced with this problem I started use SpatiaLite database. There you could make same result in 1-2 minutes. If it interesting I might explain step by step all process.
    – krvrd
    Commented Mar 8, 2018 at 17:43
  • Can you share the file? I suspect there's some corruption here and would like to investigate
    – ndawson
    Commented Mar 8, 2018 at 21:36
  • I would like to but unfortunately I am not allowed to share the file.
    – Stücke
    Commented Mar 9, 2018 at 8:05

4 Answers 4

2

Use the field calculator from the main window.

Adding/deleting columns with attribute tables open is super-slow.

1
  • Actually to be a bit more precise: close the attribute table while running the calculator on large datasets. Commented Mar 9, 2018 at 14:28
2

This may well be a matter of patience. I've used the field calculator ($x and $y) on points layers with over 10 million features. Using a 16BG RAM PC, I also get the apparent crash of 'waiting to respond', but it still goes onward, and does provide results after a while (in my case, after a couple of hours).

I've used a SpatiaLite format, which runs much quicker than the CSV format that this data was originally in.

1

I came across the correct answer! Don't use the attribute table but rather use the field calculator directly from the main window. Worked well forme! Took only a minute or so. Solved, thanks!

0

If you haven't already, I would create a spatial index for the file.

This may help.

enter image description here

2
  • I've tried to create a SpatiaLite index but that doesn't change anything. Is there a prefered file format for large field calculations? Should I use QGIS 2.X or QGIS 3.X?
    – Stücke
    Commented Mar 9, 2018 at 8:06
  • This answer walks you through adding a spatial index to your existing shapefile. It's a completely different process from converting your shapefile into a SpatiaLite database.
    – csk
    Commented Mar 9, 2018 at 18:18

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.