Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: add Graph.build_h3 #694

Merged
merged 3 commits into from
May 20, 2024
Merged

ENH: add Graph.build_h3 #694

merged 3 commits into from
May 20, 2024

Conversation

martinfleis
Copy link
Member

Closes #667

I am open to API suggestions, especially regarding weight. Example usage:

import geopandas as gpd
from geodatasets import get_path
from tobler.util import h3fy

from libpysal import graph

gdf = gpd.read_file(get_path("geoda guerry"))
h3 = h3fy(gdf, resolution=4)
G = graph.Graph.build_h3(h3.index)

In theory, you can use this to do spatial stats without having any geometry, just the indices.

@ljwolf I am aware of you suggestion to support other hierarchical indices as well but I am not sure if the overall goal with that would be to have a single builder method (or of it is wise to have only one) or individual, so I went ahead with H3-specific one.

@knaaptime
Copy link
Member

would it be better to move h3fy to lib?

@martinfleis
Copy link
Member Author

would it be better to move h3fy to lib?

I got no opinion there, either way is fine with me.

Copy link

codecov bot commented Mar 26, 2024

Codecov Report

Attention: Patch coverage is 94.33962% with 3 lines in your changes are missing coverage. Please review.

Project coverage is 85.0%. Comparing base (bcabdbc) to head (88c3448).
Report is 2 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@          Coverage Diff          @@
##            main    #694   +/-   ##
=====================================
  Coverage   85.0%   85.0%           
=====================================
  Files        141     143    +2     
  Lines      15203   15259   +56     
=====================================
+ Hits       12924   12974   +50     
- Misses      2279    2285    +6     
Files Coverage Δ
libpysal/graph/_indices.py 100.0% <100.0%> (ø)
libpysal/graph/tests/test_indices.py 100.0% <100.0%> (ø)
libpysal/graph/base.py 97.0% <75.0%> (-0.9%) ⬇️

... and 1 file with indirect coverage changes

@martinfleis martinfleis merged commit 3afbab7 into pysal:main May 20, 2024
11 checks passed
@martinfleis martinfleis deleted the graph-from-h3 branch May 20, 2024 14:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Build Graph from H3
3 participants