Skip to content
Open
Show file tree
Hide file tree
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
18 changes: 12 additions & 6 deletions app/streamlit/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@
},
},
"virtual_nexus": {"marker_styling": folium.Marker(icon=folium.Icon(color="green", icon="filter"))},
"lakes": {
"marker_styling": folium.Marker(icon=folium.Icon(color="darkblue", prefix="fa", icon="sailboat"))
},
"ras_xs": {
"styling": {
"color": "black",
Expand Down Expand Up @@ -297,11 +300,14 @@ def post_transient_success_msg(msg, length_s=1.5):
def load_hf_gpkg(path):
"""Helper to load the subsetted GPKG and return a dictionary of GeoDataFrames for each layer."""
hf_dict = {}
for t in list(nhf_layers.keys()):
if t == "reference_flowpaths" or t == "hydrolocations":
hf_dict[t] = pl.from_pandas(gpd.read_file(path, layer=t))
else:
hf_dict[t] = pl.from_pandas(gpd.read_file(path, layer=t).to_wkt())
layers = gpd.list_layers(path)
for _index, row in layers.iterrows():
layer_name, has_geom = row["name"], row["geometry_type"] is not None
if layer_name in nhf_layers.keys():
if has_geom:
hf_dict[layer_name] = pl.from_pandas(gpd.read_file(path, layer=layer_name).to_wkt())
else:
hf_dict[layer_name] = pl.from_pandas(gpd.read_file(path, layer=layer_name))
return hf_dict


Expand All @@ -315,7 +321,7 @@ def display_nhf_schemas():
)
with image_expander:
st.image(
"app/streamlit/resources/hydrofabric_diagram.png",
"app/streamlit/resources/nhf_schema.png",
width="content",
caption="Entity Relationship Diagram (ERD) for the Iceberg NGWPC Hydrofabric Data Catalog.",
)
Expand Down
Binary file removed app/streamlit/resources/hydrofabric_diagram.png
Binary file not shown.
Binary file added app/streamlit/resources/nhf_schema.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 4 additions & 1 deletion src/icefabric/hydrofabric/subset_nhf.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,13 +221,15 @@ def generate_subset_from_ids(
"gages": ex.submit(source.load_filtered, "gages", "fp_id", flowpath_ids),
"ref_fp": ex.submit(source.load_filtered, "reference_flowpaths", "div_id", flowpath_ids),
"lakes": ex.submit(source.load_filtered, "lakes", "fp_id", flowpath_ids),
"nhd": ex.submit(source.load_filtered, "nhd", "ref_id", flowpath_ids),
}
subset_fp = f["fp"].result()
subset_div = f["div"].result()
subset_wb = f["wb"].result()
subset_gages = f["gages"].result()
subset_ref_fp = f["ref_fp"].result()
subset_lakes = f["lakes"].result()
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a waterbodies table as well for in 1.1.3. Waterbodies and lakes are going to be merged in the next 4-6 weeks but for now there are twe tables

subset_nhd = f["nhd"].result()

# Derive dependent IDs
all_nex_ids = set(
Expand Down Expand Up @@ -293,6 +295,7 @@ def generate_subset_from_ids(
"lakes": pl_to_gdf(subset_lakes, crs=crs) if len(subset_lakes) > 0 else subset_lakes.to_pandas(),
"reference_flowpaths": subset_ref_fp.to_pandas(),
"hydrolocations": subset_hydrolocations.to_pandas(),
"nhd": subset_nhd.to_pandas(),
}

if subset_file is not None:
Expand All @@ -315,7 +318,7 @@ def generate_subset_from_ids(
if isinstance(df, gpd.GeoDataFrame) and len(df) > 0:
pyogrio.write_dataframe(df, subset_file, layer=name)

nonspatial_layers = ["reference_flowpaths", "hydrolocations"]
nonspatial_layers = ["reference_flowpaths", "hydrolocations", "nhd"]
conn = sqlite3.connect(subset_file)
for name in nonspatial_layers:
logger.debug(f" {name}: {len(output[name])} rows")
Expand Down
6 changes: 4 additions & 2 deletions src/icefabric/schemas/iceberg_tables/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
from .hydrofabric_update import (
NHD,
Divides,
Flowpaths,
Gages,
Hydrolocations,
Lakes,
Nexus,
NHFLakes,
ReferenceFlowpaths,
VirtualFlowpaths,
VirtualNexus,
Expand All @@ -21,5 +22,6 @@
"virtual_flowpaths": VirtualFlowpaths,
"virtual_nexus": VirtualNexus,
"hydrolocations": Hydrolocations,
"lakes": NHFLakes,
"lakes": Lakes,
"nhd": NHD,
}
Loading
Loading