It is probably a noob question but I'm still a beginner with maps and these libraries.

I used OSMnx, NetworkX and GeoPandas the draw a map with two polygons on it.

Each polygon have the begin with a "main node" (I have only two) and then to two different nodes which should be at a specific location which is according to angle and distance from the main nodes.

I plotted the map with the two polygons and everything is fine but when I wanted to transfer it to Folium graph, there is nothing on it.

col = ['black','blue'] #colors for main nodes
col2 =['red','yellow'] #color for other nodes

fig, ax = ox.plot_graph(G, close=False, show=False)
for i in range(len(df)):
    lon = df.iloc[i]['LON']
    lat = df.iloc[i]['LAT']
    ax.scatter(lon, lat, c=col[i], s=80) #plot two main nodes

poly_l = []   #List of two polygon

for i in range(len(df)):
    clon = df.iloc[i]['LON']
    clat = df.iloc[i]['LAT']
    stopA = df.iloc[i]['endA'] 
    startA = df.iloc[i]['startA']
    loci = (clat,clon)
    rad = float(df.iloc[i]['radius'])
    loc2,loc3 = find_angles(loci,stopA,startA,rad) 
    loc = (loci[1],loci[0])
    poly = Polygon([loc,loc2,loc3])
    ax.scatter(loc2[0], loc2[1], c=col2[i], s=80)
    ax.scatter(loc3[0], loc3[1], c=col2[i], s=80)

for polygon in poly_l:
    patch = PolygonPatch(polygon, fc='green', ec='none', alpha=0.3, zorder=-1)

graph_map = ox.plot_graph_folium(G, popup_attribute='name', edge_width=2)

this is the map after plt.show

enter image description here

and this is the Folium map:

enter image description here

How can I save my plotting on my map?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.