Skip to main content

A package that allows you to run SAGA GIS tools in a Python environment.

Project description

PySAGA-cmd

PySAGA-cmd allows the usage of SAGA GIS tools in a Python environment.

Table of Contents

How to download

Binary installers for the latest released version are available at the Python Package Index (PyPI).

pip install PySAGA-cmd

How to use the package

For information on how to use the package, check the docstrings or look at the notebook examples.

Choosing a SAGA GIS tool

from PySAGA_cmd import (
    SAGA,
    Library,
    Tool
)
# Defining saga_cmd location
saga_cmd = '/usr/local/bin/saga_cmd'

# Instantiating a SAGA environment
saga_env = SAGA(command=saga_cmd)
print(saga_env)
____________________________

   #####   ##   #####    ##
  ###     ###  ##       ###
   ###   # ## ##  #### # ##
    ### ##### ##    # #####
 ##### #   ##  ##### #   ##
____________________________

SAGA Version: 9.3.0


88 loaded tool libraries (765 tools):
 - climate_tools
 - contrib_perego
 - db_odbc
 - db_pgsql
 - dev_tools
 - docs_html
 - garden_fractals
 - garden_webservices
 - grid_analysis
 - grid_calculus
 - grid_calculus_bsl
 - grid_filter
 - grid_gridding
 - grid_spline
 - grid_tools
 - grid_visualisation
 - grids_tools
 - imagery_classification
 - imagery_isocluster
 - imagery_maxent
 - imagery_photogrammetry
 - imagery_segmentation
 - imagery_svm
 - imagery_tools
 - io_esri_e00
 - io_gdal
 - io_gps
 - io_grid
 - io_grid_image
 - io_pdal
 - io_shapes
 - io_table
 - io_virtual
 - io_webservices
 - pj_georeference
 - pj_geotrans
 - pj_proj4
 - pointcloud_tools
 - shapes_grid
 - shapes_lines
 - shapes_points
 - shapes_polygons
 - shapes_tools
 - shapes_transect
 - sim_air_flow
 - sim_cellular_automata
 - sim_ecosystems_hugget
 - sim_erosion
 - sim_fire_spreading
 - sim_geomorphology
 - sim_hydrology
 - sim_ihacres
 - sim_landscape_evolution
 - sim_qm_of_esp
 - sim_rivflow
 - statistics_grid
 - statistics_kriging
 - statistics_points
 - statistics_regression
 - ta_channels
 - ta_cliffmetrics
 - ta_compound
 - ta_hydrology
 - ta_lighting
 - ta_morphometry
 - ta_preprocessor
 - ta_profiles
 - ta_slope_stability
 - table_calculus
 - table_tools
 - tin_tools
 - vis_3d_viewer
 - _tool_chains_uncategorized *
 - climate_tools *
 - grid_filter *
 - grid_tools *
 - grids_tools *
 - imagery_classification *
 - imagery_segmentation *
 - io_table *
 - shapes_grid *
 - shapes_points *
 - shapes_polygons *
 - shapes_tools *
 - statistics_grid *
 - ta_hydrology *
 - ta_morphometry *
 - tta_tools *


*) tool chain libraries



type -h or --help for further information
# Choosing a library
saga_library = saga_env.get_library(library='ta_morphometry')
print(saga_library)
____________________________

   #####   ##   #####    ##
  ###     ###  ##       ###
   ###   # ## ##  #### # ##
    ### ##### ##    # #####
 ##### #   ##  ##### #   ##
____________________________

SAGA Version: 9.3.0


Library    : Morphometry
Category   : Terrain Analysis
File       : /usr/local/lib/saga/libta_morphometry.so
Description: Tools for (grid based) digital terrain analysis.

Tools:
 [0]	Slope, Aspect, Curvature
 [1]	Convergence Index
 [2]	Convergence Index (Search Radius)
 [3]	Surface Specific Points
 [4]	Curvature Classification
 [5]	Hypsometry
 [6]	Real Surface Area
 [7]	Morphometric Protection Index
 [8]	Multiresolution Index of Valley Bottom Flatness (MRVBF)
 [9]	Downslope Distance Gradient
 [10]	Mass Balance Index
 [11]	Effective Air Flow Heights
 [12]	Diurnal Anisotropic Heat
 [13]	Land Surface Temperature (Lapse Rates)
 [14]	Relative Heights and Slope Positions
 [15]	Wind Effect (Windward / Leeward Index)
 [16]	Terrain Ruggedness Index (TRI)
 [17]	Vector Ruggedness Measure (VRM)
 [18]	Topographic Position Index (TPI)
 [19]	TPI Based Landform Classification
 [20]	Terrain Surface Texture
 [21]	Terrain Surface Convexity
 [22]	Terrain Surface Classification (Iwahashi and Pike)
 [23]	Morphometric Features
 [24]	Valley and Ridge Detection (Top Hat Approach)
 [25]	Fuzzy Landform Element Classification
 [26]	Upslope and Downslope Curvature
 [27]	Wind Exposition Index
 [28]	Multi-Scale Topographic Position Index (TPI)
 [29]	Wind Shelter Index


Tool Chains: Geomorphometry
Description: Tools for morphometric terrain analysis.

Tools:
 [clustering]	Terrain Clustering
 [summits]	Summit Extraction
 [segmentation]	Terrain Segmentation



type -h or --help for further information
# Choosing a tool
saga_tool = saga_library.get_tool(tool='0')
print(saga_tool)
____________________________

   #####   ##   #####    ##
  ###     ###  ##       ###
   ###   # ## ##  #### # ##
    ### ##### ##    # #####
 ##### #   ##  ##### #   ##
____________________________

SAGA Version: 9.3.0

____________________________
library path: /usr/local/lib/saga/
library path: /usr/local/lib/saga/
library name: libta_morphometry
library     : ta_morphometry
tool        : Slope, Aspect, Curvature
identifier  : 0
author      : O.Conrad (c) 2001
processors  : 4 [4]
____________________________


Usage: saga_cmd ta_morphometry 0 [-ELEVATION <str>] [-SLOPE <str>] [-ASPECT <str>] [-C_GENE <str>] [-C_PROF <str>] [-C_PLAN <str>] [-C_TANG <str>] [-C_LONG <str>] [-C_CROS <str>] [-C_MINI <str>] [-C_MAXI <str>] [-C_TOTA <str>] [-C_ROTO <str>] [-METHOD <str>] [-UNIT_SLOPE <str>] [-UNIT_ASPECT <str>]
  -ELEVATION:<str>  	Elevation
	grid, input
  -SLOPE:<str>      	Slope
	grid, output
  -ASPECT:<str>     	Aspect
	grid, output
  -C_GENE:<str>     	General Curvature
	grid, output, optional
  -C_PROF:<str>     	Profile Curvature
	grid, output, optional
  -C_PLAN:<str>     	Plan Curvature
	grid, output, optional
  -C_TANG:<str>     	Tangential Curvature
	grid, output, optional
  -C_LONG:<str>     	Longitudinal Curvature
	grid, output, optional
  -C_CROS:<str>     	Cross-Sectional Curvature
	grid, output, optional
  -C_MINI:<str>     	Minimal Curvature
	grid, output, optional
  -C_MAXI:<str>     	Maximal Curvature
	grid, output, optional
  -C_TOTA:<str>     	Total Curvature
	grid, output, optional
  -C_ROTO:<str>     	Flow Line Curvature
	grid, output, optional
  -METHOD:<str>     	Method
	choice
	Available Choices:
	[0] maximum slope (Travis et al. 1975)
	[1] maximum triangle slope (Tarboton 1997)
	[2] least squares fitted plane (Horn 1981, Costa-Cabral & Burgess 1996)
	[3] 6 parameter 2nd order polynom (Evans 1979)
	[4] 6 parameter 2nd order polynom (Heerdegen & Beran 1982)
	[5] 6 parameter 2nd order polynom (Bauer, Rohdenburg, Bork 1985)
	[6] 9 parameter 2nd order polynom (Zevenbergen & Thorne 1987)
	[7] 10 parameter 3rd order polynom (Haralick 1983)
	[8] 10 parameter 3rd order polynom (Florinsky 2009)
	Default: 6
  -UNIT_SLOPE:<str> 	Unit
	choice
	Available Choices:
	[0] radians
	[1] degree
	[2] percent rise
	Default: 0
  -UNIT_ASPECT:<str>	Unit
	choice
	Available Choices:
	[0] radians
	[1] degree
	Default: 0
# Using a 'help' flag
saga_tool.flag = 'help'
print(saga_tool)
saga_tool.remove_flag()
____________________________

   #####   ##   #####    ##
  ###     ###  ##       ###
   ###   # ## ##  #### # ##
    ### ##### ##    # #####
 ##### #   ##  ##### #   ##
____________________________

SAGA Version: 9.3.0

____________________________
library path: /usr/local/lib/saga/
library path: /usr/local/lib/saga/
library name: libta_morphometry
library     : ta_morphometry
tool        : Slope, Aspect, Curvature
identifier  : 0
author      : O.Conrad (c) 2001
processors  : 4 [4]
____________________________

Name:	Slope, Aspect, Curvature
ID:	0
Author:	O.Conrad (c) 2001
Version:	1.0
Specification:	grid

____________________________
Description:
Calculates the local morphometric terrain parameters slope, aspect and if supported by the chosen method also the curvature. Besides tangential curvature also its horizontal and vertical components (i.e. plan and profile curvature) can be calculated.
____________________________

References:
 - Bauer, J., Rohdenburg, H., Bork, H.-R. (1985): Ein Digitales Reliefmodell als Vorraussetzung fuer ein deterministisches Modell der Wasser- und Stoff-Fluesse. In: Bork, H.-R., Rohdenburg, H. [Eds.]: Parameteraufbereitung fuer deterministische Gebietswassermodelle, Grundlagenarbeiten zur Analyse von Agrar-Oekosystemen, Landschaftsgenese und Landschaftsoekologie, H.10, p.1-15.
 - Beasley, D.B., Huggins, L.F. (1982): ANSWERS: User's manual. U.S. EPA-905/9-82-001, Chicago, IL. 54pp.
 - Costa-Cabral, M., Burges, S.J. (1994): Digital Elevation Model Networks (DEMON): a model of flow over hillslopes for computation of contributing and dispersal areas. Water Resources Research, v. 30, no. 6, p.1681-1692. https://doi.org/10.1029/93WR03512 (doi:10.1029/93WR03512).
 - Evans, I.S. (1979): An integrated system of terrain analysis and slope mapping. Final report on grant DA-ERO-591-73-G0040, University of Durham, England.
 - Florinsky, I.V. (2009): Computation of the third?order partial derivatives from a digital elevation model. International Journal of Geographical Information Science, 23(2), p.213-231. https://doi.org/10.1080/13658810802527499 (doi:10.1080/13658810802527499).
 - Haralick, R.M. (1983): Ridge and valley detection on digital images. Computer Vision, Graphics and Image Processing, Vol.22, No.1, p.28-38.https://doi.org/10.1016/0734-189X(83)90094-4 doi:10.1016/0734-189X(83)90094-4 (doi:10.1016/0734-189X(83)90094-4).
 - Heerdegen, R.G., Beran, M.A. (1982): Quantifying source areas through land surface curvature. Journal of Hydrology, Vol.57. https://doi.org/10.1016/0022-1694(82)90155-X (doi:10.1016/0022-1694(82)90155-X).
 - Horn, B. K. (1981): Hill shading and the relectance map. Proceedings of the IEEE, v. 69, no. 1, p.14-47. https://doi.org/10.1109/PROC.1981.11918 (doi:10.1109/PROC.1981.11918).
 - Olaya, V. (2006): Basic Land-Surface Parameters. In: Hengl, T., Reuter, H.I. [Eds.]: Geomorphometry: Concepts, Software, Applications. Developments in Soil Science, Elsevier, Vol.33, 141-169. https://doi.org/10.1016/S0166-2481(08)00006-8 (doi:10.1016/S0166-2481(08)00006-8).
 - Tarboton, D.G. (1997): A new method for the determination of flow directions and upslope areas in grid digital elevation models. Water Resources Research, Vol.33, No.2, p.309-319.
 - Travis, M.R., Elsner, G.H., Iverson, W.D., Johnson, C.G. (1975): VIEWIT: computation of seen areas, slope, and aspect for land-use planning. USDA F.S. Gen. Tech. Rep. PSW-11/1975, 70p. Berkeley, California, U.S.A.
 - Zevenbergen, L.W., Thorne, C.R. (1987): Quantitative analysis of land surface topography. Earth Surface Processes and Landforms, 12: 47-56. https://doi.org/10.1002/esp.3290120107 (doi:10.1002/esp.3290120107).

____________________________
Input:
_
Elevation
ELEVATION
grid, input


____________________________
Output:
_
Slope
SLOPE
grid, output


_
Aspect
ASPECT
grid, output


_
General Curvature
C_GENE
grid, output, optional


_
Profile Curvature
C_PROF
grid, output, optional


_
Plan Curvature
C_PLAN
grid, output, optional


_
Tangential Curvature
C_TANG
grid, output, optional


_
Longitudinal Curvature
C_LONG
grid, output, optional
Zevenbergen & Thorne (1987) refer to this as profile curvature

_
Cross-Sectional Curvature
C_CROS
grid, output, optional
Zevenbergen & Thorne (1987) refer to this as plan curvature

_
Minimal Curvature
C_MINI
grid, output, optional


_
Maximal Curvature
C_MAXI
grid, output, optional


_
Total Curvature
C_TOTA
grid, output, optional


_
Flow Line Curvature
C_ROTO
grid, output, optional


____________________________
Options:
_
Method
METHOD
choice

Available Choices:
[0] maximum slope (Travis et al. 1975)
[1] maximum triangle slope (Tarboton 1997)
[2] least squares fitted plane (Horn 1981, Costa-Cabral & Burgess 1996)
[3] 6 parameter 2nd order polynom (Evans 1979)
[4] 6 parameter 2nd order polynom (Heerdegen & Beran 1982)
[5] 6 parameter 2nd order polynom (Bauer, Rohdenburg, Bork 1985)
[6] 9 parameter 2nd order polynom (Zevenbergen & Thorne 1987)
[7] 10 parameter 3rd order polynom (Haralick 1983)
[8] 10 parameter 3rd order polynom (Florinsky 2009)
Default: 6
_
Unit
UNIT_SLOPE
choice

Available Choices:
[0] radians
[1] degree
[2] percent rise
Default: 0
_
Unit
UNIT_ASPECT
choice

Available Choices:
[0] radians
[1] degree
Default: 0

Running a SAGA GIS tool

from PySAGA_cmd import (
    SAGA,
    Library,
    Tool
)
# Defining saga_cmd location
saga_cmd = '/usr/local/bin/saga_cmd'

# Instantiating a SAGA environment
saga_env = SAGA(command=saga_cmd)

# Choosing a library
saga_library = saga_env.get_library(library='ta_morphometry')

# Choosing a tool
saga_tool = saga_library.get_tool(tool='0')

print(saga_tool)
____________________________

   #####   ##   #####    ##
  ###     ###  ##       ###
   ###   # ## ##  #### # ##
    ### ##### ##    # #####
 ##### #   ##  ##### #   ##
____________________________

SAGA Version: 9.3.0

____________________________
library path: /usr/local/lib/saga/
library path: /usr/local/lib/saga/
library name: libta_morphometry
library     : ta_morphometry
tool        : Slope, Aspect, Curvature
identifier  : 0
author      : O.Conrad (c) 2001
processors  : 4 [4]
____________________________


Usage: saga_cmd ta_morphometry 0 [-ELEVATION <str>] [-SLOPE <str>] [-ASPECT <str>] [-C_GENE <str>] [-C_PROF <str>] [-C_PLAN <str>] [-C_TANG <str>] [-C_LONG <str>] [-C_CROS <str>] [-C_MINI <str>] [-C_MAXI <str>] [-C_TOTA <str>] [-C_ROTO <str>] [-METHOD <str>] [-UNIT_SLOPE <str>] [-UNIT_ASPECT <str>]
  -ELEVATION:<str>  	Elevation
	grid, input
  -SLOPE:<str>      	Slope
	grid, output
  -ASPECT:<str>     	Aspect
	grid, output
  -C_GENE:<str>     	General Curvature
	grid, output, optional
  -C_PROF:<str>     	Profile Curvature
	grid, output, optional
  -C_PLAN:<str>     	Plan Curvature
	grid, output, optional
  -C_TANG:<str>     	Tangential Curvature
	grid, output, optional
  -C_LONG:<str>     	Longitudinal Curvature
	grid, output, optional
  -C_CROS:<str>     	Cross-Sectional Curvature
	grid, output, optional
  -C_MINI:<str>     	Minimal Curvature
	grid, output, optional
  -C_MAXI:<str>     	Maximal Curvature
	grid, output, optional
  -C_TOTA:<str>     	Total Curvature
	grid, output, optional
  -C_ROTO:<str>     	Flow Line Curvature
	grid, output, optional
  -METHOD:<str>     	Method
	choice
	Available Choices:
	[0] maximum slope (Travis et al. 1975)
	[1] maximum triangle slope (Tarboton 1997)
	[2] least squares fitted plane (Horn 1981, Costa-Cabral & Burgess 1996)
	[3] 6 parameter 2nd order polynom (Evans 1979)
	[4] 6 parameter 2nd order polynom (Heerdegen & Beran 1982)
	[5] 6 parameter 2nd order polynom (Bauer, Rohdenburg, Bork 1985)
	[6] 9 parameter 2nd order polynom (Zevenbergen & Thorne 1987)
	[7] 10 parameter 3rd order polynom (Haralick 1983)
	[8] 10 parameter 3rd order polynom (Florinsky 2009)
	Default: 6
  -UNIT_SLOPE:<str> 	Unit
	choice
	Available Choices:
	[0] radians
	[1] degree
	[2] percent rise
	Default: 0
  -UNIT_ASPECT:<str>	Unit
	choice
	Available Choices:
	[0] radians
	[1] degree
	Default: 0
dem_dir = '../data/example_input/DEM_30m.tif'

output_dir = '../data/example_output/'
slope_dir = output_dir + 'SLOPE_30m.tif'
aspect_dir = output_dir + 'ASPECT_30m.tif'
c_gene_dir = output_dir + 'C_GENE_30m.tif'
c_prof_dir = output_dir + 'C_PROF_30m.tif'
c_plan_dir = output_dir + 'C_PLAN_30m.tif'
c_tang_dir = output_dir + 'C_TANG_30m.tif'
c_long_dir = output_dir + 'C_LONG_30m.tif'
c_cros_dir = output_dir + 'C_CROS_30m.tif'
c_mini_dir = output_dir + 'C_MINI_30m.tif'
c_maxi_dir = output_dir + 'C_MAXI_30m.tif'
c_tota_dir = output_dir + 'C_TOTA_30m.tif'
c_roto_dir = output_dir + 'C_ROTO_30m.tif'

output = saga_tool.run_command(
    elevation=dem_dir,
    slope=slope_dir,
    aspect=aspect_dir,
    c_gene=c_gene_dir,
    c_prof=c_prof_dir,
    c_plan=c_plan_dir,
    c_tang=c_tang_dir,
    c_long=c_long_dir,
    c_cros=c_cros_dir,
    c_mini=c_mini_dir,
    c_maxi=c_maxi_dir,
    c_tota=c_tota_dir,
    c_roto=c_roto_dir,
    method='6',
    unit_slope='1',
    unit_aspect='1'
)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

PySAGA-cmd-0.0.4.tar.gz (11.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

PySAGA_cmd-0.0.4-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file PySAGA-cmd-0.0.4.tar.gz.

File metadata

  • Download URL: PySAGA-cmd-0.0.4.tar.gz
  • Upload date:
  • Size: 11.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.12

File hashes

Hashes for PySAGA-cmd-0.0.4.tar.gz
Algorithm Hash digest
SHA256 b7a29510c3c03f4fb1ea26de52eee0c32be2c0d38b673676e58e8aeda4d1b3d0
MD5 5eeecc72543758ca896caf4e4268714d
BLAKE2b-256 e2a2e45f0fd157958eb0ae4e5509ef97cae3a13b5f518c9545b6bdd232d5beec

See more details on using hashes here.

File details

Details for the file PySAGA_cmd-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: PySAGA_cmd-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 8.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.12

File hashes

Hashes for PySAGA_cmd-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 6f37a006c715974af951abae1ee98f9cca599d7c12d67cedfc2b39de4b46cce1
MD5 fd66f71854757b83ff169ed6981c70a2
BLAKE2b-256 b89167c33570c28036f853ef0254b9570811d1b80f7a92471a7550be7328adb7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page