6

I'm using QGIS 3.28 and I need to find the furthest point from an certain origin.

For reference, this is a Fiber to the Home (FTTH) project.

Example

Imported data:

  • The pink dot on the center is the point of origin;
  • The thinner green lines are the underground FTTH cables;

Created data:

  • 4 polygons (blue, green, purple and red) that divide a bigger zone;
  • The thicker lines (blue, red, purple and green) belong to a multistring layer I created. The purpose of them is to represent the path the cable does from the starting point (pink dot) to the furthest point (blue circle);
  • The blue circles I manually placed them on the furthest place from the point of origin (while bearing in mind the path that the cable does).

So, what I need in QGIS is to create an easier and faster way to find the places I manually found and placed the blue circles. Until now I tried to merge the underground cables layer (from numerous features to a single one - MultiLineString), create a shape containing the point of the starting point and using several tools and methods: Shortest path, Least Cost Path, Distance Matrix, Youtube and forums... And I haven't managed to find a way to do it.

4
  • Is the furthest point you're manually plotting a property or DP, is there an exsisting point already there?
    – ScoGer
    Commented Mar 10, 2023 at 15:51
  • There's no existing point. Having merged all the lines, I can't find the endpoint (s), or there is?
    – Andre R
    Commented Mar 10, 2023 at 15:59
  • You could just go around in circles for ever. You mean furthest point for all possible least cost paths?
    – Bera
    Commented Mar 10, 2023 at 16:46
  • Yes, exactly! I'm doing my best to explain myself because i'm not a native English speaker ;)
    – Andre R
    Commented Mar 10, 2023 at 16:48

2 Answers 2

8

Few steps to this process but it may be more efficent than the way you're currently working it out - it would be pretty easy to add this into a graphical model/python script too so you dont need to run it manually each time.

Probably much better ways to get it done too but here is my attempt to assist.

Start Image Starting Image

Step 1; Merge Vector Layers - select all the layers required to make a coherent network from your point of intrest to the furthest 'points' in your networks via lines.

Step 2; Extract Vertices - Extract Vertices of your line layer. Image of Extract Vertices

Step 3; Select by Location - Select the new Vertices Layer comparing to your polygon layer. Ensure you've selected your polygon before hand and click selected features only.

Image of Select by Location

Step 4; Shortest path Point to Layer - Use your network as the representing network layer (Cables/Duct), Click on the ... next to start point and select your Starting location or point of intrest. End points is your new Vertices layer (tick selected features only)

Image of Shortest path Point to Laye

Step 5; Open attribute table - Sort by cost High > Low (Highest cost line is the furthest point from your POI)

Image of Attribute table and flashing the highest cost future Image of Attribute table and flashing the future

Final Overview of all polygons completed Image of Final Overview of all polygons completed

8

Maybe you can use Service Area From Point:

This algorithm creates a new vector with all the edges or parts of edges of a network line layer that can be reached within a distance or a time, starting from a point feature. The distance and the time (both referred to as "travel cost") must be specified respectively in the network layer units or in hours.

I have created a for loop which calculates it multiple times for increasing distances, (mostly for fun). You can just execute the tool manually multiple times.

I started at 50000 meters and increased it until it reached all the furthest ends in the road network:

import random

#Change these two lines to match the names of your layers
line_layer = QgsProject.instance().mapLayersByName("roads")[0]
start_point_layer = QgsProject.instance().mapLayersByName("start_point")[0] #There must be only one point in the layer

#Find the start point
startpoint = [p.geometry() for p in start_point_layer.getFeatures()][0]

colornames = line_layer.renderer().symbol().color().colorNames() #Create a list of color names
areas = [] #A list to hold all the service areas generated
#Create service areas for the distances 50000,55000,60000,65000,...,85000
for distance in range( 50000, 90000, 5000):
    print(f"Calculating service area for distance {distance}...")
    area = processing.run("native:serviceareafrompoint", 
        {'INPUT':line_layer,'STRATEGY':0,'DIRECTION_FIELD':'','VALUE_FORWARD':'',
        'VALUE_BACKWARD':'','VALUE_BOTH':'','DEFAULT_DIRECTION':2,'SPEED_FIELD':'',
        'DEFAULT_SPEED':50,'TOLERANCE':5,
        'START_POINT':startpoint,#'488017.532000,6335277.862250 [EPSG:3006]',
        'TRAVEL_COST2':distance,'INCLUDE_BOUNDS':False,'OUTPUT_LINES':'TEMPORARY_OUTPUT'})["OUTPUT_LINES"]
    area.setName(str(distance)) #Set the layer name
    rend = area.renderer()
    color = rend.symbol().color()
    newcolor = random.choice(colornames)
    color.setNamedColor(newcolor) #And a random color
    rend.symbol().setWidth(0.5) #Line width
    areas.append(area)

QgsProject.instance().addMapLayers(areas)

enter image description here

It wasnt far enough.

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.