8 votes
Accepted

Selecting only one point in polygon using QGIS

If you don't care which point is selected, you can use this small PyQGIS script. Paste into a blank editor in the Python Console, change the layer names in the first two lines to match your layer ...
user avatar
  • 13.6k
5 votes

Selecting only one point in polygon using QGIS

With the "Select by expression tool you can use array_first( array_agg( $id, group_by:=overlay_intersects('polygons', $id), -- replace 'polygons' filter:=array_length(...
user avatar
  • 24.9k
4 votes

Calculating mean value for points within polygon in QGIS

There is a possibility using a "Virtual Layer" through Layer > Add Layer > Add/Edit Virtual Layer.... Let's assume there are two layers one with points called 'points_example' (green) ...
user avatar
  • 23k
4 votes

Selecting only one point in polygon using QGIS

To add some performance improvements to @Ben W's answer by using a spatial index and a break command: point_lyr = QgsProject.instance().mapLayersByName('points')[0] poly_lyr = QgsProject.instance()....
user avatar
  • 24.9k
4 votes

Selecting only one point in polygon using QGIS

One way to do it would be: First do a "Join Attributes by location" (Vector -> Data Management Tools) with your points as the Base Layer, your polygons as the Join Layer, "within&...
user avatar
  • 136
3 votes

Calculating mean value for points within polygon in QGIS

Solution 1 Using the data you provided, I get meaningful results using Join Attributes by Location (Summary), see screenshot below and be sure to make settings accordingly. Solution 2 Another option ...
user avatar
  • 40.1k

Only top scored, non community-wiki answers of a minimum length are eligible