Introduction¶
dem2basin is Python package to simplify common surface hydrology data preparation steps.
Numerous functions are provided to: - accomplish common vector and raster processing workflows in GeoPandas and GDAL/OGR - accomplish higher-level hydrology data processing goals
Motivation¶
It is common for hydrologists to spend some time preparing raster and vector source data for study at the individual watershed level. Once the source data is prepared, they can then generate HAND or other common terrain model. These preparation steps are largely similar or the same each and every time the hydrologist needs generate a terrain model from source data. This package provided functions to simplify these common preparation steps.
Limitations¶
This packages has only been thoroughly tested against Texas Lidar raster data, NHD vector flowline and catchment data, and WBD vector HUC watershed data.
- There are a number of proposed extensions, including:
to NED 10m raster data
to FIM / Fathom 3m raster data
to non-WBD and non-NHD watershed data, for example internationally
to Texas Lidar hypsography vector data
to Texas Lidar point-cloud data
Below I only include the most thoroughly vetted dem2basin functions. These are the vector data processing functions.
While there are workable raster data processing functions, they are currently being significantly refactored, with nearly every existing function being deprecated in favor of entirely different approaches.
Hydrology data processing functions¶
get_hucs_by_shapefinds HUCs that intersect a study area given as a vector imageget_flowlines_and_representative_points_by_hucassigns HUCs to NHD flowlines and their representative points, returning bothget_representative_pointsretrieve representative points of flowlines and assign HUCs to these pointsset_roughness_by_streamorderassign Manning’s n roughness value by each flowline’s stream orderget_catchments_by_hucassigns HUCs to NHD catchmentsset_index_by_hucreturns a geodataframe with its index set to its HUC columnfind_huc_levelfinds the name of the HUC column of a geodataframeget_nhd_by_shaperetrieves specific NHD layer masked by another geodataframeget_hucs_from_catchmentsdissolves NHD catchments into HUC equivalentswrite_rougness_tablewrite Manning’s n roughness table to CSV filename or concrete path
Core vector and raster processing functions¶
reproject_to_utm_and_bufferfinds best UTM for a geodataframe, reprojects, and then buffers itfind_utmfinds a single UTM CRS best suited for the geometries of a geodataframefind_common_utmdetermines the mode of the UTMs of the representative points of a geodataframe’s geometriesreproject_and_bufferreprojects geodataframe to a CRS and then buffers itwrite_geodataframewrite geodataframe to filename or concrete pathto_crsreprojects multiples geodataframes simultaneously_drop_index_columnsdrops columns named'index','index_left', and'index_right'either to prevent issues withgeopandasfunctions likegeopandas.sjoinand to clean up after somegeopandasfunctionsclip_geodataframe_by_attributeassign attribute from one geodataframe to another by their mutual index valuesset_and_sort_indexsets a geodataframe’s index to column and sorts by that columnread_file_or_gdfenables functions to take either filenames or geodataframes as inputsget_merged_columnreturns the mutual elements of an identically names column in multiple dataframesindex_dataframe_by_dataframeindexes a dataframe by another dataframeskip_function_if_file_existswrapper to skip a particular step in a workflow if a file already existsdelete_filedeletes a file in all versions of Python