[GIS] How to create a merged buffer in QGIS then count points that fall within it

buffermergeqgis

I have a QGIS plan which shows ponds (as points in a shape file with an OS tile as a background) within a survey area. I need to calculate the total number of ponds within 1 km of each of the on-site ponds individually.

I have created one layer with 1 km buffers for each pond as a shapefile.

As there are many ponds, this is messy to look at and I would like to create a layer which has the outline of all of the 1 km buffers combined. I have tried selecting the layer with the buffers and vector-geoprocessing tools – dissolve, but the new layer had outlines for each individual buffer.

Question part 1 – how do you create combined buffers, or convert existing buffers into one?

I will then use this outline to manually check the OS plan and add points representing ponds as a new layer "off site ponds".

Question part 2 – How would I then find the number of ponds (onsite and offsite, not counting the pond being queried) within 1 km of each on-site pond (individually).

Sub-question – if one of the buffers dissects a symbol for a pond will it count the pond, or only if the centre point falls within the buffer? (i.e. could the size of the symbol affect the result?)

Best Answer

Question part 1 - how do you create combined buffers, or convert existing buffers into one?

I don't know what version of QGIS you are using, or whether this feature is missing in older versions, but the Buffer tool has an option to "Dissolve buffer results". Note the pointer position in the following image:

QGIS Buffer Tool

Note that because my data are different, I've set the buffer distance to 200 m. You should set yours to 1609 m = 1 mile.

Question part 2 - How would I then find the number of ponds (onsite and offsite, not counting the pond being queried) within 1 km of each on-site pond (individually).

While you may want to dissolve buffers for visual display, you cannot use dissolved buffers to answer this question, since it sounds like you want a count for each pond separately. So even though the buffers overlap, that is OK, since a pond could fall in the search radius of more than one onsite pond, and you want it to count for each. Use Vector→Analysis Tools→Points in polygon:

QGIS Points-in-Polygon Tool

Since each buffer was constructed from a point, to get the count of ponds not including the central pond, use the Field Calculator tool to update the pond_count field to pond_count less one. Open the attribute table and click the "Toggle editing mode" button in the upper left. Then click the "Open Field Calculator" button in the upper right. Check "Update existing field", set the field to pond_count, and in the Expression box enter pond_count - 1:

QGIS: Updating an existing field with the Field Calculator

Hit OK once only, and close the dialog. Save your edits and toggle editing off.

If the ponds have some kind of unique identifier, it should propagate through each step of the process to your final shapefile, which will be a polygon layer of buffers with the count of all ponds within a 1 mile radius.

Sub-question - if one of the buffers dissects a symbol for a pond will it count the pond, or only if the centre point falls within the buffer? (i.e. could the size of the symbol affect the result?)

QGIS and other GISes treat points as a mathematical point (i.e., infinitesimally small). The size of the symbol you use to visualize your data is irrelevant to the calculation. Some spatial query operations may have different results depending on whether a point falls exactly on a polygon boundary (in general GIS terminology, the difference between "contains" and "contains completely"), but I'm pretty sure the QGIS Points-in-Polygon tool will count a point on the edge as being within the polygon. I haven't tested it though. It's unlikely to make a difference in this dataset. It's more likely to be important in a situation where points and polygons are constructed on some common base, such as a street grid, and you need to decide what to do with points that fall at the exact boundary between two neighboring polygons.

Related Question