Add polygon attributes to points VS join attributes by location

Joining polygon attributes to points is a pretty common geoprocessing step. There are multiple ways to solve the problem in QGIS, so I thought I’d have a look at how they perform. There is Join attributes by location in the Vector menu and Add polygon attributes to points in the Processing toolbox.

My test data: Two shapefiles with 18,713 points and 17,397 irregular polygons.

(Some system specs: 1.3GHz dualcore with 4GB RAM)

And here are the results:

SAGA Add polygon attributes to points: 44 seconds
Vector | Data management tools | Join attributes by location: killed after 16 hours

This point clearly goes to Processing and the SAGA algorithm it provides access to. Join attributes by location offers some nice options for aggregating data but it just can’t cope with the number of features in this test.

To measure execution time (in a very unscientific way), I just ran the tool from the python console using:

import datetime
import processing 

Some notes of caution:
SAGA comes readily installed in OSGeo4W. As far as I know, the stand-alone installer for Windows currently does not include SAGA but it can be installed manually. On Ubuntu, the standard repos only contain SAGA 2.0.8 but 2.1 is required.

  1. pvanb said:

    For Ubuntu users, there is an option in the provider settings (menu: processing > options and configurations > providers > saga) to enable saga 2.08 compatibility. It works for me (I can’t for some reason get Saga 2.1 compiled on my system, but I just ran your example without problem)

    • That’s great! Seems like I have to try again :-)

  2. Pierre said:

    Wouah, the difference is huge!
    I have just installed QGIS 2.0.1 from the stand-alone installer and SAGA was also included.

    • Great! Seems like the installers have been fixed. That’s good news.

    • That’s great! I guess the next version will also include QGIS 2.0.

  3. n1kn0k said:

    What’s a good technique to join multiple attributes to the point data?

    • I think the SAGA algorithm should allow to join multiple attributes to the points. Unfortunately, the Processing GUI only allows to select one attribute. I haven’t reported the issue yet, but it should be discussed I think. Since I only needed two attributes for my use case, I simply ran the tool twice. That’s acceptable since it’s really fast. But it certainly gets annoying if you have to deal with a lot of attributes.

      • n1kn0k said:

        That’s what I did. Surely wished there’s a better way to handle multiple fields. It get cumbersome after the first, and I’m only so very glad that it was lightning fast (that is, compared to the other option, “join attributes by location”

%d bloggers like this: