I am trying to use something similar to the least cost paths in SAGA in order to draw a line through various points, grouped by unique ID levels, and ordered by longitude, and restrict it to a raster. I have access QGIS 3.22. While I have access to arc pro and this may be something that can be done with network analyst or spatial analyst, the focus of this request is QGIS. Least cost path seems to work for connecting simple points that may not have more than one group, but unless this can be performed in batch over several groups (~89) , it doesn't offer much efficiency.
I am able to group by ID and order by longitude to draw lines based on Euclidean distance using points to path, but I do not want Euclidian distance and I want to restrict to a raster. Points to path would suffice if it could be contained within a raster however.
I know a similar questions has been asked at the link below, but I am trying to link multiple points (trace the path) by a group and also to draw the line from the furthest west point through all points to the furthest east point (ordered by longitude). While I am competent in R and there may be a different workaround, the focus of this post is again QGIS...
Calculating shortest distance between points within polygon using QGIS?