Module contents

class GeoAnalyze.File[source]

Bases: object

Functionality for file operations.

copy_rename_and_paste(src_folder: str, dst_folder: str, rename_map: dict[str, str]) list[str][source]

Copies files from the source folder and renames them in the destination folder. Unlike the GeoAnalyze.File.transfer_by_name() method, the source and destination folders can be the same, allowing for files to be renamed in place.

Parameters:
  • src_folder (str) – Path of the source folder containing the files to copy.

  • dst_folder (str) – Path of the destination folder where the copied files will be placed with new names.

  • rename_map (dict) – Dictionary where the keys are the original file names (without extensions) from the source folder, and the values are the new names (without extensions) for the destination folder. The file extensions will be preserved.

Returns:

A list of file names that were copied and renamed in the destination folder.

Return type:

list

delete_by_name(folder_path: str, file_names: list[str]) list[str][source]

Delete files of the same name irrespective of extensions and return a list o deleted file names.

Parameters:
  • folder_path (str) – Path of the input folder containing the files to delete.

  • file_names (list) – List of file names (without extension) to delete.

Returns:

A list of file names that were deleted.

Return type:

list

extract_specific_extension(folder_path: str, extension: str) list[str][source]

Extracts files with a specified extension from a folder.

Parameters:
  • folder_path (str) – Path of the input folder for searching files.

  • extension (str) – File extension to search for, including the leading period (e.g., ‘.tif’).

Returns:

A list of file names with the specified extension. Files with multiple extensions (e.g., ‘.tif.aux.xml’) are excluded.

Return type:

list

name_change(folder_path: str, rename_map: dict[str, str]) dict[str, str][source]

Rename files in the folder according to the provided mapping.

Parameters:
  • folder_path (str) – Path of the folder containing the files to rename.

  • rename_map (dict) – Dictionary mapping old file names (without extension) to new file names.

Returns:

A dictionary mapping old file names to new file names, with their extensions.

Return type:

dict

transfer_by_name(src_folder: str, dst_folder: str, file_names: list[str]) list[str][source]

Transfer files of the same name irrespective of extensions from the source folder to the destination folder.

Parameters:
  • src_folder (str) – Path of the source folder containing the files to transfer.

  • dst_folder (str) – Path of the destination folder for the transferred files.

  • file_names (list) – List of file names (without extension) to transfer.

Returns:

A list of file names that were transferred.

Return type:

list

class GeoAnalyze.Raster[source]

Bases: object

Provides functionality for raster file operations.

array_from_geometries(shape_file: str, value_column: str, mask_file: str, output_file: str, select_values: list[float] | None = None, all_touched: bool = True, fill_value: float | None = None, dtype: str | None = None, nodata: float | None = None) Profile[source]

Converts geometries corresponding to specified float values in a shapefile column into a raster array. If no specific value is provided, all values in the column will be used.

Parameters:
  • shape_file (str) – Path to the input shapefile containing the geometries.

  • value_column (str) – Column name that contains integer or float values to be inserted into the raster array.

  • mask_file (str) – Path to the mask raster file containing any type of values, defining the spatial extent and resolution of the output raster.

  • output_file (str) – Path to save the output raster file.

  • select_values (list, optional) – A list of specific float values from the selected column to include. If None, all values from the selected column are used.

  • all_touched (bool, optional) – If True, all pixels touched by geometries will be considered; otherwise, only pixels whose center is within the geometries will be considered. Default is True.

  • fill_value (float, optional) – Optional value to assign to NoData pixels not covered by the geometries within the mask region.

  • dtype (str, optional) – Data type of the output raster. If None, the data type of the input raster is retained.

  • nodata (float, optional) – NoData value to assign in the output raster. If None, the NoData value of the input raster is retained.

Returns:

A profile containing metadata about the output raster.

Return type:

profile

array_from_geometries_without_mask(shape_file: str, value_column: str, resolution: float, output_file: str, select_values: list[float] | None = None, all_touched: bool = True, dtype: str = 'int16', nodata: float = -9999) Profile[source]

Converts selected geometries from a shapefile into a raster array with a specified resolution. The raster values are taken from a specified column in the shapefile. If no specific value is provided, all values in the column will be used. The output raster uses the Coordinate Reference System (CRS) of the input shapefile.

Parameters:
  • shape_file (str) – Path to the input shapefile containing the geometries.

  • value_column (str) – Column name that contains integer or float values to be inserted into the raster array.

  • resolution (float) – Spatial resolution (in meters) of the output raster.

  • output_file (str) – Path to save the output raster file.

  • select_values (list, optional) – A list of specific float values from the selected column to include. If None, all values from the selected column are used.

  • all_touched (bool, optional) – If True, all pixels touched by geometries will be considered; otherwise, only pixels whose center is within the geometries will be considered. Default is True.

  • dtype (str, optional) – Data type of the output raster. Default is ‘int16’.

  • nodata (float, optional) – NoData value to assign to areas not covered by input geometries. Default is -9999.

Returns:

A profile containing metadata about the output raster.

Return type:

profile

array_to_geometries(raster_file: str, shape_file: str, select_values: tuple[float, ...] = ()) GeoDataFrame[source]

Extract geometries from a raster array for the selected values.

Parameters:
  • raster_file (str) – Path to the input raster file.

  • shape_file (str) – Path to save the output shapefile.

  • select_values (tuple, optional) – A tuple of selected raster values. All raster values will be selected if the tuple is left empty by default.

Returns:

A GeoDataFrame containing the extracted geometries and their corresponding raster values.

Return type:

GeoDataFrame

boundary_polygon(raster_file: str, shape_file: str) GeoDataFrame[source]

Extracts boundary polygons from a raster array.

Parameters:
  • raster_file (str) – Path to the input raster file.

  • shape_file (str) – Path to save the output shapefile.

Returns:

A GeoDataFrame containing the boundary polygons extracted from the raster.

Return type:

GeoDataFrame

clipping_by_shapes(input_file: str, shape_file: str, output_file: str) Profile[source]

Clips a raster file using a given shape file.

Parameters:
  • input_file (str) – Path to the input raster file.

  • shape_file (str) – Path to the input shape file used for clipping.

  • output_file (str) – Path to save the output raster file.

Returns:

A profile containing metadata about the output raster.

Return type:

profile

count_data_cells(raster_file: str) int[source]

Counts the number of cells in the raster file that have valid data.

Parameters:

raster_file (str) – Path to the input raster file.

Returns:

The numer of cells with valid data in the raster file.

Return type:

int

count_nodata_cells(raster_file: str) int[source]

Counts the number of NoData cells in the raster file.

Parameters:

raster_file (str) – Path to the input raster file.

Returns:

The numer of NoData cells in the raster file.

Return type:

int

count_unique_values(raster_file: str, csv_file: str, multiplier: float = 1, remove_values: tuple[float, ...] = (), ascending_values: bool = True) DataFrame[source]

Returns a DataFrame containing the unique values and their counts in a raster array. If the raster contains decimal values, the specified multiplier scales them to integers for counting purposes. The values are then scaled back to their original decimal form by dividing by the multiplier.

Parameters:
  • raster_file (str) – Path to the input raster file.

  • csv_file (str) – Path to save the output csv file.

  • multiplier (float, optional) – A factor to multiply raster values to handle decimal values by rounding. Default is 1, which implies no scaling.

  • remove_values (tuple, optional) – A tuple of float values to exclude from counting. These values must match the result of multiplying raster values by the multiplier. Default is an empty tuple.

  • ascending_values (bool, optional) – If False, unique values are sorted in descending order. Defaults to True.

Returns:

A DataFrame containing the raster values, their counts, and their counts as a percentage of the total.

Return type:

DataFrame

crs_assign(input_file: str, crs_code: int, output_file: str, driver: str | None = None) Profile[source]

Assigns a projected Coordinate Reference System (CRS) to a raster file that lacks one.

Parameters:
  • input_file (str) – Path to the input raster file.

  • crs_code (int) – EPSG code of the projected CRS to assign (e.g., 32638).

  • output_file (str) – Path to save the projected raster file.

  • driver (str, optional) – GDAL driver to use for the output file (e.g., ‘GTiff’). If None, the driver of the input raster is used.

Returns:

A profile containing metadata about the output raster.

Return type:

profile

crs_removal(input_file: str, output_file: str) Profile[source]

Removes the Coordinate Reference System (CRS) from a raster file.

Parameters:
  • input_file (str) – Path to the input raster file.

  • output_file (str) – Path to the output raster file with CRS removed.

Returns:

A profile containing metadata about the output raster.

Return type:

profile

crs_reprojection(input_file: str, resampling_method: str, target_crs: str, output_file: str, nodata: float | None = None) Profile[source]

Reprojects a raster array to a new Coordinate Reference System.

Parameters:
  • input_file (str) – Path to the input raster file.

  • resampling_method (str) – Raster resampling method with supported options from GeoAnalyze.core.Core.raster_resampling_method.

  • target_crs (str) – Target Coordinate Reference System for the output raster (e.g., ‘EPSG:4326’).

  • output_file (str) – Path to save the reprojected raster file.

  • nodata (float, optional) – NoData value to assign in the output raster. If None, the NoData value of the input raster is retained.

Returns:

A profile containing metadata about the output raster.

Return type:

profile

driver_convert(input_file: str, target_driver: str, output_file: str) Profile[source]

Converts the input raster file to a new format using the specified driver.

Parameters:
  • input_file (str) – Path to the input raster file.

  • target_driver (str) – GDAL-compatible name of the target driver (e.g., ‘GTiff’, ‘RST’).

  • output_file (str) – Path to save the output raster file.

Returns:

A metadata profile containing information about the output raster.

Return type:

profile

extract_value_by_mask(input_file: str, mask_file: str, output_file: str, remove_values: list[float] | None = None, fill_value: float | None = None, dtype: str | None = None, nodata: float | None = None) list[float][source]

Extracts values from the input raster based on the valid cells of the mask raster. Both rasters must share the same cell alignment, coordinate reference system (CRS), and pixel resolution; otherwise, the result may be incorrect.

Parameters:
  • input_file (str) – Path to the input raster file.

  • mask_file (str) – Path to the mask raster file. All non-NoData values are treated as valid mask cells for extracting corresponding values from the input raster.

  • output_file (str) – Path to save the output raster file.

  • remove_values (list, optional) – A list of float values to exclude from the mask raster. If None, all valid values from the mask raster are used.

  • fill_value (float, optional) – The value to assign in the output raster where the input raster contains NoData, but the corresponding mask raster cells are valid.

  • dtype (str, optional) – Data type of the output raster. If None, the data type of the input raster is retained.

  • nodata (float, optional) – NoData value to assign in the output raster. If None, the NoData value of the input raster is retained.

Returns:

A list of unique values extracted from the output raster, verifying the successful extraction process.

Return type:

list

extract_value_by_range(input_file: str, output_file: str, lower_bound: float | None = None, greater_strict: bool = False, upper_bound: float | None = None, lesser_strict: bool = False, dtype: str | None = None, nodata: float | None = None) list[float][source]

Extracts raster values within a specified value range.

Parameters:
  • input_file (str) – Path to the input raster file.

  • output_file (str) – Path to save the output raster file after extracting values within the specified range.

  • lower_bound (float, optional) – Lower bound for value extraction. If None, the minimum value from the input raster is used.

  • greater_strict (bool, optional) – If False (default), values greater than or equal to lower_bound are included. If True, only values strictly greater than lower_bound are included.

  • upper_bound (float, optional) – Upper bound for value extraction. If None, the maximum value from the input raster is used.

  • lesser_strict (bool, optional) – If False (default), values less than or equal to upper_bound are included. If True, only values strictly less than upper_bound are included.

  • dtype (str, optional) – Data type of the output raster. If None, the data type of the input raster is retained.

  • nodata (float, optional) – NoData value to assign in the output raster. If None, the NoData value of the input raster is retained.

Returns:

A list containing the minimum and maximum values of the output raster, verifying the successful application of the value range.

Return type:

list

merging_files(folder_path: str, raster_file: str, raster_extension: str = '.tif', dtype: str | None = None, nodata: float | None = None) Profile[source]

Merges raster files with the same Coordinate Reference System and data type.

Parameters:
  • folder_path (str) – Path to the folder containing the raster files to be merged. The folder must contain only the rasters intended for merging.

  • raster_file (str) – Path to save the merged output raster file.

  • raster_extension (str, optional) – File extension of the input raster files. Default is ‘.tif’.

  • dtype (str, optional) – Data type of the output raster. If None, the data type of the input rasters is retained.

  • nodata (float, optional) – NoData value to assign in the output raster. If None, the NoData value of the input rasters is retained.

Returns:

A metadata profile containing information about the output raster.

Return type:

profile

nodata_conversion_from_value(input_file: str, target_value: list[float], output_file: str) Profile[source]

Converts specified values in a raster array to NoData.

Parameters:
  • input_file (str) – Path to the input raster file.

  • target_value (list) – List of float values in the input raster array to convert to nodata.

  • output_file (str) – Path to save the output raster file.

Returns:

A profile containing metadata about the output raster.

Return type:

profile

nodata_extent_trimming(input_file: str, output_file: str) Profile[source]

Trims rows and columns that contain only NoData values in the raster array.

Parameters:
  • input_file (str) – Path to the input raster file.

  • output_file (str) – Path to save the output raster file.

Returns:

A profile containing metadata about the output raster.

Return type:

profile

nodata_to_valid_value(input_file: str, valid_value: float, output_file: str, dtype: str | None = None) Profile[source]

Converts NoData values in a raster to a specified valid value.

Parameters:
  • input_file (str) – Path to the input raster file.

  • valid_value (float) – Value to replace NoData values in the output raster. If this value is the same as the current NoData value, the NoData will be set to None in the output.

  • output_file (str) – Path to save the output raster file.

  • dtype (str, optional) – Data type of the output raster. If None, the data type of the input raster is retained.

Returns:

A profile containing metadata about the output raster.

Return type:

profile

nodata_value_change(input_file: str, nodata: float, output_file: str, dtype: str | None = None) Profile[source]

Modifies the NoData value of a raster array.

Parameters:
  • input_file (str) – Path to the input raster file.

  • nodata (float) – New NoData value to be assigned to the output raster.

  • output_file (str) – Path to save the output raster file.

  • dtype (str, optional) – Data type of the output raster. If None, the data type of the input raster is retained.

Returns:

A profile containing metadata about the output raster.

Return type:

profile

overlaid_with_geometries(input_file: str, shape_file: str, value_column: str, output_file: str, select_values: list[float] | None = None, all_touched: bool = True, dtype: str | None = None, nodata: float | None = None) list[float][source]

Overlays geometries corresponding to specified float values in a shapefile column onto the input raster. If no specific value is provided, all values in the column will be used.

Parameters:
  • input_file (str) – Path to the input raster file.

  • shape_file (str) – Path to the shapefile containing geometries to overlay on the raster.

  • value_column (str) – Column name that contains integer or float values to be inserted into the raster array.

  • output_file (str) – Path to save the output raster file.

  • select_values (list, optional) – A list of specific float values from the selected column to include. If None, all values from the selected column are used.

  • all_touched (bool, optional) – If True, all pixels touched by geometries will be considered; otherwise, only pixels whose center is within the geometries will be considered. Default is True.

  • dtype (str, optional) – Data type of the output raster. If None, the data type of the input raster is retained.

  • nodata (float, optional) – NoData value to assign in the output raster. If None, the NoData value of the input raster is retained.

Returns:

A list containing the unique values from the output raster, confirming that the geometries have been successfully overlaid.

Return type:

list

reclassify_by_constant_value(input_file: str, constant_value: float, output_file: str, dtype: str | None = None) list[float][source]

Reclassifies raster by assigning a constant value to all pixels.

Parameters:
  • input_file (str) – Path to the input raster file.

  • constant_value (float) – Constant value to be assigned to all pixels in the output raster.

  • output_file (str) – Path to save the output raster file.

  • dtype (str, optional) – Data type of the output raster. If None, the data type of the input raster is retained.

Returns:

A list containing the unique values from the output raster, confirming that the raster has been successfully reclassified.

Return type:

list

reclassify_by_value_mapping(input_file: str, reclass_map: dict[tuple[float, ...], float], output_file: str, dtype: str | None = None) list[float][source]

Reclassifies raster values based on a specified mapping.

Parameters:
  • input_file (str) – Path to the input raster file.

  • reclass_map (dict) – Dictionary mapping raster values to reclassified values. The keys are tuples of raster values, and the corresponding values are the reclassified values.

  • output_file (str) – Path to save the output raster file.

  • dtype (str, optional) – Data type of the output raster. If None, the data type of the input raster is retained.

Returns:

A list containing the unique values from the output raster, confirming that the raster has been successfully reclassified.

Return type:

list

reclassify_value_outside_boundary(area_file: str, extent_file: str, outside_value: float, output_file: str, dtype: str | None = None, nodata: float | None = None) list[float][source]

Reclassifies values outside a specified area in the input raster using an extent raster as a mask. Both rasters must share the same cell alignment, coordinate reference system (CRS), and pixel resolution; otherwise, the result may be incorrect.

Parameters:
  • area_file (str) – Path to the raster file representing the area of interest.

  • extent_file (str) – Path to the extent raster file that encompasses the area raster.

  • outside_value (float) – The value to assign to cells outside the specified area.

  • output_file (str) – Path to save the modified output raster file.

  • dtype (str, optional) – Data type of the output raster. If None, the data type of the area raster is retained.

  • nodata (float, optional) – NoData value to assign in the output raster. If None, the NoData value of the area raster is retained.

Returns:

A list containing the unique values from the output raster, verifying the successful insertion of the buffer value.

Return type:

list

resolution_rescaling(input_file: str, target_resolution: int, resampling_method: str, output_file: str) Profile[source]

Rescales the raster array from the existing resolution to a new target resolution.

Parameters:
  • input_file (str) – Path to the input raster file.

  • target_resolution (int) – Desired resolution of the output raster file.

  • resampling_method (str) – Raster resampling method with supported options from GeoAnalyze.core.Core.raster_resampling_method.

  • output_file (str) – Path to the output raster file.

Returns:

A profile containing metadata about the output raster.

Return type:

profile

resolution_rescaling_with_mask(input_file: str, mask_file: str, resampling_method: str, output_file: str) Profile[source]

Rescales the raster array from its existing resolution to match the resolution of a mask raster file.

Parameters:
  • input_file (str) – Path to the input raster file.

  • mask_file (str) – Path to the mask raster file containing any type of values, defining the spatial extent and resolution of the output raster.

  • resampling_method (str) – Raster resampling method with supported options from GeoAnalyze.core.Core.raster_resampling_method.

  • output_file (str) – Path to the output raster file.

Returns:

A profile containing metadata about the output raster.

Return type:

profile

statistics_summary(raster_file: str) dict[str, float][source]

Computes basic statistics (minimum, maximum, and mean) for a raster array.

Parameters:

raster_file (str) – Path to the input raster file.

Returns:

A dictionary where each key represents a statistical parameter, and its corresponding value is the computed result.

Return type:

dict

statistics_summary_by_reference_zone(zone_file: str, value_file: str, csv_file: str) DataFrame[source]

Calculates and returns summary statistics (minimum, maximum, mean, and standard deviation) of values in a raster file, grouped by unique zones defined in a reference zone raster.

Parameters:
  • zone_file (str) – Path to the input zone raster file.

  • value_file (str) – Path to the input value raster file.

  • csv_file (str) – Path to the CSV file where the output DataFrame will be saved.

Returns:

A DataFrame containing unique zone values and their corresponding statistics calculated from the value raster.

Return type:

pandas.DataFrame

value_scale_and_offset(input_file: str, output_file: str, scale: float = 1, offset: float = 0, dtype: str | None = None, nodata: float | None = None) Profile[source]

Applies a linear transformation to raster values \(x\) using the formula \(y = ax + b\), where \(a\) and \(b\) are the scale and offset input variables, respectively.

Parameters:
  • input_file (str) – Path to the input raster file.

  • output_file (str) – Path to the output raster file after applying the scale and offset.

  • scale (float, optional) – Scaling factor to apply to the raster values. Default is 1.

  • offset (float, optional) – Offset value to add to the scaled raster values. Default is 0.

  • dtype (str, optional) – Data type of the output raster. If None, the data type of the input raster is retained.

  • nodata (float, optional) – NoData value to assign in the output raster. If None, the NoData value of the input raster is retained.

Returns:

A profile containing metadata about the output raster.

Return type:

profile

class GeoAnalyze.Shape[source]

Bases: object

Provides functionality for shapefile operations.

aggregate_geometries_from_layers(input_file: str, geometry_type: str, output_file: str, column_list: list[str] | None = None, layer_column: str = 'layer', rename_columns: dict[str, str] = {}) GeoDataFrame[source]

Aggregates geometries of a specified type from multiple layers in an input file.

Parameters:
  • input_file (str) – Path to the input file containing multiple layers.

  • geometry_type (str) – Type of geometry to aggregate. Must be one of: ‘Point’, ‘LineString’, or ‘Polygon’.

  • output_file (str) – Path to the output file where the aggregated GeoDataFrame will be saved.

  • column_list (list, optional) – List of common columns (excluding ‘geometry’) to include in the aggregated GeoDataFrame. If None (default), only the ‘geometry’ column and an additional column with the layer name will be included.

  • layer_column (str, optional) – Name of the column that will store the layer names in the aggregated GeoDataFrame. Default is ‘layer’.

  • rename_columns (dict, optional) – A dictionary used to rename columns in the output GeoDataFrame. Default is an empty dictionary.

Returns:

A GeoDataFrame containing all geometries of the specified type aggregated from the layers of the input file, including a column with the corresponding layer names.

Return type:

GeoDataFrame

aggregate_geometries_from_shapefiles(folder_path: str, geometry_type: str, column_name: str, output_file: str) GeoDataFrame[source]

Aggregates geometries of a specified type from shapefiles in a folder.

Parameters:
  • folde_path (str) – Folder path containing the input shapefiles.

  • geometry_type (str) – Type of geometry to aggregate, one of ‘Point’, ‘LineString’, or ‘Polygon’.

  • column_name (str) – Name of the column where unique identifiers will be assigned to each geometry after aggregation.

  • output_file (str) – Path to save the output shapefile.

Returns:

A GeoDataFrame containing all geometries of the specified type aggregated from the shapefiles in the folder.

Return type:

GeoDataFrame

boundary_box(input_file: str, output_file: str, buffer_length: float = 0) GeoDataFrame[source]

Generate a rectangular bounding box from input geometries.

Parameters:
  • input_file (str) – Path to the shapefile containing input geometries.

  • output_file (str) – Path to the output shapefile where the bounding box polygon will be saved.

  • buffer_length (float, optional) – Distance to expand the bounding box on all sides. Default is 0.

Returns:

A GeoDataFrame containing a single polygon representing the bounding box.

Return type:

GeoDataFrame

column_add_for_id(input_file: str, column_name: str, output_file: str) GeoDataFrame[source]

Adds an identifier column to the geometries, starting from 1 and incrementing by 1.

Parameters:
  • input_file (str) – Path to the input shapefile.

  • colums_name (str) – Name of the identifier column to be added.

  • output_file (str) – Path to save the output shapefile.

Returns:

A GeoDataFrame with an added identifier column, where values start from 1 and increase by 1.

Return type:

GeoDataFrame

column_add_mapped_values(input_file: str, column_exist: str, column_new: str, mapping_value: dict[Any, Any], output_file: str) GeoDataFrame[source]

Adds a new column to the GeoDataFrame from the input shapefile, using a mapping applied to values in an existing column.

Parameters:
  • input_file (str) – Path to the input shapefile.

  • column_exsit (str) – Name of the existing column in the GeoDataFrame to be used for value mapping.

  • column_new (str) – Name of the new column to be added to the GeoDataFrame.

  • mapping_value (dict) – A dictionary where keys correspond to unique values in the existing column, and values are the new values to assign in the new column.

  • output_file (str) – Path to the shapefile where the output GeoDataFrame will be saved.

Returns:

A GeoDataFrame with an additional column containing values mapped from the existing column.

Return type:

GeoDataFrame

column_area_by_value(shape_file: str, column_name: str, csv_file: str, descending_area: bool = True) DataFrame[source]

Calculate the total area for each unique value in a specified column of the input shapefile.

Parameters:
  • shape_file (str) – Path to the input shapefile.

  • column_name (str) – Name of the target column.

  • csv_file (str) – Path to the CSV file where the output DataFrame will be saved.

  • descending_area (bool, optional) – If True, the output DataFrame is sorted in descending order by area. The default is True.

Returns:

A DataFrame with unique column values, their corresponding total area, and area percentage.

Return type:

DataFrame

column_delete(input_file: str, column_list: list[str], output_file: str) GeoDataFrame[source]

Delete specified columns from a GeoDataFrame. Useful when the user wants to delete specific columns.

Parameters:
  • input_file (str) – Path to the input shapefile.

  • column_list (list) – List of columns, apart from ‘geometry’, to delete in the output shapefile.

  • output_file (str) – Path to save the output shapefile.

Returns:

A GeoDataFrame with the deletion of speificed columns.

Return type:

GeoDataFrame

column_nondecimal_float_to_int_type(input_file: str, output_file: str) GeoDataFrame[source]

Converts float columns with whole numbers to integer.

Parameters:
  • input_file (str) – Path to the input shapefile.

  • output_file (str) – Path to save the output shapefile.

Returns:

A GeoDataFrame with applicable float columns converted to integer.

Return type:

GeoDataFrame

column_retain(input_file: str, column_list: list[str], output_file: str) GeoDataFrame[source]

Return a GeoDataFrame with geometry and specified columns. Useful when the user wants to remove unnecessary columns while retaining a few required ones.

Parameters:
  • input_file (str) – Path to the input shapefile.

  • column_list (list) – List of columns, apart from ‘geometry’, to include in the output shapefile.

  • output_file (str) – Path to save the output shapefile.

Returns:

A GeoDataFrame containing the speificed columns.

Return type:

GeoDataFrame

column_unique_values(shape_file: str, column_list: list[str] | None = None) dict[str, list[Any]][source]

Retrieves unique values from specified columns in a shapefile.

Parameters:
  • shape_file (str) – Path to the input shapefile.

  • column_list (list, optional) – List of column names to extract unique values from, excluding the ‘geometry’ column. Defaults to None, in which case all non-geometry columns are selected.

Returns:

A dictionary where each key is a column name and the corresponding value is a list of that column’s unique entries.

Return type:

dict

crs_reprojection(input_file: str, target_crs: str, output_file: str) GeoDataFrame[source]

Reprojects a GeoDataFrame to a new Coordinate Reference System.

Parameters:
  • input_file (str) – Path to the input shapefile.

  • target_crs (str) – Target Coordinate Reference System for the output GeoDataFrame (e.g., ‘EPSG:4326’).

  • output_file (str) – Path to save the output shapefile.

Returns:

A GeoDataFrame with reprojected Coordinate Reference System.

Return type:

GeoDataFrame

extract_polygons_by_overlap_threshold(input_file: str, mask_file: str, output_file: str, overlap_percent: float = 0, greater_strict: bool = False, overlap_col: str = 'overlap(%)') GeoDataFrame[source]

Extracts polygons from an input shapefile based on their overlap percentage with mask geometries.

Note

Although extraction is based on overlap percentage, the output shapefile will contain the entire original polygons, not clipped geometries.

Parameters:
  • input_file (str) – Path to the input polygon shapefile.

  • mask_file (str) – Path to the mask polygon shapefile used for overlap calculation.

  • output_file (str) – Path to the output shapefile where the extracted polygons will be saved.

  • overlap_percent (float, optional) – Threshold for minimum percentage of overlap to include a polygon. Default is 0, meaning all overlapping geometries are included.

  • greater_strict (bool, optional) – If False (default), includes polygons with overlap percentage greater than or equal to overlap_percent. If True, includes only those with overlap strictly greater than overlap_percent.

  • overlap_col (str, optional) – Name of the column in the output shapefile that will store the computed overlap percentages. Default is ‘overlap(%)’.

Returns:

A GeoDataFrame containing polygons that meet the specified overlap threshold with the mask geometries.

Return type:

GeoDataFrame

extract_spatial_join_geometries(input_file: str, overlay_file: str, output_file: str) GeoDataFrame[source]

Performs a spatial join to extract geometries that intersect with other geometries.

Parameters:
  • input_file (str) – Path to the input shapefile.

  • overlay_file (str) – Path to the input overlay shapefile.

  • output_file (str) – Path to save the output shapefile.

Returns:

A GeoDataFrame of extracted geometries that intersect with other geometries.

Return type:

GeoDataFrame

polygon_count_by_cumsum_area(shape_file: str) dict[float, int][source]

Sorts the polygons by area in descending order, calculate cumulative sum percentages, and returns a dictionary with cumulative area percentages as keys and the corresponding cumulative polygon counts as values.

Parameters:

shape_file (str) – Path to the input shapefile.

Returns:

A dictionary where the keys are cumulative percentage areas of polygons, and values are the cumulative counts of polygons.

Return type:

dict

polygon_fill(input_file: str, output_file: str, explode: bool = False) GeoDataFrame[source]

Fills holes in polygon.

Parameters:
  • input_file (str) – Path to the input shapefile.

  • output_file (str) – Path to save the output shapefile.

  • explode (bool, optional) – Explode the multi-part polygons, if any, into single pieces and fill the holes, if any, inside the polygons. Default is False

Returns:

A GeoDataFrame with any holes in the polygons filled.

Return type:

GeoDataFrame

polygon_fill_after_merge(input_file: str, column_name: str, output_file: str) GeoDataFrame[source]

Merges overlapping polygons, explodes multi-part, and fills any holes within the polygons.

Parameters:
  • input_file (str) – Path to the input shapefile.

  • column_name (str) – Name of the column to assign unique identifiers to each polygon after merging.

  • output_file (str) – Path to save the output shapefile.

Returns:

A GeoDataFrame containing individual polygons after merging, exploding, and filling holes, with each polygon assigned an ID from the specified column.

Return type:

GeoDataFrame

polygons_remove_by_cumsum_area_percent(input_file: str, percent_cutoff: float, output_file: str, index_sort: bool = False) GeoDataFrame[source]

Sorts the percentage area of polygons in descending order and removes polygons whose cumulative percentage exceeds the specified cutoff (ranging from 0 to 100).

Parameters:
  • input_file (str) – Path to the input shapefile.

  • percent_cutoff (float) – Only polygons with a cumulative area percentage less than or equal to the specified cutoff (between 0 and 100) are retained.

  • output_file (str) – Path to save the output shapefile.

  • index_sort (bool, False) – If True, polygons are sorted by their index before sorting cumulative area percentages.

Returns:

A GeoDataFrame containing polygons with a cumulative area percentage less than or equal to the specified cutoff.

Return type:

GeoDataFrame

polygons_to_boundary_lines(input_file: str, output_file: str) GeoDataFrame[source]

Extracts boundary lines from polygons.

Parameters:
  • input_file (str) – Path to the input polygon shapefile.

  • output_file (str) – Path to save the output line shapefile.

Returns:

A GeoDataFrame containing the extracted boundary lines of the polygons.

Return type:

GeoDataFrame

class GeoAnalyze.Stream[source]

Bases: object

Provides functionality for stream path operations.

box_cross_selected_segment_at_endpoint(input_file: str, column_name: str, column_value: Any, box_length: float, output_file: str, downstream_point: bool = True) GeoDataFrame[source]

Creates a square box polygon that crosses a specified segment in the stream path and passes through an endpoint of the segment.

Parameters:
  • input_file (str) – Path to the input stream shapefile.

  • column_name (str) – Name of the column used for selecting the target stream segment.

  • column_value (Any) – Value in the specified column that identifies the target stream segment.

  • box_length (float) – Length of each side of the square box polygon.

  • output_file (str) – Path to save the output box polygon shapefile.

  • downstream_point (bool, optional) – If True, the box is positioned to pass through the downstream endpoint of the segment; if False, it passes through the upstream endpoint. Default is True.

Returns:

A GeoDataFrame containing the box polygon, which crosses the specified stream segment and passes through an endpoint of the segment.

Return type:

GeoDataFrame

box_touch_selected_segment(input_file: str, column_name: str, column_value: Any, box_length: float, output_file: str) GeoDataFrame[source]

Creates a square box polygon that touches a specified segment in the stream path at a randomly chosen point along the segment.

Parameters:
  • input_file (str) – Path to the input stream shapefile.

  • column_name (str) – Name of the column used for selecting the target stream segment.

  • column_value (Any) – Value in the specified column that identifies the target stream segment.

  • box_length (float) – Length of each side of the square box polygon.

  • output_file (str) – Path to save the output box polygon shapefile.

Returns:

A GeoDataFrame containing the created box polygon, which touches the specified stream segment at a random point.

Return type:

GeoDataFrame

box_touch_selected_segment_at_endpoint(input_file: str, column_name: str, column_value: Any, box_length: float, output_file: str, upstream_point: bool = True) GeoDataFrame[source]

Creates a square box polygon that touches an endpoint of a specified segment in the input stream path.

Parameters:
  • input_file (str) – Path to the input stream shapefile.

  • column_name (str) – Name of the column used for selecting the target stream segment.

  • column_value (Any) – Value in the specified column that identifies the target stream segment.

  • box_length (float) – Length of each side of the square box polygon.

  • output_file (str) – Path to save the output box polygon shapefile.

  • upstream_point (bool, optional) – If True, the box is positioned to pass through the upstream endpoint of the segment; if False, it passes through the downstream endpoint. Default is True.

Returns:

A GeoDataFrame containing the box polygon, which touches an endpoint of the specified segment in the input stream path.

Return type:

GeoDataFrame

connectivity_adjacent_downstream_segment(input_file: str, stream_col: str, output_file: str, link_col: str = 'ds_id', unlinked_id: int = -1) GeoDataFrame[source]

Identifies the adjacent connected downstream identifier for each segment in a stream network shapefile.

Parameters:
  • input_file (str) – Path to the input stream shapefile.

  • stream_col (str) – Column name in the stream shapefile containing a unique identifier for each stream segment.

  • output_file (str) – Path to save the output stream shapefile with adjacent downstream connectivity information.

  • link_col (str, optional) – Name of the column to store the connected downstream segment identifiers. Default is ‘ds_id’.

  • unlinked_id (int, optional) – Value to assign when a downstream segment identifier is not found. Default is -1.

Returns:

A GeoDataFrame representing the input shapefile, enhanced with an additional column that indicates the downstream segment identifier for each feature.

Return type:

GeoDataFrame

connectivity_adjacent_upstream_segment(stream_file: str, stream_col: str, csv_file: str, link_col: str = 'us_id', unlinked_id: int = -1) DataFrame[source]

Identifies the adjacent connected upstream identifiers for each segment in a stream network shapefile.

Parameters:
  • input_file (str) – Path to the input stream shapefile.

  • stream_col (str) – Column name in the stream shapefile containing a unique identifier for each stream segment.

  • csv_file (str) – Path to save the output CSV file with adjacent upstream connectivity information.

  • link_col (str, optional) – Name of the column to store the connected upstream segment identifiers. Default is ‘us_id’.

  • unlinked_id (int, optional) – Value to assign when an upstream segment identifier is not found. Default is -1.

Returns:

A DataFrame with two columns stream_col and link_col. The stream_col contains stream segment identifiers (which may appear multiple times), and the link_col contains their corresponding connected adjacent upstream segment identifiers.

Return type:

DataFrame

connectivity_downstream_to_upstream(stream_file: str, stream_col: str, json_file: str) dict[float, list[list[float]]][source]

Identifies the connected upstream structure for each segment in a stream network shapefile, tracing all upstream paths until reaching a headwater segment.

Parameters:
  • stream_file (str) – Path to the input stream shapefile.

  • stream_col (str) – Column name in the stream shapefile containing a unique identifier for each stream segment.

  • json_file (str) – Path to save the output JSON file representing downstream to upstream connections.

Returns:

A dictionary where each key is a stream segment identifier, and the corresponding value is a list of lists, each representing a unique upstream path ending at a headwater segment.

Return type:

dict

connectivity_merge_of_split_segments(input_file: str, stream_col: str, output_file: str, json_file: str) GeoDataFrame[source]

Merges split segments in the stream network, if any, either between two junction points or from a junction point upstream until a headwater occurs. The merged segment is assigned the identifier of the most downstream segment among those being merged.

Parameters:
  • input_file (str) – Path to the input stream shapefile.

  • stream_col (str) – Column name in the stream shapefile containing a unique identifier for each stream segment.

  • output_file (str) – Path to save the output stream shapefile with updated downstream connectivity information.

  • json_file (str) – Path to save the output JSON file representing the merge information of stream segments. For example, {5: [4, 39, 38, 2]} indicates that stream segment 5 is the result of merging segments 4, 39, 38, and 2, which are consecutively connected from downstream to upstream until a junction point is reached or no upstream segment exists.

Returns:

A GeoDataFrame where each merged segment is represented by the most downstream segment identifier, absorbing all connected upstream segments either between junction points or from a junction point to a headwater.

Return type:

GeoDataFrame

connectivity_remove_to_headwater(input_file: str, stream_col: str, remove_segments: list[float], output_file: str) GeoDataFrame[source]

Removes targeted stream segments and all their upstream connections up to headwaters in a stream network shapefile.

Parameters:
  • input_file (str) – Path to the input stream shapefile.

  • stream_col (str) – Column name in the stream shapefile containing a unique identifier for each stream segment.

  • remove_segments (list) – A list of stream segment identifiers to remove, along with all their upstream connections up to the headwaters.

  • output_file (str) – Path to save the output stream shapefile after removing the specified segments and their upstream connections.

Returns:

A GeoDataFrame representing the updated stream network after removing the targeted stream segments and their upstream paths.

Return type:

GeoDataFrame

connectivity_to_all_upstream_segments(stream_file: str, stream_col: str, csv_file: str, link_col: str = 'us_id', unlinked_id: int = -1) DataFrame[source]

Converts the dictionary output from the GeoAnalyze.Stream.conncetivity_downstream_to_upstream() method into a DataFrame with two columns: stream_col and link_col, representing stream segment identifiers (which may appear multiple times) and their corresponding consecutively connected upstream segments ending at a headwater segment, respectively.

Parameters:
  • stream_file (str) – Path to the input stream shapefile.

  • stream_col (str) – Column name in the stream shapefile containing a unique identifier for each stream segment.

  • csv_file (str) – Path to save the output JSON file representing downstream to upstream connections.

  • link_col (str, optional) – Name of the column to store the connected upstream segment identifiers. Default is ‘us_id’.

  • unlinked_id (int, optional) – Value to assign when a upstream segment identifier is not found. Default is -1.

Returns:

A DataFrame with two columns stream_col and link_col. The stream_col contains stream segment identifiers (which may appear multiple times), and the link_col contains their corresponding consecutively connected upstream segment identifiers ending at a headwater segment.

Return type:

DataFrame

connectivity_upstream_to_downstream(stream_file: str, stream_col: str, json_file: str) dict[float, list[float]][source]

Identifies all consecutively connected downstream segment identifiers up to the outlet point for each segment in a stream network shapefile.

Parameters:
  • stream_file (str) – Path to the input stream shapefile.

  • stream_col (str) – Column name in the stream shapefile containing a unique identifier for each stream segment.

  • json_file (str) – Path to save the output JSON file representing upstream to downstream connections.

Returns:

A dictionary where each key is a stream segment identifier, and the corresponding value is a list of all consecutively connected downstream identifiers, ending at the outlet. If no connected downstream segment is found, the value list contains the segment identifier itself.

Return type:

dict

flw_path_reverse(input_file: str, output_file: str) GeoDataFrame[source]

Reverses the coordinate order for each segment in the input flow path, ensuring that the starting point of each segment becomes its most upstream point.

Parameters:
  • input_file (str) – Path to the input stream shapefile.

  • output_file (str) – Path to save the output stream shapefile.

Returns:

A GeoDataFrame with each stream segment’s coordinates reversed.

Return type:

GeoDataFrame

flw_path_us2ds_check(stream_file: str) bool[source]

Checks the flow path direction from upstream to downstream by comparing the number of segments in the flow path to the number of their most upstream points.

Parameters:

stream_file (str) – Path to the input stream shapefile.

Returns:

True if the number of flow path segments aligns with the number of upstream points, indicating correct flow direction; otherwise, False.

Return type:

bool

order_shreve(input_file: str, stream_col: str, output_file: str, order_col: str = 'shreve') GeoDataFrame[source]

Computes the Shreve order for each segment in a stream network shapefile.

Parameters:
  • input_file (str) – Path to the input stream shapefile.

  • stream_col (str) – Column name in the stream shapefile containing a unique identifier for each stream segment.

  • output_file (str) – Path to save the output stream shapefile with Shreve stream order information.

  • order_col (str, optional) – Name of the column to store the Shreve order of stream segments. Default is ‘shreve’.

Returns:

A GeoDataFrame representing the input shapefile, enhanced with an additional column that indicates the Shreve stream order for each stream segment.

Return type:

GeoDataFrame

order_strahler(input_file: str, stream_col: str, output_file: str, order_col: str = 'strahler') GeoDataFrame[source]

Computes the Strahler order for each segment in a stream network shapefile.

Parameters:
  • input_file (str) – Path to the input stream shapefile.

  • stream_col (str) – Column name in the stream shapefile containing a unique identifier for each stream segment.

  • output_file (str) – Path to save the output stream shapefile with Strahler stream order information.

  • order_col (str, optional) – Name of the column to store the Strahler order of stream segments. Default is ‘strahler’.

Returns:

A GeoDataFrame representing the input shapefile, enhanced with an additional column that indicates the Strahler stream order for each stream segment.

Return type:

GeoDataFrame

point_headwaters(input_file: str, stream_col: str, output_file: str) GeoDataFrame[source]

Identifies headwater points in the stream network. A headwater point is defined as the starting point of a stream segment with no upstream connections.

Parameters:
  • input_file (str) – Path to the input stream shapefile.

  • output_file (str) – Path to save the output shapefile containing identified headwater points.

Returns:

A GeoDataFrame containing the geometries and attributes of headwater points.

Return type:

GeoDataFrame

point_junctions(input_file: str, stream_col: str, output_file: str, junction_col: str = 'j_id') GeoDataFrame[source]

Identifies junction points in the stream path and maps stream segment identifiers whose most downstream points coincide with these junction points. Additionally, a new column ‘j_id’ will be added to assign a unique identifier to each junction point, starting from 1.

Parameters:
  • input_file (str) – Path to the input stream shapefile.

  • stream_col (str) – Column name in the stream shapefile containing a unique identifier for each stream segment.

  • output_file (str) – Path to save the output junction point shapefile.

  • junction_col (str, optional) – Name of the column to store the connected downstream segment identifiers. Default is ‘j_id’.

Returns:

A GeoDataFrame of junction points with their corresponding stream segment identifiers.

Return type:

GeoDataFrame

point_main_outlets(input_file: str, output_file: str) GeoDataFrame[source]

Identifies the main outlet points of a stream path and saves the resulting GeoDataFrame to the specified shapefile path.

Parameters:
  • input_file (str) – Path to the input stream shapefile.

  • output_file (str) – Path to save the output outlet point shapefile.

Returns:

A GeoDataFrame containing the main outlet points along with their associated flow segment identifiers.

Return type:

GeoDataFrame

point_segment_subbasin_drainage(input_file: str, output_file: str) GeoDataFrame[source]

Generates a GeoDataFrame of subbasin drainage points for flow segments in the stream path. For each flow segment, the most downstream point is selected unless it is a junction point, in which case the second most downstream point is used.

Parameters:
  • input_file (str) – Path to the input stream shapefile.

  • output_file (str) – Path to save the output pour point shapefile.

Returns:

A GeoDataFrame containing the subbasin drainage points.

Return type:

GeoDataFrame

class GeoAnalyze.Visual[source]

Bases: object

Provides functions to plot of raster and vector data.

quickview_geometry(shape_file: str, column_name: str, figure_file: str, colormap: str = 'terrain', fig_width: float = 6, fig_height: float = 6, fig_title: str = '', log_scale: bool = False, gui_window: bool = True) Figure[source]

Generates a figure for a quick view of a shapefile column.

Parameters:
  • shape_file (str) – Path to the input shapefile.

  • column_name (str) – Name of the column to be plotted.

  • figure_file (str) – Path to the output figure file.

  • colormap (str, optional) – Registered colormap name in the matplotlib Python package. Default is ‘terrain’.

  • fig_width (float, optional) – Width of the figure in inches. Default is 6 inches.

  • fig_height (float, optional) – Height of the figure in inches. Default is 6 inches.

  • fig_title (str, optional) – Title of the figure. Default is an empty string.

  • log_scale (bool, optional) – If True, display the colormap in logarithmic scale. Default is False.

  • gui_window (bool, optional) – If True, open a graphical user interface window of the plot. Default is True.

Returns:

A figure displaying the selected column from the shapefile.

Return type:

Figure

quickview_raster(raster_file: str, figure_file: str, colormap: str = 'terrain', fig_width: float = 6, fig_height: float = 6, fig_title: str = '', log_scale: bool = False, gui_window: bool = True) Figure[source]

Generates a figure for a quick view of a raster array.

Parameters:
  • raster_file (str) – Path to the input raster file.

  • figure_file (str) – Path to the output figure file.

  • colormap (str, optional) – Registered colormap name in the matplotlib Python package. Default is ‘terrain’.

  • fig_width (float, optional) – Width of the figure in inches. Default is 6 inches.

  • fig_height (float, optional) – Height of the figure in inches. Default is 6 inches.

  • fig_title (str, optional) – Title of the figure. Default is an empty string.

  • log_scale (bool, optional) – If True, display the colormap in logarithmic scale. Default is False.

  • gui_window (bool, optional) – If True, open a graphical user interface window of the plot. Default is True.

Returns:

A figure displaying the plot of the input raster array.

Return type:

Figure

class GeoAnalyze.Watershed[source]

Bases: object

Provides functionality for watershed delineation from Digital Elevation Model (DEM).

dem_delineation(dem_file: str, outlet_type: str, tacc_type: str, tacc_value: float, folder_path: str, flw_col: str = 'flw_id') str[source]

Generates delineation raster outputs, including flow direction (flwdir.tif), slope (slope.tif), aspect (aspect.tif), and flow accumulation (flwacc.tif). Using the provided flow accumulation threshold, the function also generates shapefiles for streams (stream_lines.shp), subbasins (subbasins.shp), subbasin drainage points (subbasin_drainage_points.shp), and main outlets (outlet_points.shp). All shapefiles include a common identifier column, flw_col, to facilitate cross-referencing.

The subbasins.shp file contains an additional column, area_m2, which stores the area of each subbasin. The subbasin_drainage_points.shp file contains an additional column, flwacc, which stores the flow accumulation value at the drainage points.

A summary file is created detailing the processing time and other relevant parameters. All outputs are saved to the specified folder.

Parameters:
  • dem_file (str) – Path to the input DEM raster file.

  • outlet_type (str) – Type of outlet from one of [single, multiple]. The ‘single’ option forces all flow directions toward a single outlet at the lowest pit, while ‘multiple’ allows for multiple outlets.

  • tacc_type (str) – Type of threshold for flow accumulation, chosen from [‘percentage’, ‘absolute’]. The ‘percentage’ option uses the percent value of the maximum flow accumulation, while ‘absolute’ specifies a threshold based on a specific number of cells.

  • tacc_value (float) – If ‘percentage’ is selected, this value must be between 0 and 100, representing the percentage of maximum flow accumulation.

  • folder_path (str) – Path to the output folder for saving files.

  • flw_col (str, optional) – Name of the identifier column used in shapefiles to facilitate cross-referencing. Default is ‘flw_id’.

Returns:

A confirmation message that all geoprocessing has been completed.

Return type:

str

dem_extended_area_to_basin(input_file: str, basin_file: str, output_file: str) GeoDataFrame[source]

Computes the basin from an extended DEM area by considering the highest flow accumulation point as the main outlet. Generally, open-source DEMs have a rectangular shape with a geographic Coordinate Reference System (CRS). The DEM must be converted to a projected CRS using the GeoAnalyze.Raster.crs_reprojection() method.

Note

Since the basin is generated without any input outlet point, the main outlet point should be located close to the corresponding edge of the extended DEM area. The greater the distance between the outlet point and the edge of the extended DEM area, the higher the probability of obtaining a larger basin area than expected.

Parameters:
  • input_file (str) – Path to the input DEM raster file.

  • basin_file (str) – Path to save the output basin shapefile.

  • output_file (str) – Path to save the output clipped DEM raster file by the basin area.

Returns:

A GeoDataFrame representing the output basin polygon area.

Return type:

GeoDataFrame

get_aspect(dem_file: str, aspect_file: str) str[source]

Computes the terrain aspect from a DEM without applying pit filling.

Parameters:
  • dem_file (str) – Path to the input DEM raster file (e.g., GeoTIFF).

  • aspect_file (str) – Path to save the output aspect raster file.

Returns:

A message indicating the time required for all geoprocessing computations.

Return type:

str

get_flwacc(flwdir_file: str, flwacc_file: str) str[source]

Computes flow accumulation from flow direction rasters.

Parameters:
  • flwdir_file (str) – Path of the input flow direction raster file.

  • flwacc_file (str) – Path to save the output flow accumulation raster file.

Returns:

A message indicating the time required for all geoprocessing computations.

Return type:

str

get_flwdir(dem_file: str, outlet_type: str, pitfill_file: str, flwdir_file: str) str[source]

Compute flow direction after filling the pits of the DEM.

Parameters:
  • dem_file (str) – Path to the input DEM raster file.

  • outlet_type (str) – Type of outlet from one of [single, multiple]. The ‘single’ option forces all flow directions toward a single outlet at the lowest pit, while ‘multiple’ allows for multiple outlets.

  • pitfill_file (str) – Path to save the output pit-filled DEM raster file.

  • flwdir_file (str) – Path to save the output flow direction raster file.

Returns:

A message indicating the time required for all geoprocessing computations.

Return type:

str

get_slope(dem_file: str, slope_file: str) str[source]

Computes slope from the DEM without pit filling.

Parameters:
  • dem_file (str) – Path to the input DEM raster file.

  • slope_file (str) – Path to save the output slope raster file.

Returns:

A message indicating the time required for all geoprocessing computations.

Return type:

str

get_stream(flwdir_file: str, flwacc_file: str, tacc_type: str, tacc_value: str, stream_file: str, outlet_file: str) str[source]

Generates stream network and main outlet GeoDataFrames from flow direction and accumulation.

Parameters:
  • flwdir_file (str) – Path to the input flow direction raster file.

  • flwacc_file (str) – Path to the input flow accumulation raster file.

  • tacc_type (str) – Type of threshold for flow accumulation, chosen from [‘percentage’, ‘absolute’]. The ‘percentage’ option uses the percent value of the maximum flow accumulation, while ‘absolute’ specifies a threshold based on a specific number of cells.

  • tacc_value (float) – If ‘percentage’ is selected, this value must be between 0 and 100, representing the percentage of maximum flow accumulation.

  • stream_file (str) – Path to save the output stream shapefile.

  • outlet_file (str) – Path to save the output outlet shapefile.

Returns:

A message indicating the time required for all geoprocessing computations.

Return type:

str

get_subbasins(flwdir_file: str, stream_file: str, outlet_file: str, subbasin_file: str, pour_file: str) str[source]

Generates subbasins and their pour points from flow direction, stream and outlets.

Parameters:
  • flwdir_file (str) – Path to the input flow direction raster file.

  • stream_file (str) – Path of the input stream shapefile.

  • outlet_file (str) – Path of the input outlet shapefile.

  • subbasin_file (str) – Path to save the output subbasins shapefile.

  • pour_file (str) – Path to save the output pour points shapefile.

Returns:

A message indicating the time required for all geoprocessing computations.

Return type:

str

slope_classification(slope_file: str, reclass_lb: list[int], reclass_values: list[int], reclass_file: str) str[source]

Multiplies the slope array by 100 and reclassifies the values based on the given intervals.

Parameters:
  • slope_file (str) – Path of the input slope raster file.

  • reclass_lb (list) – List of left bounds of intervals. For example, [0, 2, 5] would be treated as three intervals: [0, 2), [2, 5), and [5, maximum slope).

  • reclass_values (list) – List of reclassified slope values.

  • reclass_file (str) –

    Raster file path to save the output reclassified slope.

    Note

    Recommended classifications for erosion risk:

    Slope Percentage (%)

    Slope Type

    < 2 %

    Flats

    [2 - 8) %

    Gentle

    [8 - 20) %

    Moderate

    [20 - 40) %

    Steep

    >= 40 %

    Very Steep

    Tip

    Recommended for standard classifications:

    Slope Percentage (%)

    Slope Type

    < 5 %

    Flat

    [5 - 15) %

    Gentle

    [15 - 30) %

    Moderate

    [30 - 50) %

    Steep

    [50 - 75) %

    Very Steep

    >= 75 %

    Extremely Steep

Returns:

A message indicating the time required for all geoprocessing computations.

Return type:

str