Different coordinates for same node for different queries using osmnx

Hello OSM-Experts,
i am quite new to OSM and I have stumbled across a behaviour that I can’t explain. I am working with python (3.9.12) and osmnx (1.3.0). I don´t know, if the behaviour is related to OSM itself or OSMNX. I will reach out to OSMNX as well.

I want to extract the railway graph for a specfic polygon and i am using the graph_from_polygon method.

Depending on the query i get different coordinates for the same node [245813931] and i checked the map by hand “48.3663241, 10.8775063” seems to be the correct coordinate for that node. I tried to create a minimal example with the bbox_polygon but here the error doesn´t occure any more.

Did someone had a similar problem? I couldn´t find anything in the forum yet.
I have worked with over 1000 different polygons and this occured only once.

I would love to hear some of your thoughts! If you need more information, just reach out to me :slight_smile:

Kind regards,
Christopher

from shapely import Polygon
bbox_polygon = Polygon([(10.871783363942845, 48.366481050166925),
 (10.871783363942845, 48.37955378097544),
 (10.884697476460012, 48.37955378097544),
 (10.884697476460012, 48.366481050166925),
 (10.871783363942845, 48.366481050166925)])
poly_lat = [10.88232812402611, 10.882494774687233, 10.88264578006929, 10.882806333458173, 10.882910924777676, 10.883209680271474, 10.883304029721502, 10.883570718463762, 10.88365395659814, 10.883886121081693, 10.883957480897683, 10.88415298191619, 10.88421180592135, 10.884368842271225, 10.884414588539242, 10.884531713608958, 10.884563960768704, 10.884640095851452, 10.884658546963395, 10.88469299117535, 10.884697476460012, 10.884689913174126, 10.884680391567525, 10.884630891302365, 10.884607450824594, 10.884516470564435, 10.884479327498292, 10.88434770645092, 10.884297203338507, 10.884126155171408, 10.884062757647593, 10.883853859274073, 10.88377815176632, 10.883660097406766, 10.883498085080285, 10.883367484899491, 10.883277447576377, 10.882989852867759, 10.882888394484917, 10.882567982177678, 10.882456093153941, 10.882105990953244, 10.881984763459771, 10.881799636225868, 10.881203476553134, 10.881015152844475, 10.88088777334928, 10.880495111456984, 10.88036102637402, 10.879950130495942, 10.879810609396738, 10.879385369993242, 10.879241733875377, 10.87880617708929, 10.878659785873902, 10.87821803543356, 10.878070275096015, 10.877626513284074, 10.877478782739153, 10.877037210829634, 10.876890908695131, 10.876455707192184, 10.876312218555965, 10.875887507648434, 10.875748190963671, 10.875337991538782, 10.875204165771171, 10.874812361372422, 10.874685293520622, 10.874315593599906, 10.874196486707024, 10.873852391528485, 10.873742373297743, 10.873427140809424, 10.87332725293154, 10.87304386793001, 10.872955056223176, 10.87270620210145, 10.87262930755701, 10.872417340894085, 10.872353091712782, 10.872180019957112, 10.872129024651136, 10.871996487099523, 10.87195922872596, 10.871868480985798, 10.871845312566139, 10.871797214643411, 10.871788355812715, 10.871783363942845, 10.871788898860679, 10.87182706115855, 10.87184693770172, 10.87192789367423, 10.871961923919512, 10.872084907845961, 10.872132769838416, 10.87229661798822, 10.872357858779031, 10.872561020399607, 10.872635060324935, 10.872875612297028, 10.872961750457769, 10.873095349506581, 10.873702483442393, 10.873841842963913, 10.873937362109773, 10.874239260256129, 10.874344776939525, 10.874675256655634, 10.87478980843225, 10.875145855243922, 10.875268397200399, 10.875646763254915, 10.87577617754014, 10.876173411236534, 10.876308517260192, 10.87672099474182, 10.876860559947087, 10.877284518172281, 10.877427269284315, 10.87785884036713, 10.878003475014474, 10.8784387215338, 10.87858392013653, 10.879018871075045, 10.879163308890835, 10.879593995890113, 10.879736355108081, 10.880158848689712, 10.88029783046137, 10.880708275911397, 10.880842612208488, 10.881237264762326, 10.881365729953147, 10.88174098898058, 10.881862411018803, 10.88221485290259, 10.88232812402611]
poly_lon =  [48.3678798427946, 48.368021817738104, 48.368156830721745, 48.36830747860855, 48.36841045164596, 48.36873425226009, 48.36884689744824, 48.3691981887515, 48.36931946778919, 48.36969501178878, 48.36982380680683, 48.37022014202076, 48.37035526589424, 48.37076873927405, 48.370908946572186, 48.37133574720211, 48.37147974567523, 48.371915939918466, 48.372062402415466, 48.3725039701863, 48.37265154689232, 48.37309441872717, 48.37324174960875, 48.37368184418028, 48.37382757152284, 48.374260833261744, 48.374403614183564, 48.37482605065599, 48.37496456948373, 48.375372288179996, 48.37550526857117, 48.375894512769584, 48.37602072947049, 48.376207295263825, 48.37645028001812, 48.37663608066795, 48.376757696209815, 48.37710859675333, 48.37722062936801, 48.377541104120944, 48.37764246057182, 48.37792938235765, 48.37801907364027, 48.378149063726056, 48.37854595499935, 48.37866479012427, 48.37874087650978, 48.378950054457064, 48.37901325493819, 48.37918283102404, 48.37923254743354, 48.37936091675125, 48.37939667858365, 48.37948262634146, 48.37950409519796, 48.3795468081916, 48.37955378097544, 48.379552855264926, 48.37954526609693, 48.379500710810895, 48.379478631647856, 48.379390868883576, 48.37935450883322, 48.379224369652846, 48.3791740729926, 48.37900278955298, 48.37893903247087, 48.37872822636274, 48.378651612451584, 48.37840327935585, 48.37831453390294, 48.37803102471498, 48.37793098784157, 48.37761498643237, 48.377504605147315, 48.37715910297732, 48.377039422219696, 48.37666769004739, 48.37653984280296, 48.376145399743685, 48.37601059632795, 48.37559717656904, 48.375456693178194, 48.37502821065038, 48.374883377287816, 48.37444388863884, 48.374296076531664, 48.37384974274012, 48.37370035136365, 48.373251398364594, 48.373101842198174, 48.37265452088676, 48.37250621602551, 48.37206476201709, 48.37191911276603, 48.371487706297536, 48.37134609187554, 48.37092881822181, 48.370792579700534, 48.370393390484, 48.37026381808577, 48.36988649384491, 48.36976481472022, 48.36958547769086, 48.368810474529795, 48.368641058476456, 48.36853042299784, 48.36821273904167, 48.36811182689749, 48.36782472900137, 48.36773446096974, 48.367480568839824, 48.36740176861939, 48.367183399092845, 48.36711678577846, 48.366935931655895, 48.366882113168465, 48.36674042500432, 48.366699892535046, 48.366598663550846, 48.366571787070825, 48.36651194133143, 48.36649896620805, 48.366481050166925, 48.366482094918204, 48.36650627241337, 48.36652132762098, 48.36658737836562, 48.366616306756775, 48.36672362833829, 48.366766166035674, 48.36691377940915, 48.36696953833803, 48.36715609675893, 48.36722456818906, 48.36744836950508, 48.36752892869504, 48.367787930892625, 48.3678798427946]
polygon = Polygon(zip(poly_lat, poly_lon))

# node_id = 245813931
graph = ox.graph_from_polygon(
    polygon=polygon,
    truncate_by_edge=True,
    simplify=False,
    retain_all=True,
    custom_filter='["railway"~"^rail$|^switch$"]', # different coordinates: 48.366321, 10.8774909
    #custom_filter='["railway"~"^rail$|switch"]', # same as map: 48.3663241, 10.8775063
    #custom_filter='["railway"~"switch"]', # empty response
    #custom_filter='["railway"~"^rail$"]', # same as map: 48.3663241, 10.8775063
)```
1 Like

I don’t claim to know what’s going on here, but I notice that the node has been moved fairly recently, and that the coordinates that you are getting are the coordinates before and after the move.

1 Like

Thank you very much. I didn’t even think to take a look at the versioning. Cool way