User Tools

Site Tools


calculate_distance

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
calculate_distance [2023/04/21 15:30] – external edit 127.0.0.1calculate_distance [2023/04/21 15:48] (current) irladmin
Line 24: Line 24:
     import sys     import sys
     import numpy     import numpy
-    from gdalconst import *+    from osgeo.gdalconst import *
     from osgeo import gdal     from osgeo import gdal
     import math     import math
     from node_utils import *     from node_utils import *
     from scipy.spatial import distance     from scipy.spatial import distance
-    import gdal 
          
     # set names for labelling the script while running     # set names for labelling the script while running
Line 52: Line 51:
          
         if (len(road_list) == 0):         if (len(road_list) == 0):
-            print "findCloserRoadCell: There are no roads in the map."+            print("findCloserRoadCell: There are no roads in the map.")
             return None             return None
          
Line 66: Line 65:
         node_road = getNodeByName(nodes_data, input_name)         node_road = getNodeByName(nodes_data, input_name)
         if (not node_road):         if (not node_road):
-            print SCRIPT_NAME, "ERROR Node", input_name, "is not in nodes_data"+            print(SCRIPT_NAME, "ERROR Node", input_name, "is not in nodes_data")
             return []             return []
          
Line 74: Line 73:
         pixelsize = dataset.GetGeoTransform()[1]         pixelsize = dataset.GetGeoTransform()[1]
          
-        print SCRIPT_NAME, "pixelsize:", pixelsize+        print(SCRIPT_NAME, "pixelsize:", pixelsize)
          
         road_cells = [];         road_cells = [];
Line 83: Line 82:
                 road_cells.append(cell);                 road_cells.append(cell);
                            
-        print SCRIPT_NAME, "There are", len(road_cells), "cells that are roads"+        print(SCRIPT_NAME, "There are", len(road_cells), "cells that are roads")
          
         distances=[]         distances=[]
Line 105: Line 104:
          
         for i in range(CELLS_PRINTING):         for i in range(CELLS_PRINTING):
-            print SCRIPT_NAME, "cell:", i, ":" ,  new_nodes_data[0]['data'][i]+            print(SCRIPT_NAME, "cell:", i, ":" ,  new_nodes_data[0]['data'][i])
                  
          
calculate_distance.1682083809.txt.gz · Last modified: 2023/04/21 15:30 by 127.0.0.1