Using QGIS 3.10.1, I am attempting to rasterize some demographic polygons, and then apply a filter (Gaussian) to create a smooth/graduated surface. This works fine for some of my values (e.g. total population and housing units), but I am running into problems rasterizing averages (e.g. age and income). Average age, median income, and total population are all attributes of each demographic polygon.
When I rasterize the average age, for example, the values in the raster output are not weighted to the number of people, and this error gets magnified when I apply a filter. Imagine a feature that has 1000 people and an average age of 60 and the surrounding polygons have 10 people each and an average age of 20. When you use rasterize it creates a cell that is bigger than and contains all these features, but the rasterize algorithm only asks for the burn value and as a result, it averages the average age of all the features without regard to the number of people. As a result, the raster cell for that area erroneously shows a value of 22. If it was correctly weighted for the number of people it's value would be 59.
Because the area that I am looking at is a large area and includes urban polygons that are very small and rural ones that are very big it is inevitable that some cells span multiple polygons, and that there will be some overlap.
Are there any tools that can rasterize and apply a filter using 2 variables (a burn variable and a weight/quantity variable or can anyone recommend a workflow to address this issue?
One possible solution I've been exploring is to create duplicate geometries based on the total number of people. For example, a polygon with an average age of 40 with 10 people would get 1 polygon and a neighboring polygon with an average age 35 over 100 people would get 10 identical polygons so that when they go into the rasterize algorithm they are weighted appropriately. That could solve the rasterize issue, but I still would have the weighting problem when I apply the Gaussian filter.
Another way I am thinking about solving this issue is to rasterize/filter using aggregate data, and then use the raster calculator as the final step to divide the aggregate data by the total numbers of population or households.