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

Geopackage read bugfix #838

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions src/troute-network/troute/HYFeaturesNetwork.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ def read_geopkg(file_path, compute_parameters, waterbody_parameters, cpu_pool):
available_layers = fiona.listlayers(file_path)

# patterns for the layers we want to find
# $ in flowpaths to avoid double matching with flowpath_attributes
layer_patterns = {
'flowpaths': r'flow[-_]?paths?|flow[-_]?lines?',
'flowpaths': r'flow[-_]?paths?$|flow[-_]?lines?$',
'flowpath_attributes': r'flow[-_]?path[-_]?attributes?|flow[-_]?line[-_]?attributes?',
'lakes': r'lakes?',
'nexus': r'nexus?',
Expand Down Expand Up @@ -92,13 +93,18 @@ def read_layer(layer_name):
if 'link' in flowpath_attributes_df.columns:
flowpath_attributes_df.rename(columns={'link': 'id'}, inplace=True)

# Merge flowpaths and flowpath_attributes
flowpaths = pd.merge(
flowpaths_df,
flowpath_attributes_df,
on='id',
how='inner'
)
# Merge flowpaths and flowpath_attributes
if not flowpath_attributes_df.empty and not flowpaths_df.empty:
flowpaths = pd.merge(
flowpaths_df,
flowpath_attributes_df,
on='id',
how='inner'
)
elif not flowpaths_df.empty:
flowpaths = flowpaths_df
elif not flowpath_attributes_df.empty:
flowpaths = flowpath_attributes_df

lakes = table_dict.get('lakes', pd.DataFrame())
network = table_dict.get('network', pd.DataFrame())
Expand Down
Loading