You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have an implementation of building a (higher-order) contiguity Graph based on H3 index. I'd like to expose it as a builder on `Graph, so dumping the code below before I'll forget.
importh3fromlibpysalimportgraphdata= ... # dataframe with H3 IDs as an index, like those coming from tobler h3fyorder=5neighbors= {}
weights= {}
forixindata.index:
rings=h3.hex_range_distances(ix, order)
fori, ringinenumerate(rings):
ifi==0:
neighbors[ix] = []
weights[ix] = []
else:
neighbors[ix].extend(list(ring))
weights[ix].extend([i] *len(ring))
matrix=graph.Graph.from_dicts(neighbors, weights)
It encodes the order as weight now, I was casting to a binary graph and used topological inverse weighting based on that (inverse = graph.Graph(1 / matrix.adjacency)). We can figure out what the API should be once the PR is alive?
I also think that the latest beta release of h3 completely changed the API so the h3 calls will need to change a bit but it's been beta for a year.
I have an implementation of building a (higher-order) contiguity Graph based on H3 index. I'd like to expose it as a builder on `Graph, so dumping the code below before I'll forget.
It encodes the order as weight now, I was casting to a binary graph and used topological inverse weighting based on that (
inverse = graph.Graph(1 / matrix.adjacency)
). We can figure out what the API should be once the PR is alive?I also think that the latest beta release of h3 completely changed the API so the h3 calls will need to change a bit but it's been beta for a year.
based on https://github.com/Urban-Analytics-Technology-Platform/demoland-project/blob/main/code/04_generalisation/create_spatial_weights.ipynb
The text was updated successfully, but these errors were encountered: