1

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?


Question

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.


Original_data

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

  1. Grey dots are representing addresses with a "number of inhabitants" per each location
  2. Blue Polygons include input attributes, i.e. "In_Value", "Out_Value", "Workday", all are absolute values
  3. Green Polygons for which new values "In_Value_N", "Out_Value_N", "Workday_N" have to be defined

By so far I executed following steps

  1. Calculated the number of inhabitants per each feature in "Polygons_From" using Virtual Layer (alternative 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
    
  2. Executed 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.

Union_outcome

  1. 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
    
  2. The output that I achieved.

Result


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.


References:

  • 2
    Please make the question self-contained and more clear. No need for a dump references unless you show how they are highly related to understanding the problem. :) – bugmenot123 May 10 at 11:18
  • 1
    All your polygon outlines are the same color, so it's difficult to tell which black lines are the boundaries for which layer. If your polygons are different shapes, you could calculate new values proportional to the area difference, and proportional to the population difference between the source polygon and the target polygon. But that assumes the values are evenly distributed across space and across the population. Are those valid assumptions for this data? – csk May 10 at 16:11
  • @csk, yes you are right. Alternatively, I can exclude the forest areas from the calculation via area-factor. – Taras May 15 at 13:01
  • the group by m_area looks suspicious. If you have 2 unrelated polygons with the exact same area, this query will keep only the 1st one. You likely want to group by some ID instead – JGH May 17 at 11:23
  • 1
    It is better to use an ID. You can create the unique ID if you don't have one! (using the row number or else) – JGH May 17 at 12:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.