I'm new to QGIS and I'm using it as a small part of a project I'm developing, so I need some help if possible. I have this layer:

enter image description here

What I need is to define a variable to serve as a perimeter and give some lat/long coordinates and define a circle around that point with perimeter = variable. I don't need this to all the points on the layer, just a few that I will then select. Also, the perimeter should be a constant. The main goal is to count the number of red/yellow/blue "points" within the range of each circle.

  • 1
    This is a pretty simple problem, it just sounds like you don't know the terminology. To create your perimeters, look at creating buffers around your lat/lon points. Then there are a few different ways of counting the points within those buffers. Jun 22, 2018 at 16:14
  • 1
    Possible duplicate of Count points within each buffer QGIS Jun 22, 2018 at 16:16
  • It's almost the same. The difference is my points aren't all the same. I have two different types of points within the buffer. Using the count points in polygon I can count them all. But I want to count points of type1 and points of type2. I may be able to do that using SQL, I will try it. Thanks Jun 22, 2018 at 16:23
  • Then the problem has shifted from counting points in a buffer (which is solved) to selecting features and then joining attributes into an attribute table.
    – Gabriel
    Jun 22, 2018 at 16:41

2 Answers 2


First off, if you don't have a point layer already built with the geographic coordinates of your evaluation points, build it from a csv list. You then need to add a field in that layer with the variable that will serve as the radius value you need if it wasn't already in your csv list.

You can achieve what you want with two tools accessible from the vector menu. The first thing is to use Buffer, found in geoprocessing tools. In the distance parameters, you can use a data defined override and provide a field to control the radius. See here.

If you need only certain points counted according to their attributes, use select features by value from the main toolbar. You get a list of each field where you can type the value you are looking to select with. On the right, there is a drop down menu where you can set your query operator (equal to, contains, etc.). After executing the selection, run the count points in polygon tool, found in the analysis tools menu within the vector menu. Set your polygon and points layers, make sure you tick the Selected features only checkbox and then run the tool. It will output a new polygon layer with an additional field named NUMPOINTS (by default - you can rename the field in the tool) where the point count will be located. See here.

You'll need to repeat the process for each of your evaluated variables (once if you are only looking for african or european as your values). Then you can merge the attribute fields into one polygon layer.

  • I've now done that. I had previously loaded a csv layer and the buffer created circles around every point of the layer. Now I have to load another layer with more points and calculate for each circle of the buffer the number of points within each circle according to a variable that is in the csv. I want something like (pseudo code): for each circle of buffer count number of points with x = y from layer1 and count number of points with x = y from layer2 Jun 22, 2018 at 15:52
  • Do you need to do this programmatically or are the different values of your x variable low in count enough that you could just select by attributes and then run the count points in polygon tool while ticking the selected entities only checkbox?
    – Gabriel
    Jun 22, 2018 at 16:06
  • I don't need to do it programmatically. And yes, they are low, maximum of 15 per zone. The layer has the format: field1 field2 field3 field4. field1 and field2 corresponde to lat and long field3 doesn't matter field4 has two different values: european or african What I want is to calculate for each circle of the buffer the number of european and african points. I don't know how to do it using the count points in polygon tool Jun 22, 2018 at 16:10
  • I edited the answer after I took a look at the buffer tool which has the ability to use a field to set distance. I'll edit again to make the steps easier to understand for the point count.
    – Gabriel
    Jun 22, 2018 at 16:20

You're looking for "buffer" and "join attributes by location", both in the vector menu. Make sure that your data is in a utm-projection before buffering it, otherwise it will be hard to set a reasonable value for your buffer.

Your Answer

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

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