Comments (19)
@sablanchard you guys been able to reproduce this yet?
from pandana.
from pandana.
I realized I was not using the most current pandana version so I upgraded. However, all of the queries now return a dataframe where none of the nodes are within the distance limit. So the print statements in the tests are all printing 0. I am having the same exact issue with an UrbanAccess network:
Thanks!
from pandana.
Update- The set_pois method seems to only work now with x, y data that have more than one record. So the following returns a result:
coords_dict = [{'x' : -122.355 , 'y' : 47.689, 'var' : 1}, {'x' : -122.355 , 'y' : 47.689, 'var' : 1}]
df = pd.DataFrame(coords_dict)
net.init_pois(1, dist, 1)
net.set_pois('map_loc', df.x, df.y)
I have also confirmed that the issue I first reported on this thread is still happening in the latest version. I will post the revised code to do the tests later today.
from pandana.
@stefancoe I added some code to test this using the test data here
everything seems to be working ok as best as I can tell.
(fyi adding this test makes other tests fail, but not related to this issue)
from pandana.
Great call @fscottfoti. I can fix the sort
issue today unless you're already working on it.
from pandana.
I was actually confused by that test failure - why isn't master failing because of it?
The other test failure is because I added the test so now the network is initialized while the other test was expecting it to not be initialized yet. I can probably fix that one.
from pandana.
I think only because the new pandas release made it to Conda in the last couple of days, and last build of master
was before then: https://travis-ci.org/UDST/pandana/builds.
from pandana.
Thanks @fscottfoti! For my own sanity, can you run this code below? No files needed. From the print statements, I get 972, 693, and 678. Thanks!
import pandana as pdna
from pandana.loaders import osm
import pandas as pd
network = osm.pdna_network_from_bbox(37.859, -122.282, 37.881, -122.252)
dist = 1000
network.init_pois(1, dist, 1)
def get_nearest_nodes(x, y):
coords_dict = [{'x' : x , 'y' : y, 'var' : 1}, {'x' : x , 'y' : y, 'var' : 1}]
df = pd.DataFrame(coords_dict)
network.set_pois('map_loc', df['x'], df['y'])
res_name = "dist_map_loc"
res = network.nearest_pois(dist, 'map_loc', num_pois=1, max_distance=99999)
return res
##### TEST 2- this shows the potential bug #####
# First and Third coordinates are the same but give different result.
# The second set of coordinates are within the buffer distance of the first/third.
test1 = get_nearest_nodes(-122.262634 , 37.877165)
print len(test1[(test1[1] < 99999)])
test2 = get_nearest_nodes(-122.254116, 37.869361)
print len(test2[(test2[1] < 99999)])
# Same coords as the first call, but yields different results
test3 = get_nearest_nodes(-122.262634 , 37.877165)
print len(test3[(test3[1] < 99999)])
from pandana.
weird - I wonder if it's related to #43
when I ask for 10 pois rather than 1 the problem goes away
so you're trying to get an isochrone to this one point in your web service and it's not working in that use case?
from pandana.
Yeah- If a user were to make multiple calls in the same area, the results after the first call may not be correct. I have a work around (similar to what you found) that should work- set init_poi with many categories and then only call each category once. The code below produces stable results across calls, so it should be fine as long as only one nearest_poi is used per poi category.
import pandana as pdna
from pandana.loaders import osm
import pandas as pd
network = osm.pdna_network_from_bbox(37.859, -122.282, 37.881, -122.252)
dist = 1000
num_poi = 10
network.init_pois(num_poi, dist, 1)
def get_nearest_nodes(x, y, poi_name):
coords_dict = [{'x' : x , 'y' : y, 'var' : 1}, {'x' : x , 'y' : y, 'var' : 1}]
df = pd.DataFrame(coords_dict)
network.set_pois(poi_name, df['x'], df['y'])
res_name = "dist_map_loc"
res = network.nearest_pois(dist, poi_name, num_pois=1, max_distance=99999)
return res
##### TEST 2- this shows the potential bug #####
# First and Third coordinates are the same but give different result.
# The second set of coordinates are within the buffer distance of the first/third.
for x in range (1, num_poi + 1) :
test1 = get_nearest_nodes(-122.262634 , 37.877165, 'poi_' + str(x))
print len(test1[(test1[1] < 99999)])
test2 = get_nearest_nodes(-122.254116, 37.869361, 'poi_' + str(x))
print len(test2[(test2[1] < 99999)])
# Same coords as the first call, but yields different results
test3 = get_nearest_nodes(-122.262634 , 37.877165, 'poi_' + str(x))
print len(test3[(test3[1] < 99999)])
from pandana.
OK I've looked into it a bit. Turns out @federicofernandez is actually looking at the same thing in #80. I read the underlying code wrong and set_pois actually adds pois rather than re-initializing the memory and starting with new pois. So test 2 adds a new poi and then test 3 adds another new poi (in the same location as the first) and so you get different results on successive calls. @federicofernandez was just looking into the initialization of these data structures so I'll continue this on issue #80 to see if it's possible to re-initialize a category from scratch. In short, for now, the solution you came up with (have lots of categories) is likely the only solution that will work.
Also, the fact that you needed two pois in the coords_dict
list is a bug introduced in the latest release, but a considerably easier one to fix than the other so I'll get that out in the next couple of days.
from pandana.
@stefancoe I think I have this all solved for you in #81 . Do you have the means to build from source, or do you use Windows (which I think is harder to build from source)? I'm hoping the former so you can test it out before we cut a build.
from pandana.
@fscottfoti I am using windows and have a virtual env set up that should work. Should I pull the code and run setup.py?
from pandana.
I haven't a clue how to compile on Windows - does anyone else know if this works? @sablanchard @pksohn
from pandana.
I did it a couple of times. Those are the correct instructions, the only detail is to have the corresponding version of Visual C++ for Python, according to the python version that @stefancoe has. Let me know if I can help with that.
from pandana.
I was at a conference all week, I'll try to test this by early next week.
from pandana.
I cloned this branch https://github.com/UDST/pandana/tree/issue-73 but setup.py failed because it could not find vcvarsall.bat, which is the c compiler installed by Visual Studio. I tried all the usual fixes (e.g. https://stackoverflow.com/questions/2667069/cannot-find-vcvarsall-bat-when-running-a-python-script) that have worked in the past but no luck this time. Sorry I could not be of more help testing this on windows.
from pandana.
Fixed in #87, which will be released soon
from pandana.
Related Issues (20)
- Support for M1 Macs HOT 3
- [Question] How to get different Key|Value combinations in osm.node_query
- [Feature Request] Aggreggation queries to subset of nodes
- Binary incompatibility error with older versions of NumPy HOT 1
- Shortest path length exists but shortest path is empty HOT 5
- shortest path distance between non connected nodes
- Allow specifying mapping distance for POIs
- Issue: the POI Accessibility computation is taking forever
- OSM loader - POIs that are ways in OSM HOT 1
- Pandana network initiation slow for large network HOT 4
- how to increase the performance of the aggregate when impedance is changed to time?
- net.shortest_paths doesn't work with multiprocessing
- tables sub-dependency versions conflict with python 3.10 compatibility when installing with pip HOT 1
- incorrect shortest paths solutions when impendance values are particularly small or large HOT 1
- Plotting with Pandana does not render title HOT 1
- osm.pdna_network_from_bbox error HOT 6
- Pulling network object from OSM bugged HOT 2
- New release ?
- Google Colab install pandana error HOT 1
- query the OSM API for the street network within the specified bounding box error HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pandana.