Skip to content

Commit

Permalink
Merge pull request #223 from knaaptime/h3compat
Browse files Browse the repository at this point in the history
h3compat
  • Loading branch information
knaaptime authored Jan 23, 2025
2 parents ec07f10 + b583029 commit 5aeb4d7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
8 changes: 8 additions & 0 deletions tobler/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ def test_h3fy_clip():
sac_hex.area.sum(), 13131736346.537422, decimal=0
)

def test_h3fy_clip_buffer():
sac1 = load_example("Sacramento1")
sac1 = geopandas.read_file(sac1.get_path("sacramentot2.shp"))
sac_hex = h3fy(sac1, clip=True, buffer=True)
sac_hex = sac_hex.to_crs(sac_hex.estimate_utm_crs())
assert_almost_equal(
sac_hex.area.sum(), 13749446323.1722, decimal=0
)

@pytest.mark.skipif(platform.system() == "Windows", reason='Unknown precision error on Windows. See #174 for details')
def test_h3_multipoly():
Expand Down
5 changes: 3 additions & 2 deletions tobler/util/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ def circumradius(resolution):
"You can install it with `conda install h3-py` or "
"`pip install h3`"
)

return h3.edge_length(resolution, "m")
if Version(h3.__version__) < Version("4.0"):
return h3.edge_length(resolution, "m")
return h3.average_hexagon_edge_length(resolution, "m")


def _check_crs(source_df, target_df):
Expand Down

0 comments on commit 5aeb4d7

Please sign in to comment.