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"?
Answer
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.
No comments:
Post a Comment