Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
Levi John Wolf
@ljwolf
naw, that's super neat
Sergio Rey
@sjsrey
one idea regarding OSMnx (which is really nice) is to replace our network datastructure with that. Then, all our analytics could be the "meat" of spaghetti.
James Gaboardi
@jGaboardi
:+1: :smile:
hasecbinusr
@hasecbinusr
OSMnx, from what I've read, stores objects as NetworkX objects, so I'd imagine replacing the network data structure with NetworkX objects would also allow interoperability with non-OSM networks
Levi John Wolf
@ljwolf
would need to check if the node deletion machinery in osmnx is able to be applied to arbitrary nx objects?
iirc, the snapping & node reduction were the two heavy lifts for the computational geometry part
Sergio Rey
@sjsrey
yes, they were :-o
Snapping we would need to port, but i'm not so sure about the node reduction.
Sergio Rey
@sjsrey
I think OSMnx handles node reduction.
Sergio Rey
@sjsrey
export PYTHONPATH=$PYTHONPATH:$PWD/libpysal
export PYTHONPATH=$PYTHONPATH:$PWD/mapclassify
export PYTHONPATH=$PYTHONPATH:$PWD/esda
export PYTHONPATH=$PYTHONPATH:$PWD/giddy
export PYTHONPATH=$PYTHONPATH:$PWD/splot
export PYTHONPATH=$PYTHONPATH:$PWD/pointpats
Sergio Rey
@sjsrey
@jGaboardi very nice example!
James Gaboardi
@jGaboardi
LOL all I did was make the notebook look pretty. Mr. osmnxGeoff Boeing wrote code.
Sergio Rey
@sjsrey
good artists copy, great artists steal
James Gaboardi
@jGaboardi
But is does give another powerful and concise example of why we are better off building on top of osmnx.
Sergio Rey
@sjsrey
+1
Levi John Wolf
@ljwolf
!!
whattt
this means we could do skater straight from W * affinity matrix
we can get MST of weighted undirected graphs
Levi John Wolf
@ljwolf
that's skater in 40 lines
built on top of sklearn.metrics and scipy.sparse.csgraph.
I think the results from that are substantively different from what I get from the spectral + contiguity clustering
Levi John Wolf
@ljwolf
2017-07-19-143454_388x328_scrot.png
close in some ways, though.
regardless, I did not realize that scipy had builtin sparse adjacency matrix graph support
that makes it super easy to build on top of, I'd think both for spaghetti & for bounder/region
Levi John Wolf
@ljwolf
I just refreshed the gist for Spatial-Spectral clustering comparison
anyway, this rapidly deviated from this channel's intent. Sorry to spam. Was just excited about the sparse network support & algos in scipy already.
James Gaboardi
@jGaboardi
@ljwolf looks really neat. Will check it out later.
Levi John Wolf
@ljwolf
if someone figures out how to prevent calling csgraph.csgraph_from_dense after zeroing the links, I'd love to know
right now, that's a slow component at scale.
Levi John Wolf
@ljwolf
figured it out using matrix.eliminate_zeros() after zeroing the link
Now I never cast the sparse matrix to a dense one while solving
Levi John Wolf
@ljwolf
This implementation was just applied to an O(10k) dataset, looked for 100 clusters, got ~60 clusters on a quorum of 70, in ~400 seconds.
hasecbinusr
@hasecbinusr
A year later... I see there is some implementation of NetworkX is Spaghetti now, but I haven't really dug into it to see the extent of integration. Can Spaghetti use a NetworkX model as a starting point now or does it still require a shapefile?
(I'm looking back at my issue from a year and a half ago, haha... pysal/spaghetti#9)
James Gaboardi
@jGaboardi

@hasecbinusr a network object can now be instantiated with a geopandas.GeoDataFrame, but currently it will still produce the same error you were getting before if you would like a simplified, graph-theoretic object. However, we have added an extragraph kwarg that will bypass simplification if set to False.

Thanks for sticking with this issue. It is absolutely still on the radar.

hasecbinusr
@hasecbinusr
I was about to get back into it and work on fixing it, but since I've been gone so long I'm having to refresh myself on the state of the project
hasecbinusr
@hasecbinusr
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-14-0c31d729ebc0> in <module>()
----> 1 ntw = spgh.Network(in_shp=edges)

AttributeError: module 'spaghetti' has no attribute 'Network'
Any clue what's causing this? I'm trying to follow the example at https://github.com/pysal/spaghetti/blob/master/notebooks/Network_Usage.ipynb
James Gaboardi
@jGaboardi
Do you have the most recent version of spaghetti?
hasecbinusr
@hasecbinusr
I just installed a few minutes ago with "pip install spaghetti"
Just upgraded to the latest dev version with the same error
James Gaboardi
@jGaboardi
hmmm. Ok. I will take a look at it.
hasecbinusr
@hasecbinusr
Disregard. I flushed my cache and restarted and it's working now. Who knew...
Gremlins in the system
James Gaboardi
@jGaboardi
:+1:
hasecbinusr
@hasecbinusr
If anyone is interested, I was able to pull a road network from OSMnx and import it into Spaghetti using this code:
import spaghetti as spgh
import osmnx as ox
%matplotlib inline
place_name = "Travis County, Texas, United States of America"
graph = ox.graph_from_place(place_name, network_type='drive')
fig, ax = ox.plot_graph(graph)
edges = ox.graph_to_gdfs(graph, nodes=False, edges=True)
ntw = spgh.Network(in_shp=edges)