I'm trying to replicate a nearest-neighbor analysis that returns X (one OR more than one) neighbors in either QGIS or PyQGIS.
In this output, I have a set of locations (Red Stars) that are being connected to the target hubs (Blue Circles) via nearest neighbor analysis (Pink Lines). What I'd like is to find the 2nd, 3rd, 4th, etc. nearest neighbor for my set of locations to relate to hubs.
Many methods are available for performing this in PostGIS and in ArcGIS/ArcPy but it seems like there isn't an explicit method for returning more than one neighbor using Distance to Hubs or the NNJoin plugin.
Ideally, the best method would be either PyQGIS/Python based or easily replicable via the QGIS modeler interface.
Some other examples from the net: