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

snap_to_branch #178

Open
MatthiasHHSK opened this issue Apr 10, 2024 · 3 comments
Open

snap_to_branch #178

MatthiasHHSK opened this issue Apr 10, 2024 · 3 comments

Comments

@MatthiasHHSK
Copy link

The snap_to_branch does not really snap geometries to branches? It only returns the columns: [branch_offset, branch_id]

"def snap_to_branch(self, branches, snap_method, maxdist=5):
"""Snap the geometries to the branch"""
spatial.find_nearest_branch(
branches=branches, geometries=self, method=snap_method, maxdist=maxdist
)"

or do I miss something?

@BdGraaff
Copy link

You are correct. There is an example notebook with test data that demonstrates how the functions can be used:
https://github.com/Deltares/HYDROLIB/tree/main/hydrolib/notebooks

The test data can be found here:
https://github.com/Deltares/HYDROLIB/tree/main/hydrolib/tests/data

Here is an example from this notebook for a weir:
hydamo.weirs.read_gpkg_layer(gpkg_file, layer_name="Stuw", index_col="code")
hydamo.weirs.snap_to_branch(hydamo.branches, snap_method="overal", maxdist=10)
hydamo.weirs.dropna(axis=0, inplace=True, subset=["branch_offset"])

In the last line the objects with that shouldn't be snapped are dropped from the dataframe and will not be incorporated in the schematization.

@MatthiasHHSK
Copy link
Author

Thanks! I am aware of the example notebook.
So this functions does not change the geometry, it adds the offset and further on in the data conversion the geometry is changed?

@BdGraaff
Copy link

The geometry is not changed. Using the function it is determined to which branch the object should be snapped and also on what chainage. This for example the result of the function for one weir in a model:
image

This is the result in the structure.ini file when writing the model:
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants