My previous question was Inherited values between polygons in QGIS?. However, I was not satisfied with the quality of my results. Therefore, I am looking now for additional methodologies that may augment my desired output with a stronger background.
Task remains the same to transfer values from Blue polygons into Green polygons based on a certain aspect/ratio. The previous time I have used
$area-factor after applying
'Union'-function as was suggested in Calculating proportional area of polygon within another layer's polygon using QGIS?
What are Spatial Analysis techniques that will give me a certain ratio for calculating new values?
I am not sure if it is about the spatial distribution of points and spatial pattern analysis. Perhaps someone can refer me to any sort of books, articles, PhD/MSc thesis, scientific outcomes.
Alternatively, I can work with the number of addresses in each sub-polygon.
Disclaimer: I do not have much experience in Spatial Statistics.
Additionally, to two previous polygons, I now have an extra point layer that represents inhabitants via address.
In total, there are three shapefiles, see the image below
- Grey dots are representing addresses with a
"number of inhabitants"per each location
- Blue Polygons include input attributes, i.e.
"Workday", all are absolute values
- Green Polygons for which new values
"Workday_N"have to be defined
By so far I executed following steps
Calculated the number of inhabitants per each feature in
Join attributes by location)
SELECT PF.*, SUM(EWjeAdr) AS s_EW FROM Polygons_From AS PF LEFT JOIN Trial_EW AS TEW ON contains(PF.geometry, TEW.geometry) GROUP BY PF.id
Union-function on the output (Stage 1) and
"Polygon_To"and deleting redundant and empty records. Now each feature is a single unit even it was earlier a part of
"Polygon_To", check the image below.
Calculated the number of inhabitants per each feature in Stage 2 output, the same way as was done in Stage 1. Than calculated new values as the original value multiplied by the ratio between the number of inhabitants in a Green polygon part to the number of inhabitants that are in the Blue cell to which the Green polygon part belongs to. And produced the result.
WITH inhabitants AS ( SELECT PM.*, SUM(EWjeAdr) AS m_EW FROM Polygon_Middle AS PM LEFT JOIN Trial_EW AS TEW ON contains(PM.geometry, TEW.geometry) GROUP BY PM.geometry ), calculations AS (SELECT i.*, In_Value*m_EW/s_EW AS In_Value_N, Out_Value*m_EW/s_EW AS Out_Value_N, Workday*m_EW/s_EW AS Workday_N FROM inhabitants AS i) SELECT ST_Union(c.geometry), c.FLAECHEID, ROUND(SUM(In_Value_N),2) as In_Value_N, ROUND(SUM(Out_Value_N),2) as Out_Value_N, ROUND(SUM(Workday),2) as Workday FROM calculations As c GROUP BY FLAECHEID
The output that I achieved.
Since last time I have overcome the issues about maintaining all the geometries that were missing. It was about
LEFT JOIN and the
NULL output of
contains(PM.geometry, TEW.geometry) command.