Making graph with shapefile

Hi, I am new to Julia and need some help regarding construction of graph with shapefile.
I have shapefile that contains polylines and want to get the shortest path using Dijkstra’s algorithm.
The thing is, in order to use Dijkstra’s algorithm, I need a graph.
I am wondering if I can construct a graph with the shapefile that contains polylines?
Maybe I need to add vertices at the end of each polylines to fix the source and destination points.
Is there any suggestions or packages that I can refer to?

Thanks in advance.

Hi @Michelle_Ko!

I don’t think there is anything ready-baked for you, you might have to combine several packages:

Let me know if you need more help!

Hi @gdalle

Thanks for the reply but I already imported the shapefile into Julia and I figured out how to make a simple graph and add vertices and edges.

To explain more specifically, I have an electricity network in shapefile and I want to measure the shortest path from starting vertex to destination vertex. In order to do this, I thought I need to construct a graph using the polyline data since ‘dijkstra_shortest_paths’ let me measure the shortest path of a graph. For example,

Polyline(Rect(-7.89573e6, 5.24276e6, -7.89571e6, 5.24284e6), Int32[0], Point[Point(-7.89573e6, 5.24276e6), Point(-7.89571e6, 5.24284e6)])

is one electricity line that connects two points Point[Point(-7.89573e6, 5.24276e6) and Point(-7.89571e6, 5.24284e6)]) and

Polyline(Rect(-7.89573e6, 5.24276e6, -7.89579e6, 5.24299e6), Int32[0], Point[Point(-7.89573e6, 5.24276e6), Point(-7.89574e6, 5.24294e6), Point(-7.89579e6, 5.24299e6)])

is another line that connects three points. And the points are in the form of coordinates in wgs84 (spatial reference).

Are there any ways that I can construct a graph that mimic the network of these electricity lines? Thank a lot in advance.

I think you have to manually extract the distance between vertex coordinates from the Polyline objects, in order to turn it into weights. Does that answer your question?