Skip to content

Commit

Permalink
add thin_arr
Browse files Browse the repository at this point in the history
  • Loading branch information
carderne committed Mar 5, 2024
1 parent 239a85a commit 4cd884a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
10 changes: 9 additions & 1 deletion gridfinder/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
from importlib.metadata import version

from gridfinder.gridfinder import get_targets_costs, optimise
from gridfinder.post import accuracy, raster_to_lines, thin, threshold, threshold_arr
from gridfinder.post import (
accuracy,
raster_to_lines,
thin,
thin_arr,
threshold,
threshold_arr,
)
from gridfinder.prepare import (
clip_rasters,
create_filter,
Expand All @@ -21,6 +28,7 @@
"threshold",
"threshold_arr",
"thin",
"thin_arr",
"raster_to_lines",
"accuracy",
"clip_rasters",
Expand Down
8 changes: 6 additions & 2 deletions gridfinder/post.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,15 @@ def thin(guess_in: Pathy) -> tuple[np.ndarray, Affine]:
with rs.open(guess_in) as ds:
guess_arr = ds.read(1)
affine = ds.transform
guess_skel = thin_arr(guess_arr)
return guess_skel, affine


guess_skel = skeletonize(guess_arr)
def thin_arr(guess: np.ndarray) -> np.ndarray:
guess_skel = skeletonize(guess)
guess_skel = guess_skel.astype("int32")
return guess_skel

return guess_skel, affine


def raster_to_lines(guess_skel_in: Pathy) -> gpd.GeoDataFrame:
Expand Down

0 comments on commit 4cd884a

Please sign in to comment.