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 ...
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(...
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) ...
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()....
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&...
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 ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
point-in-polygon × 421qgis × 149
polygon × 67
point × 51
r × 47
postgis × 46
arcgis-desktop × 44
spatial-join × 33
python × 29
overlapping-features × 29
shapefile × 25
count × 24
arcmap × 19
postgresql × 14
qgis-3 × 14
pyqgis × 11
field-calculator × 11
intersection × 11
shapely × 11
select-by-location × 11
arcgis-10.2 × 9
fields-attributes × 9
geopandas × 9
arcgis-10.1 × 8
attribute-table × 8