Skip to content

michelk/saga-cmd.hs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bindings-saga-cmd: Wrapping saga_cmd to chain GIS-Data conversion

  • Travis: https://travis-ci.org/michelk/bindings-saga-cmd.hs.svg?branch=master
  • Hackage: https://img.shields.io/hackage/v/bindings-saga-cmd.hs.svg?style=flat

Description

Haskell Library to wrap saga_cmd.

Three exectuables are currently shipped

sagaPipe
A program to chain different saga-calls, where the output of one command gets the input of the next.
sagaTopo
Wrapper to create topographic-maps out of sgrid-files

For example

sagaTopo --min 280 --max 360  -o dem.tif dem.sgrd
    
sagaLut
Program to create color lookup-tables with min/max values eg sagaLut 260 280 > colors.txt

This is Work In Progress.

Implemented modules

Command(cmdPar,sagaPar,default)sagaLibsagaModuledefaultSuffix
ascGrdNAio_grid1.sgrd
gdalGridNAio_gdal0.sgrd
gridClassToPoly(all,CLASS_ALL,1):(id,CLASS_ID,1):(split,SPLIT,0)shapes_grid6_polygons.shp
gridClassifyFlat(method,METHOD,0):(new,NEW,1.0):(nodata,RESULT_NODATA_VALUE,-99999.0):(old,OLD,0.0):(table,RETAB,reclassify.txt)grid_tools15_reclassified.sgrd
gridContour(d,ZSTEP,1):(max,ZMAX,10000):(min,ZMIN,0)shapes_grid5_contour.shp
gridEsriAscNAio_grid0.asc
gridFillGapsNAgrid_tools25_filled.sgrd
gridFillGapsSpline(grdFlT,TARGET_DEFINITION,1)grid_spline5_filled.sgrd
gridHillshadeNAta_lighting0_hillshade.sgrd
gridPolyClip(poly,POLYGONS,1)shapes_grid7_polyClip.sgrd
gridSlope(aspect,ASPECT,aspect)ta_morphometry0_slope.sgrd
gridTifGdalNAio_gdal2.tif
gridTifHillshade(colRev,COL_REVERT,1):(max,STRETCH_MAX,1.571):(min,STRETCH_MIN,0):(pal,COL_PALETTE,2)io_grid_image0.tif
gridTifTerrain(col,COLOURING,2):(max,STRETCH_MAX,100):(min,STRETCH_MIN,0):(pal,COL_PALETTE,23)io_grid_image0.tif
gridXyz(header,CAPTION,0):(na,EX_NODATA,1)io_grid5.xyz
lasToPtCldNAio_shapes_las1.spc
polyDissolve(f1,FIELD_1,1):(f2,FIELD_1,-1):(f3,FIELD_1,-1):(method,DISSOLVE,0)shapes_polygons5_disollved.shp
ptCldToGrid(cs,CELLSIZE,1)pointcloud_tools4.sgrd
xyzGridToGrid(cs,CELLSIZE,1):(sep,SEPARATOR,space)io_grid6.sgrd

Installation

Saga And haskell-platform

Linux

sudo aptitude install haskell-platform
sudo aptitude install saga

Windows with Cygwin

  • Get the haskell-platform
  • Install Saga with OSGeo4W
  • Put saga_cmd in the search path; add the line following (the actual filepath could differ) line to your $HOME/.bashrc
    export PATH="$PATH:/cygdrive/c/Program Files (x86)/SAGA-GIS
        

saga-cmd-wrapper library

git clone https://www.github.com/michelk/bindings-saga-cmd.hs.git
cd bindings-saga-cmd.hs
stack install

The exectuables are usually installed into $HOME/.cabal/bin; to use them you have to put them into your search path. Put this into your $HOME/.bashrc:

export PATH="$PATH:$HOME/.local/bin"

sagaPipe

Usage

$HOME/.local/bin/sagaPipe --help

sagaPipe lets you chain saga_cmd commands. The program could be used in two ways. Common for both modes are specification of parameters to use during conversion and the input-file.

Source-Target
Specify a source-format and target-format
Processing-pathway
Specify pathway/route to go exlicitly

The pathways are visualized below

doc/figures/chains.png

Example

Source-Target

sagaPipe \
    --from xyz-grid \
    --to grid-filled-hillshade-tif \
    --parameters sep=tabulator:cs=0.5 \
    -o dem_hillshade.tif \
    dem.xyz

If -o hadn’t been specified, in the directory of the input-file, the follwing grids would have been created:

  • dem_grid.sgrd
  • dem_grid-filled.sgrd
  • dem_grid-filled_hillshade.sgrd

Processing-pathway

The equivalent exlicit version to above is

sagaPipe --chain xyzGridToGrid:gridFillGaps:gridHillshade --parameters sep=tabulator:cs=0.5 dem.xyz

Or for example If you would like to create a hillshade with some buildings removed; invert the buildings-shapefile and do the following

sagaPipe --chain xyzGridToGrid:gridFillGaps:gridHillshade:gridPolyClip:gridTifHillshade  \
         -p poly=BuildingsInv.shp:cs=0.5:sep=tabulator dem.xyz

sagaTopo

Wrapper-program to create topographic maps from sgrd-files

Development

In order to extend functionality, the follwing steps are necessary

  • Find the wanted library and module
    • Eg with ./doc/search
  • Edit src/Math/Geometry/Saga/Data.hs
    • create a SagaCmd (copy & paste an existing one; pretty straigt forward)
    • create a pathway-chain
  • Export README.org

Find the module

cd doc
./search <keyword> 

New SagaCmd

Edit src/Math/Geometry/Saga/Data.hs

  • Add Module
  • Add pathway node

Documentation

  • Edit README.org

ToDo

  • extend library-commands
  • merge sagaTopo into sagaPipe
  • cmd-line-option which color-palette to use (sagaLut)

About

Wrapper for saga-gis

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published