Skip to main content
Edited post
Source Link
Joseph
  • 76.3k
  • 7
  • 172
  • 286

I would probably do the following:

  1. Load your point layer into QGIS and run the Split vector layer with Network as the Unique ID field. The results will be saved to a directory.

  2. Run the following code in the Python Console. It uses the same Distance matrix tool but only calculates the points for each Network and outputs the statistics including the maximum distance. Change the paths and field names accordingly:

     import glob, os, processing
    
     path = "C:/Users/You/Desktop/Folder/"
     output_path = "C:/Users/You/Desktop/Folder/Results/"
     field_1 = "Field_1"
     field_2 = "Field_2"
    
     for layer in glob.glob(path + "*.shp"):
         processing.runalg("qgis:distancematrix", layer, field_1, layer, field_2, 2, 0, output_path + os.path.splitext(os.path.basename(layer))[0] + ".csv")
    

I would probably do the following:

  1. Load your point layer into QGIS and run the Split vector layer with Network as the Unique ID field. The results will be saved to a directory.

  2. Run the following code in the Python Console. It uses the same Distance matrix tool but only calculates the points for each Network and outputs the statistics including the maximum distance. Change the paths and field names accordingly:

     import glob, os, processing
    
     path = "C:/Users/You/Desktop/Folder/"
     output_path = "C:/Users/You/Desktop/Folder/Results/"
     field_1 = "Field_1"
     field_2 = "Field_2"
    
     for layer in glob.glob(path + "*.shp"):
         processing.runalg("qgis:distancematrix", layer, field_1, layer, field_2, 2, 0, output_path + os.path.basename(layer) + ".csv")
    

I would probably do the following:

  1. Load your point layer into QGIS and run the Split vector layer with Network as the Unique ID field. The results will be saved to a directory.

  2. Run the following code in the Python Console. It uses the same Distance matrix tool but only calculates the points for each Network and outputs the statistics including the maximum distance. Change the paths and field names accordingly:

     import glob, os, processing
    
     path = "C:/Users/You/Desktop/Folder/"
     output_path = "C:/Users/You/Desktop/Folder/Results/"
     field_1 = "Field_1"
     field_2 = "Field_2"
    
     for layer in glob.glob(path + "*.shp"):
         processing.runalg("qgis:distancematrix", layer, field_1, layer, field_2, 2, 0, output_path + os.path.splitext(os.path.basename(layer))[0] + ".csv")
    
Source Link
Joseph
  • 76.3k
  • 7
  • 172
  • 286

I would probably do the following:

  1. Load your point layer into QGIS and run the Split vector layer with Network as the Unique ID field. The results will be saved to a directory.

  2. Run the following code in the Python Console. It uses the same Distance matrix tool but only calculates the points for each Network and outputs the statistics including the maximum distance. Change the paths and field names accordingly:

     import glob, os, processing
    
     path = "C:/Users/You/Desktop/Folder/"
     output_path = "C:/Users/You/Desktop/Folder/Results/"
     field_1 = "Field_1"
     field_2 = "Field_2"
    
     for layer in glob.glob(path + "*.shp"):
         processing.runalg("qgis:distancematrix", layer, field_1, layer, field_2, 2, 0, output_path + os.path.basename(layer) + ".csv")