TransWikia.com

Counting points in a polygon for a subset of my points layer?

Geographic Information Systems Asked by NS31 on January 31, 2021

I have a points layer with a column that separates the points into different types (eg ‘high’, ‘medium’, ‘low’).
I need to count the number of points within polygons, for each of the different types.
At the moment, I’m doing it by creating a separate points layer for each of the types and then running the points within polygon tool for each of them.
I was just wondering if there’s a tool that lets you run points within polygon but with conditions, so that I could run it for those points where the type is ‘high’ etc?

One Answer

SQL is the answer !

You can achieve this using the DB Manager of QGIS.

You choose Database / Database Manager / Database Manager then Virtual Layers / Qgis Layers you can then try queries like the following :

SELECT count(*), pt_type from pt_layer, poly_layer
where st_intersects(pt.geometry, poly.geometry)
group by pt_type 

pt_layer being your point layer and poly_layer being your polygon layer...

You can then load the result in the layer manager.

Answered by snaileater on January 31, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP