I would like to find out the average distance from high schools (represented as a point in QGIS) to libraries (represented as another point in QGIS) in New York's 32 districts.
I have already calculated the distance to nearest library for each individual high school, but I need the result to be averaged at the district level. in other words, the result should be something like: "in district 5, the average distance between a high school and a library is 2 miles".
Is there any way to do this without manually calculating the average distance for each district, plotting this average into a table, and joining this table to the vector layer for districts?
aggregate('High Schools', 'mean', "Distance to Library",intersects($geometry,@parent))
. Substitute the name of your High Schools layer and the name of the "distance to library" field in that layer.