# Creating a selection that selects points that are within a certain distance of other points in QGIS

So I am in a beginner Geospatial Analysis class which is focused on learning Arc and ESRI-owned GIS software but I wanted to be able to apply what I am learning in something that would be more applicable to me. The instructions are meant primarily for ArcMap but I am trying to follow them in QGIS.

I need to be able to select and count how many points are within one mile distance of a point in another set of points. The instructions for ArcMap say to use the Select By Location tool, but the one in QGIS doesn't seem to have the same functionality as in ArcMap. I have seen some talk about the distance matrix but I don't know anything about that.

I think @Paul Goyes's solution only works if you have created a 1-mile polygon buffer layer for your point, similarly to Select by Location.

I don't think the nearest neighbour algorithms are aimed at what you're trying to do either - they generally keep looking to find the closest match(es) and are about comparing what the best match is for each of multiple source points. Not just selecting everything within a fixed distance from a single point.

If you don't want to create another layer per Paul's solution, the easiest way to select everything from one layer given a distance from another layer may be using QGIS expressions in the Select by Expression dialog box.

In this example I have a single green point labeled POINT (layer `point`) Now I want to select everything in another layer (`otherpoints`) that is within a 20m radius of POINT - shown as a pink circle in this diagram.

I selected the layer `otherpoints` and used the following expression in Select Features by Expression:

`within(\$geometry,aggregate('point','collect',buffer(\$geometry,20)))`

(Note the layer reference, being `point` in this instance, is case-sensitive)

As you can see below this selected the relevant points.

To modify the expression for your own use, simply change the layer reference and the map units from 20 to 1. Make sure both layers are in a projected CRS (miles-based in your case)!

• Expressions are often the best way to follow. Apr 7 '20 at 3:29

I think you could use the distance matrix, as indicated here: https://www.qgistutorials.com/en/docs/nearest_neighbor_analysis.html

The exactly answer is here. Tool name: extract by location. Qgis3x. Follow the instructions step-by-step here https://www.qgistutorials.com/en/docs/3/performing_spatial_queries.html