Closed lead8000 closed 1 year ago
Thanks for using OSMnx! Please re-read the contributing guidelines and the new issue template you saw when you opened this issue. As the template noted, your issue will be automatically closed if you didn't provide all of the information requested in the template, because we need this information to be able to troubleshoot your issue.
First of all, thank you @gboeing for your quick response to my problem, and secondly, happy holidays. I have solved the template problem. My initial question was a how-to
question, but I have realized that it is more of a package issue, because if curated data is not provided, it would have to be clarified somewhere in the documentation or examples.
Here I can show you the result of plotting using the data provided by G.edges()
, and here the result of plotting using the osmnx.plot_graph()
function of the package.
This problem with your code does not appear to have anything to do with OSMnx itself. The coordinates of the edges are correct and precise per what's on OSM. If you provide a couple of OSM ways and nodes whose coordinates do not match what OSMnx says they should be, we can investigate further. Otherwise this just appears to be an issue with how you're plotting with pygame.
My way of painting may not be the best or the clearest, but I simply take each edge provided by OSMnx
and draw a line.
If you look closely at the images I showed you earlier (my painting and its painting) you will notice that there is something strange. Maybe it makes sense because they are consistent when painting the streets with osmnx.plot_graph()
, but that is not clear from the documentation or the examples.
@gboeing my argument is that I can draw the lines wrong, but I do not invent additional lines, because each line corresponds to an edge provided by G.edges()
.
I do not use or support the pygame package so I cannot speak to it. If you have a specific question about drawing with pygame, you'll have to ask its developers or user community. Regarding OSMnx, if you believe the problem is with incorrect coordinates, like I mentioned earlier, please provide us with the IDs of specific OSM ways and nodes whose coordinates do not match what OSMnx has in its graph, so we can investigate further. But, aside from pygame, you can plot the graph's edges with or without OSMnx, and you can see it is correct:
import osmnx as ox
point = (23.1021, -82.3936)
G = ox.graph_from_point(point, dist=1000, retain_all=True, simplify=True, network_type='drive')
G = ox.project_graph(G)
# plot with OSMnx directly
fig, ax = ox.plot_graph(G)
# plot the edges with GeoPandas/matplotlib
edges = ox.graph_to_gdfs(G, nodes=False)
ax = edges.plot()
@gboeing thank you very much for your support.
I am doing an academic project and this mapping thing has taken me a long time, at another time maybe I will take it up again and incorporate it into a feature later and then I will be able to tell you with better certainty where is the "inconsistency" I find, maybe there isn't and what I need is a little more information that I didn't find in the documentation.
Happy new year! :partying_face: :tada:
Problem description
osmnx.plot_graph()
function.osmnx.plot_graph()
function.Environment information
conda list
orpip list
then paste the output between the two "details" tags below)Code
This is the code I use to plot with pygame. The only thing I do is to paint the streets with the exact values provided by the
G.edges()
function.This is the code of
map.py
.And this is the code of
window.py
.