Skip to content

Instantly share code, notes, and snippets.

@ljwolf
Created December 3, 2020 14:56
Show Gist options
  • Save ljwolf/252ce076aca6e41b181ef462a7848c25 to your computer and use it in GitHub Desktop.
Save ljwolf/252ce076aca6e41b181ef462a7848c25 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@brendan-ward
Copy link

Possible speedup: (about 1.5x faster locally)

heads, tails = tree.query_bulk(pygeos_polygons, predicate='intersects')
ix = heads != tails
heads = heads[ix]
tails = tails[ix]
touches = pygeos.touches(pygeos_polygons.take(heads), pygeos_polygons.take(tails))
G = networkx.Graph()
G.add_edges_from(zip(heads[touches], tails[touches]))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment