0

I have a network consisting of more than 300 nodes that have coordinates as attributes. My node attributes look like this:

print(EL.nodes(data = True))
[(1, {'label': 'Aachen', 'Country': 'DE', 'Population': 248960.0, 'lat': 50.7762, 'lon': 6.0838}), ...]

I would like to plot the nodes and edges on a map, so respecting the lat and lon information I have. I tried using this code:

pos = nx.spring_layout(EL)
nx.draw(EL, nx.get_node_attributes(EL, 'pos'), with_labels=True, node_size=1)

But it gives me an error Node 1 has no position Looking online, I tried to use alternative solutions using Basemap or mplleaflet but I cannot install either via the Anaconda prompt. If I try via the Anaconda navigator, I get this:


Output in format: Requested package -> Available versions 

I've been browsing similar threads on Stackoverflow where people had similar problems, but nothing works. For instance, I checked those threads: Python basemap module impossible to import

Drawing nodes with coordinates in correct position using NetworkX/Matplotlib

How to fix "UnsatisfiableError: The following specifications were found to be incompatible with each other: - pip -> python=3.6"

Can anyone help me plot this network? Thanks a lot

FlyingTeller
  • 13,811
  • 2
  • 31
  • 45
Djoustaine
  • 39
  • 5
  • 1
    Hey, "basemap" is depreciated since years (it has been superseeded by "cartopy")... I have no experience with "NetworkX", but if you simply extract your coordinates and values as lists, you could give EOmaps a try... (I'm the dev) ``conda install -c conda-forge eomaps`` https://github.com/raphaelquast/EOmaps – raphael Mar 24 '22 at 10:55

0 Answers0