ipython-books / cookbook-code

[DEPRECATED] See the new edition:

Home Page:http://ipython-books.github.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Errors in http://ipython-books.github.io/featured-03/

mattkrems opened this issue · comments

A few issues:
Step 2: make sure to actually use "g = nx.read_shp("data/tl_2013_06_prisecroads.shp", simplify =False)". Without setting simplify to False, grid-like road structures become completely broken graphs. This is extremely important when using open street map data for example.

Step 3: to get the maximally connected subgraph, use the command 'max(nx.connected_component_subgraphs(g.to_undirected()), key=len)'

Step 7: Since the "JSON" coordinates are in the form (lon,lat), you are actually passing the wrong set to the geocalc function. Change to 'return np.sum(geocalc(path[1:,1],path[1:,0],path[:-1,1],path[:-1,0]))'. Surprisingly, the path it finds is nearly the same, and the distance is only a bit different.