3

The busstop pairs can be seen hereI need to measure the direct distance between busstops in meters, not taking roads/networks into account.

I have the WGS 84 Coordinates + globalIDs for 28.000 pairs.

I already imported the Busstops from a csv (UTF-8) into a point layer.

My previous atempts:

  • Distance Matrix doesn´t work, because of the huge data size 28.000 x 28.000 is too much "waste" data and the operation fails...

  • "Point Connector" tool just creates "lines" without any measurments

The output should be 28.000 Lines with the distance in meters in a CSV, or just simply the measurment in m for every busstop relation.

Any ideas?

9
  • Just in order to clarify: You want to know, how far it is from busstop A to B, then from B to C, etc. And this for every line? I guess the busstops have attributes concerning the lines?
    – Erik
    Commented Jun 8, 2020 at 12:16
  • More like. Busstop A to B, C to D, E to F. Commented Jun 8, 2020 at 12:19
  • 3
    Add some sample data and/or screenshots
    – Bera
    Commented Jun 8, 2020 at 12:24
  • 1
    just the path of a bird :D "direct path" Commented Jun 8, 2020 at 13:13
  • 1
    Btw, you coordinates are missing a decimal separator - currently they look like UTM coordinates.
    – Erik
    Commented Jun 8, 2020 at 13:50

2 Answers 2

1

Not sure I understand you but if you have the table you show you could try using pyqgis to calculate distance:

layer = iface.activeLayer() #Click layer/table in tree. I have a excel table

#https://gis.stackexchange.com/questions/266360/pyqgis-when-we-search-based-on-the-distance-between-two-points-is-the-measurem
distance = QgsDistanceArea()
distance.setEllipsoid('WGS84')

fieldnames = [f.name() for f in layer.fields() if f.name().startswith(('fr','to'))] #List fields starting with fr and to
field_to_update = 'distance' #Change to match the field you want to store distances in

with edit(layer):
    for f in layer.getFeatures():
        p1 = QgsPointXY(f[fieldnames[0]]/100000,f[fieldnames[1]]/100000)
        p2 = QgsPointXY(f[fieldnames[2]]/100000,f[fieldnames[3]]/100000)
        m = distance.measureLine(p1, p2)
        f.setAttribute(f.fieldNameIndex(field_to_update),m)
        layer.updateFeature(f)

enter image description here

0

Thank you very much for your support.

I managed to do it.

Use the plugin "PointConnector" to create lines between the busstops. Then just use the "add Geometricattribute" tool.

Easy but very effetive.

Tipp 1: Only use WGS 84 Tipp 2: Be careful while creating the from-to-list for PointConnector. Excel rounds the zeros , therefor 10 is converted to 1. Tipp 3: PointConnector: Read the Python concole if errors accur. It helps alot to understand what went wrong. Sometimes just a new project with the same steps solves the problem. Or you can use the "repair geometrie" tool

Hope this helps.

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.