Commit 98ad920 1 parent b9fea9e commit 98ad920 Copy full SHA for 98ad920
File tree 1 file changed +35
-0
lines changed
python/ngen_config_gen/examples/generate_conus_hf_2_2
1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change
1
+ import geopandas as gpd
2
+ import pandas as pd
3
+
4
+ from ngen .config_gen .file_writer import DefaultFileWriter
5
+ from ngen .config_gen .hook_providers import DefaultHookProvider
6
+ from ngen .config_gen .generate import generate_configs
7
+ from ngen .config_gen .mappings import LinkedData_2_2
8
+
9
+ from ngen .config_gen .models .cfe import Cfe
10
+ from ngen .config_gen .models .pet import Pet
11
+
12
+ if __name__ == "__main__" :
13
+ # or pass local file paths instead
14
+ hf_file = "https://lynker-spatial.s3-us-west-2.amazonaws.com/hydrofabric/v2.2/conus/conus_nextgen.gpkg"
15
+
16
+ hf : gpd .GeoDataFrame = gpd .read_file (hf_file , layer = "divides" )
17
+ hf_lnk_data : pd .DataFrame = pd .read_parquet (hf_file , layer = "divide-attributes" )
18
+ # NOTE: remap HF 2.2 'divide-attributes' names to HF 2.0 names so they are
19
+ # compatible with existing hooks
20
+ hf_lnk_data = hf_lnk_data .rename (columns = LinkedData_2_2 .conus , errors = "ignore" )
21
+ # Non-conus mappings available also:
22
+ # LinkedData_2_2.hi
23
+ # LinkedData_2_2.pr
24
+ # LinkedData_2_2.vi
25
+ # LinkedData_2_2.ak
26
+
27
+ hook_provider = DefaultHookProvider (hf = hf , hf_lnk_data = hf_lnk_data )
28
+ # files will be written to ./config
29
+ file_writer = DefaultFileWriter ("./config/" )
30
+
31
+ generate_configs (
32
+ hook_providers = hook_provider ,
33
+ hook_objects = [Cfe , Pet ],
34
+ file_writer = file_writer ,
35
+ )
You can’t perform that action at this time.
0 commit comments