Since QGIS now makes import/export and querying of spatial data easy, we can use the spatiaLite engine to join the intersection of both layers to the region table and then aggregate this intersections by applying max- and count-function on each region. We'll also keep the identity and the area-value of the species with the largest intersecting area.
For the presented example I'll use
Do the calculation in 2 easy steps:
SELECT
t.region AS region,
t.species AS sp_dom,
count(*) AS sp_number,
max(t.sp_area) / 10000 AS sp_dom_area
FROM (
SELECT
g.region AS region, s.species AS species,
area(intersection(g.Geometry, s.Geometry)) AS sp_area
FROM Regions AS g JOIN Sp_Distribution AS s
ON INTERSECTS(g.Geometry, s.Geometry)
) AS t
GROUP BY t.region
ORDER BY t.region
Addendum:
If you wish to calculate any other diversity measures, like Diversity- or Heterogenity-Indices, you might just run the below query (which actually is the subquery from above) and feed the resulting table to any statistic-software!
The output table will contain region's IDs, each intersecting species and the intersection area.
The intersection area, which is the species' area per polygon, is the metric that would be used for the calculation of diversity / heterogenity measures, etc. of regions!
SELECT
g.region AS regID,
s.species AS sp,
AREA(INTERSECTION(g.geometry, s.geometry)) AS sp_area
FROM Regions AS g JOIN Sp_Distribution AS s
ON INTERSECTS(g.Geometry,s.Geometry)
ORDER BY regID, sp_area ASC
I tested this on
No comments :
Post a Comment