I'm working with a point layer (airports from OpenFlights), and I want to create a map of distance to the nearest airport.
I thought I might be able to do this by using radial fill on the voronoi polygons.
I created the voronoi polygons. These included the original fields from the airports layer, so I have (lat, lon) of the airport for each polygon.
When it comes to styling, I tried to create a radial fill centred on the airport. It's very easy to center on the centroid, but the centroid is nowhere near the airport in most cases.
I set up a radial fill with reference points (0.5,0.5) and (1.0,1.0), mode: reflect.
You can see here the result.. how can I centre it so the brightest point in the radial fill for each polygon aligns with its airport?
There doesn't seem to be an option to set a centre point coordinate. The data-driven option to the right of the centroid isn't for setting up a coordinate, it's a binary field for the centroid setting.
I could try computing an offset (between the centroid and the airport) but there aren't any data-driven options for the offset fields, so they would need to be set manually.
Shapeburst fill isn't suitable for this (although it does give some interesting results!)
I've also looked at raster and svg fill, but again these appear to offer no way to set the centre coordinate (I suspect they align using the bounding box)
Is there some way to do this with QGIS? Am I overlooking something?
Also, is there way to prevent QGIS from scaling the gradients to fit the bounding box? I've tried switching from 'object' to 'viewport' but the polygons all vanish.
Dmitry helped fix the first question - aligning up the gradients to the airport locations
I added 6 new real fields to my polygons with the field calculator...
xmin -> x_min(bounds($geometry)) ymin -> y_min(bounds($geometry)) xmax -> x_max(bounds($geometry)) ymax -> y_max(bounds($geometry)) xoff -> (airportx - xmin)/(xmax-xmin) yoff -> 1 - ((airporty - ymin)/(ymax-ymin))
I then used the values of xoff and yoff in the data-driven x1 and y1 fields. The bounding box appears to be in the bottom-left, not the top-left, hence the "1-" in the last function.
Results now look a lot better...
This still leaves me with the problem of the best option for x2 and y2; for now, I've set the second control point to (1,1). Need to have a think about that.
Given that this is pegged to the bounding box, I suspect the answer to the second question (can I avoid the gradient being scaled) is 'no' :)
So I'll probably do this as a python gdal raster script.. also has the advantage that I can use PostGIS to calculate spheroid distances.