Questions tagged [networkx]

NetworkX is a Python package for the creation, manipulation, and study of the structure, dynamics, and functions of complex networks.

Filter by
Sorted by
Tagged with
0
votes
0answers
20 views

Assign shape file attribute as a vertex label in networkx

I have a shapefile which has attribute 'num' and I want it to use it as vertex ID. It means if I print G.nodes() and G.edges() then the vertex IDs should appear as per attribute 'num'. But in networkx ...
0
votes
0answers
40 views

Preserving Geometry of Shape file after merging edges using Networkx

I have a stream network and I want it to convert in a graph like data structure having vertices with only degree 1 and 3. The degree of the vertex is the number of edges incident to that vertex. The ...
0
votes
0answers
44 views

Import graph from networkx

I have prepared an aggregated DiGraph using big data from a Spark Cluster. The resulting graph structure looks like this: - Nodes are numbers (bus stop numbers) and have a 'pos' attribute with GPS ...
0
votes
2answers
78 views

How to create a weighted square lattice as well as a weighted network graph

I am planning to create a weighted square lattice for different sizes, and then label each edge with its associated weight. It's similar to this thread "How to load a weighed shapefile in networkX" ...
1
vote
1answer
49 views

networkx shortest path error

I am trying to implement single_source_dijkstra_path algorithm of the networkx to define the shortest path from a node to all nodes in the network. There are six sources in total, and I want to ...
2
votes
2answers
570 views

Generating Steiner tree using Network X in Python?

I'm trying to generate a Steiner tree in Python using NetworkX. I have a range of geolocated nodes saved in the GeoJSON format, allowing me to visually validate the outputs in QGIS. A radially ...
7
votes
3answers
675 views

Shortest path between one point to every other points

I am trying to figure out how to find all the shortest paths from each point and each node of a line to the other points and nodes of lines of this map. I have tried to do it in Python using NetworkX....
2
votes
0answers
36 views

Selecting weights while transferring from shapefile to network

I have a shapefile representing roads (LineStrings) and I need to transfer it to a networkx type (with the lengths as weights) so I can do some network analysis. I have used the s2g library to do so ...
2
votes
0answers
305 views

Networkx shortest paths for two point layers

I have a task to know the best way from houses to subway station. There are three types of data on a picture below: orange dots are the entrances to subway stations violet dots are centerspoints of ...
1
vote
0answers
31 views

Error while importing networkx module in QGIS 2.18.16 [duplicate]

I am trying to import networkx module in QGIS 2.18.16 but getting the error message. Any suggestions? Traceback (most recent call last): File "<input>", line 1, in <module> File "C:/...
0
votes
0answers
91 views

NetworkX - Indexed Spatial node queries?

I'm trying to extract a Road Network from a large set of GPS point data gathered from vehicles. I plan on representing the final network in terms of a NetworkX graph of G(V,E) I have implemented ...
0
votes
1answer
563 views

(OSMNX, Folium) Plotting and Isochrone on a Folium Web Map

I am trying to plot an isochrone map like the one in this example onto a Folium Web Map. I understand how to set up the colors for time/edges/nodes/polygons... I just don't understand how I could get ...
3
votes
0answers
69 views

QGIS Python all_simple_paths

I have my shapefile imported as shown below: I calculate all all_simple_paths from root to all leaf nodes of a graph. Red dot is a node to start with. It gives me all path from red dot to green dot. ...
2
votes
0answers
173 views

Creating a Graph from a lines AND a points shapefile in networkx using read_shp

I am trying to use networkx for analysing networks which I represented in QGIS as a line shapefile and a point shapefile. If I import only the lines shapefile using networkx.read_shp('lines.shp') I ...
3
votes
0answers
84 views

Merge linestrings between two nodes based on condition

I am working with dense openstreetmap road networks and I am trying to simplify the network. To simplify it, I would like to merge all the linestrings that only intersect with one other line, as shown ...
1
vote
0answers
217 views

NetworkX read_shp works on Python 2.7 but not on Python 3?

I was trying to implement the same code in Python 2.7 and Python 3.0 opening the same file from the same directory using NetworkX's read_shp function. One, using Python 2.7 IDE and the other is ...
1
vote
1answer
129 views

ArcGIS Server Geoprocessing Service failing on repeat call

Trying to create a geoprocessing service on ArcGIS for Server 10.3 to do some routing on a networkx graph. The service only works on the first call. It fails on subsequent calls. I note this because ...
1
vote
1answer
404 views

Getting KeyError when using shortest_path of NetworkX and ShapeFile

I have a shapefile of all street segments in Los Angeles County that I have made sure is clean. I am able to use the QGIS Road Graph plugin to calculate various shortest paths, see attached as my ...
1
vote
2answers
1k views

How to load a weighed shapefile in networkX

I have a added a length table in every line of my shapefile which contains lines that represent roads, and I want to create a weighted graph with this data using the length table as weights. I have ...
3
votes
1answer
854 views

Programmatically infer start and end points from a Polygon with linear characteristics

Question: Given a Polygon exhibiting linear-like qualities (long and thin, with clear extremities upon visual inspection), is there a reasonable/defensible order of operations to compute "start" and "...
1
vote
1answer
273 views

Create MultiDiGraph from Shapefile using Networkx

I have a .shp with a road network that I want to represent in a Graph with NetworkX. I have used it for further analysis such as shortest distance etc. The problem is the function in Networkx converts ...
1
vote
0answers
203 views

How to convert a coordinates to indice array (vice versa) in a NetworkX graph?

I want to use a raster for a A* and bidirectional Dijkstra path analysis in NetworkX. I am using Python for this project. Raster example (it's a png file converted when uploaded, but the real problem ...
1
vote
0answers
194 views

Read osm map tags using networkx

I downloaded part of a map using JOSM, and saved it in .osm. I am reading the same file using networkx in python. When I read the attribute of an edge, it gives me something like this: {'ShpName': '...
1
vote
0answers
586 views

NetworkX or Shapely to get the simplified graph between 2 Graphs?

I'm having trouble whether which approach to take in simplifying a graph from another graph. It's not a basic graph difference but the other way around. I want to further simplify a graph of a street ...
4
votes
4answers
5k views

How to (re)install gdal in python3 (mac)?

I am stuck trying to install gdal, running python3.6 on a Mac. When I run pip install gdal I get errors of Failed building wheel for gdal error: command 'gcc' failed with exit status 1 Command "/...
6
votes
2answers
2k views

From shapefile to Python NetworkX?

I am being baffled by how apparently poorly NetworkX reads a shapefile and builds a graph out of it. Below is a graphical example of a fake network built with 27 polylines all snapped together, so ...
6
votes
1answer
505 views

Finding out and editing specific rows of attribute table in line shapefile using Python?

I got a line shapefile tc_line with 166 rows (line segments), and the figure below was its atttribute table: Originally, I had to manually select lines (these lines were lines upstream and around ...
3
votes
1answer
3k views

How to calculate edge length in Networkx

I want to export a directed weighted graph from a shapefile. I used read_shp function of the Networkx package to export the directed graph which perfectly matches my needs. But I am unable to ...
1
vote
1answer
295 views

Inaccurate output (missing features) while reading a shapefile into networkx

I am doing some work with networkx, which involves the conversion of a point and polyline shapefile into a graph with nodes and links. The documentation about the read_shp() method states that it: ...
2
votes
1answer
292 views

OSM2PO Postgres to graph for A*

I have created a directed graph from the nodes stored within my Postgres db but the resulting graph doesn't seem to be fully connected and as a result my shortest path algorithm is not able to find a ...
1
vote
1answer
1k views

Problem with read_shp() in NetworkX

I'm trying to convert a shapefile of only line geometry (a street network) to a NetworkX graph to run some connectivity algorithms on it. I'm running into this issue: File "/Library/Frameworks/...
2
votes
2answers
1k views

NetworkX: Saving Shortest path of OpenStreetMap data as an OGR friendly format

I am using this script to import OSM data into a GIS based model. This has to run independent from any software package such as QGIS, PostGIS, or ArcGIS. I then create a shortest path between two ...
1
vote
1answer
1k views

How to visualize shortest path that is calculated using Networkx?

I have a graph G (made from a road network shapefile), and a source node S, and a destination node D. I have calculated the length of shortest path using single_source_dijkstra_path_length, but now I ...
0
votes
2answers
98 views

Adjacency matrix in GRASS

I have a line shapefile that I use as network. I connect a set of point to it using "v.net operation connect" command. . My questions are: (i) how can I get the list of neighbors for each "connected"...
3
votes
1answer
734 views

nx_spatial does not read all shapefile features

I have a polyline shapefile for a road network. The roads are split at every intersection (node), e.g. if two roads intersect at one point, then they are split into four links(edges). So using the ...
3
votes
2answers
1k views

Making routable graph from Point and Line shapefile using Networkx?

I have one shapefile which consists of all the streets in the study area, and another shapefile which has points representing origins and destinations. Is it possible to find shortest path between ...
2
votes
1answer
990 views

Does not show shortest path in networkx (in QGIS)

I used the following commands (in qgis console) to get the shortest path with astar algorithm. But the result shows 'NetworkXNoPath' every time. Why was that? Please help me to find a solution to this ...
4
votes
2answers
610 views

Create network from shapefile without ArcGIS?

I want to perform shortest-path analysis on a network whose edges represent real-world roads and whose nodes are buildings or other locations. I have the shapefile for the area I'm interested in. ...
14
votes
0answers
1k views

Converting raster (array) to NetworkX graph and do * search? [closed]

I want to use a slope-raster for a a_star path analysis in NetworkX. I am using Python for this project. My test raster looks like this First I read in the raster with GDAL input_raster = "slope5....
2
votes
2answers
2k views

How to install networkx python in QGIS?

How to install and how to compile networkx python on QGIS? I always get an error that no module named networkx in the console of QGIS I copied the file networkx in C:\Program Files\Quantum GIS Lisboa\...
3
votes
0answers
612 views

problem in read_shp() to generate a networkx.DiGraph from point and line shapefiles

I tried to use the Python module networkx and specifically the read-shp () to ensure the transformation of a graph to a file sharpe but I always find this error noting that this is the first time I ...
5
votes
1answer
2k views

How to restrict or block certain paths in NetworkX graphs?

I am trying to calculate shortest path between 2 points using Dijkstra and A Star algorithms (in a directed NetworkX graph). At the moment it works fine and I can see the calculated path but I would ...
10
votes
2answers
7k views

Point (of a linestring) within Polygon using ogr and Python

I'm currently working on a project in which I need to build a topological network out of the geometry features I find in shapefiles. So far using Ben Reilly's open source project I've managed to ...
9
votes
3answers
2k views

How to populate an undirected graph from PostGIS?

This question is more related to resources that I might not have identified yet, although I've been searching the web for a while. In the project I'm working at the moment I need to run a shortest-...
10
votes
5answers
2k views

How to convert line simple features to topological network?

using Gdal/ OGR is there a way to convert a shp, kml, or PostGIS line layer into a network of nodes and segments so it can be used in packages such as networkx?