geosdhydro
¶
geosdhydro package.
GIS tools for semi-distributed hydrologic modelling
Classes:
-
ShapefileToSwiftConverter
–Converts shapefile data to SWIFT JSON catchment structure.
Functions:
-
get_parser
–Return the CLI argument parser.
-
main
–Run the main program.
ShapefileToSwiftConverter
¶
ShapefileToSwiftConverter(
gdf: GeoDataFrame,
include_coordinates: bool = False,
linkid_field: str = "LinkID",
fromnodeid_field: str = "FromNodeID",
tonodeid_field: str = "ToNodeID",
spathlen_field: str = "SPathLen",
darea2_field: str = "DArea2",
geometry_field: str = "geometry",
linkname_field: Optional[str] = None,
subarea_name_field: Optional[str] = None,
node_names: Optional[Dict[str, str]] = None,
)
Converts shapefile data to SWIFT JSON catchment structure.
Parameters:
-
gdf
(GeoDataFrame
) –GeoDataFrame loaded from shapefile containing link data
-
include_coordinates
(bool
, default:False
) –Whether to include lat/lon in node definitions
-
linkid_field
(str
, default:'LinkID'
) –Name of the column containing Link IDs
-
fromnodeid_field
(str
, default:'FromNodeID'
) –Name of the column containing From Node IDs
-
tonodeid_field
(str
, default:'ToNodeID'
) –Name of the column containing To Node IDs
-
spathlen_field
(str
, default:'SPathLen'
) –Name of the column containing Stream Path Lengths (in meters)
-
darea2_field
(str
, default:'DArea2'
) –Name of the column containing Subarea Drainage Area (in square meters)
-
geometry_field
(str
, default:'geometry'
) –Name of the column containing geometry data
-
linkname_field
(Optional[str]
, default:None
) –Name of the column containing Link Names (optional)
-
subarea_name_field
(Optional[str]
, default:None
) –Name of the column containing SubArea Names (optional)
-
node_names
(Optional[Dict[str, str]]
, default:None
) –Optional mapping of node IDs to names (optional)
Methods:
-
convert
–Convert shapefile data to SWIFT JSON format.
-
save_to_file
–Save converted data to JSON file.
Attributes:
-
gdf
(GeoDataFrame
) –The geodataframe from which we build the json file.
-
include_coordinates
(bool
) –Should the Latitude/Longitude coordinates be derived from the geometry and written in the json file.
-
routing_model
(dict
) –Dictionary for the routing model sections of the json file.
-
runoff_model
(dict
) –Dictionary for the rainfall-runoff model sections of the json file.
Source code in src/geosdhydro/_internal/swift.py
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
|
include_coordinates
property
writable
¶
include_coordinates: bool
Should the Latitude/Longitude coordinates be derived from the geometry and written in the json file.
routing_model
property
writable
¶
routing_model: dict
Dictionary for the routing model sections of the json file.
runoff_model
property
writable
¶
runoff_model: dict
Dictionary for the rainfall-runoff model sections of the json file.
convert
¶
Convert shapefile data to SWIFT JSON format.
Returns:
Source code in src/geosdhydro/_internal/swift.py
177 178 179 180 181 182 183 |
|
save_to_file
¶
Save converted data to JSON file.
Parameters:
-
filepath
(str
) –Path where to save the JSON file
-
indent
(int
, default:2
) –Number of spaces for JSON indentation (default: 2)
Source code in src/geosdhydro/_internal/swift.py
185 186 187 188 189 190 191 192 193 |
|
get_parser
¶
get_parser() -> ArgumentParser
Return the CLI argument parser.
Returns:
-
ArgumentParser
–An argparse parser.
Source code in src/geosdhydro/_internal/cli.py
30 31 32 33 34 35 36 37 38 39 |
|
main
¶
Run the main program.
This function is executed when you type geosdhydro
or python -m geosdhydro
.
Parameters:
Returns:
-
int
–An exit code.
Source code in src/geosdhydro/_internal/cli.py
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
|