1

I need to do the following in QGIS and hope so much anyone could help.

I have a vector layer with points. Each point represents a firm with the number of employees in the attribute table. I want to buffer around every point, so that the buffer's attribute table contains the sum of employees within the buffer.

It would be so great if the sum to each point could be written to the attribute table.

Thanks for your help.

nmtoken
13.6k5 gold badges39 silver badges91 bronze badges
asked Jul 20, 2013 at 15:48
2
  • Do any of the buffer polygons overlap? Commented Jul 20, 2013 at 18:37
  • Hi Kevin - yes they do overlap! Commented Jul 20, 2013 at 19:09

1 Answer 1

1

If you want to import your points into SpatiaLite, it's easy to get the total number of employees in each buffer. Suppose we have a point table "firms" in spatialite with columns "firm_name" and "num_employees". Assuming you want buffers of size 5000, then

First create the buffer polygons table:

CREATE TABLE firm_buffers pk_uid INTEGER PRIMARY KEY AUTOINCREMENT,
firm_name TEXT, ttl_employees INTEGER;
SELECT AddGeometryColumn('firm_buffers','geometry',<your SRID>,'POLYGON','XY');

Now create the buffer polygons:

INSERT INTO firm_buffers (firm_name, geometry)
SELECT firm_name, ST_Buffer(geometry, 5000) FROM firms;

Now update the ttl_employees column:

UPDATE firm_buffers SET ttl_employees=(
SELECT SUM(f.num_employees) FROM firms AS f
WHERE ST_Contains(firm_buffer.geometry, f.geometry));

That should total up all employees from all firm locations with a buffer.

answered Jul 21, 2013 at 6:07
0

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.