Name | idfva JSON |
Version |
0.1.2
JSON |
| download |
home_page | None |
Summary | This model generates investigation polygons which are used to estimate and store incremental erosion and deposition volumes along the path of a debris flow at user- defined resolution. The user will need: 1) a .LAS or .TIF of topographic change, 2) a DEM of the AOI, and 3) a shapefile (polyline) of the debris flow path of interest. Each incremental volume is georeferenced and stored within a shapefile attribute associated with a catchment area and distance from outlet for analysis. |
upload_time | 2025-08-20 21:36:36 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.10 |
license | None |
keywords |
debris flow
erosion
erosion/deposition
flow path
hazards
lateral erosion
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# Welcome to idfva
| | |
|--------|--------|
| Package | [](https://pypi.org/project/idfva/) [](https://pypi.org/project/idfva/) [](https://github.com/laurenguido/IncrementalDerisFlowVolumeAnalyzer) |
| Meta | [](https://github.com/laurenguido/IncrementalDerisFlowVolumeAnalyzer/blob/main/CODE_OF_CONDUCT.md) |
The idfva (IncrementalDebrisFlowVolumeAnalyzer) is a Python tool for estimating intra-channel volume of erosion and deposition along a flow path. The series of semi-automated scripts which make up IncrementalDebrisFlowVolumeAnalyzer can be looped using a master text file and/or the glob package depending on the user file structure, to efficiently run volume estimations across an area of interest. The IncrementalDebrisFlowVolumeAnalyzer relies heavily on the Fiona, Rasterio, and Shapely packages for reading and writing geospatial data.
This tool was designed to be used by geohazard and geomorphology researchers in tandem with external data, field work, and geomorphometric analyses. Students may also use this tool to gain familiarity with debris flow hazards, change detection data types, and geospatial data manipulationin Python with hands-on application to real world problems.
## Get started
You can install this package into your preferred Python environment using pip:
```bash
$ pip install idfva
```
To use idfva in your code:
```python
"""
Example workflow for end-to-end idfva use.
"""
# --- 1. Convert LAS to Raster ---
import las2ras
las_file = "C:/Users/path/to/input/las.las"
scalar_field = "M3C2 distance"
output_raster = "C:/Users/path/to/output/raster.tif"
cell_size = 1
method = 'linear'
las2ras.print_scalar_field(las_file, scalar_field, num_values=10)
las2ras.las_to_raster(las_file, scalar_field, output_raster, cell_size, method)
# --- 2. Process Watersheds (DEM hydrology) ---
import process_watersheds
dem_path = "C:/Users/path/to/DEM.tif"
fdir_output_file = "C:/Users/path/to/flow/direction.tif"
acc_output_file = "C:/Users/path/to/flow/accumulation.tif"
crs_str = "+proj=utm +zone=13 +ellps=GRS80 +units=m +no_defs"
grid, dem = process_watersheds.read_dem(dem_path)
inflated_dem = process_watersheds.condition_dem(grid, dem)
fdir_d8 = process_watersheds.compute_flow_direction(grid, inflated_dem)
acc_d8 = process_watersheds.compute_flow_accumulation(grid, fdir_d8)
process_watersheds.save_raster(fdir_d8, fdir_output_file, crs_str, grid.affine)
process_watersheds.save_raster(acc_d8, acc_output_file, crs_str, grid.affine)
process_watersheds.plot_array(acc_d8, grid, "Flow Accumulation", "cubehelix", "Upstream Cells", log_norm=True)
process_watersheds.plot_array(fdir_d8, grid, "Flow Direction", "viridis", "Flow Direction")
# --- 3. Generate Query Points Along Path ---
import generate_query_points
accumulation_path = acc_output_file
direction_path = fdir_output_file
debris_flow_path = "C:/Users/path/to/flowpath.shp"
output_shapefile_path = "C:/Users/path/to/querypoints.shp"
max_point = generate_query_points.find_max_value_point(debris_flow_path, accumulation_path)
if max_point:
X, Y = max_point
x = X[0]
y = Y[0]
grid, acc, fdir = generate_query_points.initialize_grid(direction_path, accumulation_path)
dist, x_snap, y_snap = generate_query_points.calculate_distance_to_outlet(grid, acc, fdir, x, y)
lon, lat = generate_query_points.convert_coordinates(direction_path, x_snap, y_snap)
all_points, distances, catchments = generate_query_points.interpolate_points_along_polyline(
debris_flow_path, direction_path, accumulation_path, dist)
generate_query_points.save_points_to_shapefile(output_shapefile_path, all_points, distances, catchments)
generate_query_points.plot_flow_distance(grid, dist, all_points, debris_flow_path)
# --- 4. Prepare Path (dissolve and buffer) ---
import prepare_path
buffered_path = "C:/Users/path/to/buffered/polygon.shp"
buffer_width = 30.0
original_geometries, buffer, crs = prepare_path.create_dissolved_buffer(debris_flow_path, buffered_path, buffer_width)
prepare_path.plot_shapefiles(original_geometries, buffer, crs)
# --- 5. Apply Modified Voronoi ---
import apply_modified_voronoi
investigation_polygons_shapefile = "C:/Users/path/to/investigation/polygons.shp"
buffer_distance = 0
points = apply_modified_voronoi.read_points_from_shapefile(output_shapefile_path)
points_array = np.array([[p.x, p.y] for p in points])
x_min, y_min = points_array.min(axis=0)
x_max, y_max = points_array.max(axis=0)
extra_points = [
apply_modified_voronoi.Point(x_min - buffer_distance, y_min - buffer_distance),
apply_modified_voronoi.Point(x_min - buffer_distance, y_max + buffer_distance),
apply_modified_voronoi.Point(x_max + buffer_distance, y_min - buffer_distance),
apply_modified_voronoi.Point(x_max + buffer_distance, y_max + buffer_distance)
]
points.extend(extra_points)
with fiona.open(buffered_path, 'r') as src:
original_polygon = apply_modified_voronoi.unary_union([apply_modified_voronoi.Polygon(feat['geometry']['coordinates'][0]) for feat in src])
clipped_voronoi_polygons = apply_modified_voronoi.compute_voronoi_polygons(points, original_polygon, buffer_distance)
apply_modified_voronoi.save_voronoi_polygons_to_shapefile(clipped_voronoi_polygons, investigation_polygons_shapefile)
apply_modified_voronoi.plot_voronoi_on_map(points, extra_points, clipped_voronoi_polygons, debris_flow_path)
apply_modified_voronoi.plot_voronoi_polygon_areas(clipped_voronoi_polygons)
apply_modified_voronoi.voronoi_polygon_qc(investigation_polygons_shapefile)
# --- 6. Estimate Volumes and Plot ---
import estimate_volume_and_plot
raster_path = output_raster # or your change detection raster
LoD = 0.25 # User-defined detection limit
polygon_ids = ['803', '830', '766'] # Example tributary IDs
estimate_volume_and_plot.extract_raster_values(raster_path, investigation_polygons_shapefile, debris_flow_path, LoD)
estimate_volume_and_plot.plot_polygons(investigation_polygons_shapefile, 'dep_vol', cmap='Blues')
estimate_volume_and_plot.plot_polygons(investigation_polygons_shapefile, 'ero_vol', cmap='Reds_r')
estimate_volume_and_plot.plot_polygons(investigation_polygons_shapefile, 'net_mob', cmap='Purples_r')
estimate_volume_and_plot.plot_attributes_vs_distance_bar(investigation_polygons_shapefile)
estimate_volume_and_plot.plot_YR_vs_distance(investigation_polygons_shapefile)
estimate_volume_and_plot.plot_YR_vs_catchment(investigation_polygons_shapefile)
estimate_volume_and_plot.plot_attributes_vs_catchment_bar(investigation_polygons_shapefile)
estimate_volume_and_plot.plot_attributes_vs_catchment_log_bar(investigation_polygons_shapefile)
estimate_volume_and_plot.plot_cumulative_vs_distance(investigation_polygons_shapefile)
estimate_volume_and_plot.plot_cumulative_vs_catchment(investigation_polygons_shapefile)
estimate_volume_and_plot.plot_cumulative_vs_distance_scatter(investigation_polygons_shapefile)
estimate_volume_and_plot.plot_cumulative_vs_catchment_scatter(investigation_polygons_shapefile)
```
## Copyright
- Copyright © 2025 Lauren Guido.
- Free software distributed under the [MIT License](./LICENSE).
Raw data
{
"_id": null,
"home_page": null,
"name": "idfva",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": null,
"keywords": "debris flow, erosion, erosion/deposition, flow path, hazards, lateral erosion",
"author": null,
"author_email": "Lauren Guido <laurenmiller@mines.edu>",
"download_url": "https://files.pythonhosted.org/packages/05/3a/b3008934c8e7f499e2c9545af07a870b3dc0e2c1caf18594e9efa7272de8/idfva-0.1.2.tar.gz",
"platform": null,
"description": "# Welcome to idfva\n\n| | |\n|--------|--------|\n| Package | [](https://pypi.org/project/idfva/) [](https://pypi.org/project/idfva/) [](https://github.com/laurenguido/IncrementalDerisFlowVolumeAnalyzer) |\n| Meta | [](https://github.com/laurenguido/IncrementalDerisFlowVolumeAnalyzer/blob/main/CODE_OF_CONDUCT.md) |\n\nThe idfva (IncrementalDebrisFlowVolumeAnalyzer) is a Python tool for estimating intra-channel volume of erosion and deposition along a flow path. The series of semi-automated scripts which make up IncrementalDebrisFlowVolumeAnalyzer can be looped using a master text file and/or the glob package depending on the user file structure, to efficiently run volume estimations across an area of interest. The IncrementalDebrisFlowVolumeAnalyzer relies heavily on the Fiona, Rasterio, and Shapely packages for reading and writing geospatial data.\n\nThis tool was designed to be used by geohazard and geomorphology researchers in tandem with external data, field work, and geomorphometric analyses. Students may also use this tool to gain familiarity with debris flow hazards, change detection data types, and geospatial data manipulationin Python with hands-on application to real world problems.\n\n## Get started\n\nYou can install this package into your preferred Python environment using pip:\n\n```bash\n$ pip install idfva\n```\n\nTo use idfva in your code:\n\n```python\n\"\"\"\nExample workflow for end-to-end idfva use.\n\"\"\"\n\n# --- 1. Convert LAS to Raster ---\nimport las2ras\nlas_file = \"C:/Users/path/to/input/las.las\"\nscalar_field = \"M3C2 distance\"\noutput_raster = \"C:/Users/path/to/output/raster.tif\"\ncell_size = 1\nmethod = 'linear'\nlas2ras.print_scalar_field(las_file, scalar_field, num_values=10)\nlas2ras.las_to_raster(las_file, scalar_field, output_raster, cell_size, method)\n\n# --- 2. Process Watersheds (DEM hydrology) ---\nimport process_watersheds\ndem_path = \"C:/Users/path/to/DEM.tif\"\nfdir_output_file = \"C:/Users/path/to/flow/direction.tif\"\nacc_output_file = \"C:/Users/path/to/flow/accumulation.tif\"\ncrs_str = \"+proj=utm +zone=13 +ellps=GRS80 +units=m +no_defs\"\n\ngrid, dem = process_watersheds.read_dem(dem_path)\ninflated_dem = process_watersheds.condition_dem(grid, dem)\nfdir_d8 = process_watersheds.compute_flow_direction(grid, inflated_dem)\nacc_d8 = process_watersheds.compute_flow_accumulation(grid, fdir_d8)\nprocess_watersheds.save_raster(fdir_d8, fdir_output_file, crs_str, grid.affine)\nprocess_watersheds.save_raster(acc_d8, acc_output_file, crs_str, grid.affine)\nprocess_watersheds.plot_array(acc_d8, grid, \"Flow Accumulation\", \"cubehelix\", \"Upstream Cells\", log_norm=True)\nprocess_watersheds.plot_array(fdir_d8, grid, \"Flow Direction\", \"viridis\", \"Flow Direction\")\n\n# --- 3. Generate Query Points Along Path ---\nimport generate_query_points\naccumulation_path = acc_output_file\ndirection_path = fdir_output_file\ndebris_flow_path = \"C:/Users/path/to/flowpath.shp\"\noutput_shapefile_path = \"C:/Users/path/to/querypoints.shp\"\n\nmax_point = generate_query_points.find_max_value_point(debris_flow_path, accumulation_path)\nif max_point:\n X, Y = max_point\n x = X[0]\n y = Y[0]\n grid, acc, fdir = generate_query_points.initialize_grid(direction_path, accumulation_path)\n dist, x_snap, y_snap = generate_query_points.calculate_distance_to_outlet(grid, acc, fdir, x, y)\n lon, lat = generate_query_points.convert_coordinates(direction_path, x_snap, y_snap)\n all_points, distances, catchments = generate_query_points.interpolate_points_along_polyline(\n debris_flow_path, direction_path, accumulation_path, dist)\n generate_query_points.save_points_to_shapefile(output_shapefile_path, all_points, distances, catchments)\n generate_query_points.plot_flow_distance(grid, dist, all_points, debris_flow_path)\n\n# --- 4. Prepare Path (dissolve and buffer) ---\nimport prepare_path\nbuffered_path = \"C:/Users/path/to/buffered/polygon.shp\"\nbuffer_width = 30.0\noriginal_geometries, buffer, crs = prepare_path.create_dissolved_buffer(debris_flow_path, buffered_path, buffer_width)\nprepare_path.plot_shapefiles(original_geometries, buffer, crs)\n\n# --- 5. Apply Modified Voronoi ---\nimport apply_modified_voronoi\ninvestigation_polygons_shapefile = \"C:/Users/path/to/investigation/polygons.shp\"\nbuffer_distance = 0\n\npoints = apply_modified_voronoi.read_points_from_shapefile(output_shapefile_path)\npoints_array = np.array([[p.x, p.y] for p in points])\nx_min, y_min = points_array.min(axis=0)\nx_max, y_max = points_array.max(axis=0)\nextra_points = [\n apply_modified_voronoi.Point(x_min - buffer_distance, y_min - buffer_distance),\n apply_modified_voronoi.Point(x_min - buffer_distance, y_max + buffer_distance),\n apply_modified_voronoi.Point(x_max + buffer_distance, y_min - buffer_distance),\n apply_modified_voronoi.Point(x_max + buffer_distance, y_max + buffer_distance)\n]\npoints.extend(extra_points)\n\nwith fiona.open(buffered_path, 'r') as src:\n original_polygon = apply_modified_voronoi.unary_union([apply_modified_voronoi.Polygon(feat['geometry']['coordinates'][0]) for feat in src])\nclipped_voronoi_polygons = apply_modified_voronoi.compute_voronoi_polygons(points, original_polygon, buffer_distance)\napply_modified_voronoi.save_voronoi_polygons_to_shapefile(clipped_voronoi_polygons, investigation_polygons_shapefile)\napply_modified_voronoi.plot_voronoi_on_map(points, extra_points, clipped_voronoi_polygons, debris_flow_path)\napply_modified_voronoi.plot_voronoi_polygon_areas(clipped_voronoi_polygons)\napply_modified_voronoi.voronoi_polygon_qc(investigation_polygons_shapefile)\n\n# --- 6. Estimate Volumes and Plot ---\nimport estimate_volume_and_plot\nraster_path = output_raster # or your change detection raster\nLoD = 0.25 # User-defined detection limit\npolygon_ids = ['803', '830', '766'] # Example tributary IDs\n\nestimate_volume_and_plot.extract_raster_values(raster_path, investigation_polygons_shapefile, debris_flow_path, LoD)\nestimate_volume_and_plot.plot_polygons(investigation_polygons_shapefile, 'dep_vol', cmap='Blues')\nestimate_volume_and_plot.plot_polygons(investigation_polygons_shapefile, 'ero_vol', cmap='Reds_r')\nestimate_volume_and_plot.plot_polygons(investigation_polygons_shapefile, 'net_mob', cmap='Purples_r')\nestimate_volume_and_plot.plot_attributes_vs_distance_bar(investigation_polygons_shapefile)\nestimate_volume_and_plot.plot_YR_vs_distance(investigation_polygons_shapefile)\nestimate_volume_and_plot.plot_YR_vs_catchment(investigation_polygons_shapefile)\nestimate_volume_and_plot.plot_attributes_vs_catchment_bar(investigation_polygons_shapefile)\nestimate_volume_and_plot.plot_attributes_vs_catchment_log_bar(investigation_polygons_shapefile)\nestimate_volume_and_plot.plot_cumulative_vs_distance(investigation_polygons_shapefile)\nestimate_volume_and_plot.plot_cumulative_vs_catchment(investigation_polygons_shapefile)\nestimate_volume_and_plot.plot_cumulative_vs_distance_scatter(investigation_polygons_shapefile)\nestimate_volume_and_plot.plot_cumulative_vs_catchment_scatter(investigation_polygons_shapefile)\n```\n\n## Copyright\n\n- Copyright \u00a9 2025 Lauren Guido.\n- Free software distributed under the [MIT License](./LICENSE).\n",
"bugtrack_url": null,
"license": null,
"summary": "This model generates investigation polygons which are used to estimate and store incremental erosion and deposition volumes along the path of a debris flow at user- defined resolution. The user will need: 1) a .LAS or .TIF of topographic change, 2) a DEM of the AOI, and 3) a shapefile (polyline) of the debris flow path of interest. Each incremental volume is georeferenced and stored within a shapefile attribute associated with a catchment area and distance from outlet for analysis.",
"version": "0.1.2",
"project_urls": {
"Bug Tracker": "https://https://github.com/laurenguido/IncrementalDerisFlowVolumeAnalyzer/blob/main/CHANGELOG.md",
"Documentation": "https://https://csdms.colorado.edu/wiki/Model:IncrementalDebrisFlowVolumeAnalyzer",
"Download": "https://pypi.org/project/idfva/#files",
"Homepage": "https://https://github.com/laurenguido/IncrementalDerisFlowVolumeAnalyzer",
"Source Code": "https://https://github.com/laurenguido/IncrementalDerisFlowVolumeAnalyzer/tree/main/idfva"
},
"split_keywords": [
"debris flow",
" erosion",
" erosion/deposition",
" flow path",
" hazards",
" lateral erosion"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "e962109935e4ec04e99df4a66b584b1a6b96f4b5fe390663aadd018d9678af22",
"md5": "b3f12f050ce87f2b72bc287d18f422c7",
"sha256": "b3f6cb583ea92c25333330f16a4191c41ab00b47d9347966597b416f88bd3fdc"
},
"downloads": -1,
"filename": "idfva-0.1.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "b3f12f050ce87f2b72bc287d18f422c7",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 22184,
"upload_time": "2025-08-20T21:36:38",
"upload_time_iso_8601": "2025-08-20T21:36:38.264092Z",
"url": "https://files.pythonhosted.org/packages/e9/62/109935e4ec04e99df4a66b584b1a6b96f4b5fe390663aadd018d9678af22/idfva-0.1.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "053ab3008934c8e7f499e2c9545af07a870b3dc0e2c1caf18594e9efa7272de8",
"md5": "c3a72bb2d8946ff384ccb41114610e83",
"sha256": "2ca9d67de6dab0a81faaa7aa13cdf70f02c8fb0191b3ddaa5e0b90cb5f387423"
},
"downloads": -1,
"filename": "idfva-0.1.2.tar.gz",
"has_sig": false,
"md5_digest": "c3a72bb2d8946ff384ccb41114610e83",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 22702,
"upload_time": "2025-08-20T21:36:36",
"upload_time_iso_8601": "2025-08-20T21:36:36.155663Z",
"url": "https://files.pythonhosted.org/packages/05/3a/b3008934c8e7f499e2c9545af07a870b3dc0e2c1caf18594e9efa7272de8/idfva-0.1.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-08-20 21:36:36",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "idfva"
}