In my vector layer I want to select points within a buffer of 12 meters and with an exception (if 'Name' is not "James" than select).

Is this possible with "select by expression"?


Yes this is possible. You need to calculate the distance between every point and your reference point using the distance function (a buffer is a misleading idea), and add a second condition using the AND operator. This could give something like:

distance( geomFromWKT('POINT(4 4)') ,  $geometry ) <= 12 AND  "Name"  IS NOT 'James'

where $geometry are all the points, and geomFromWKT('POINT(4 4)') your reference point (in Well Known Text format). Make sure you get the single and double quotes right: double quotes are for field names and single quotes for strings.

| improve this answer | |
  • Sorry, there is a mistake in my question. I want select points within a distance <= 12 meters and with the expression that the Name column is not the same. What mean is that I want to find points which are closer than 12m and they do not have the same attribute (Name). – Pimpel Sep 15 '15 at 14:46
  • Ok I see. What happens if there is more than 1 point within 12 meters? Could we say that what you want is select points that don't have any other point with the same attribute within a distance of 12 meters? – chkaiser Sep 15 '15 at 16:57
  • Not really. The points are placed in rows. Every row has it's own name. I want to know if there are points too close to the neighbour row. If the points of a row are closer than 12 meters...it doesn't matter. – Pimpel Sep 15 '15 at 18:14
  • @Pimpel if your question can be improved then please use its edit button to do that rather than in comments on an answer to it. – PolyGeo Mar 19 '16 at 2:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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