TransWikia.com

eval and cats is not recognized as an internal or external command, operable program or batch file in GRASS GIS

Geographic Information Systems Asked on November 26, 2021

I’m trying to do the r.lfp and r.accumulate examples for multiple longest flow paths, except I keep getting the "eval" or "cats" "is not recognized as an internal or external command, operable program or batch file.". Not sure what I’m doing wrong, not used to working with GRASS I usually work on QGIS I just didn’t find a way do get lfp from QGIS. Using GRASS on windows.

Here are the two codes I’m trying to put in GRASS:

For r.lfp:

# get nsres
eval `r.info -g map=elevation`

# delineate streams using a threshold
r.stream.extract elevation=elevation threshold=50000 stream_vector=streams

# populate stream lengths
v.db.addcolumn map=streams columns="length real"
v.to.db map=streams option=length columns=length

# create points along the streams starting from downstream
v.to.points -r input=streams output=stream_points dmax=$nsres

# find outlets (downstream-most less nsres points)
cats=`db.select -c sql="select stream_points_2.cat from stream_points_2 
    inner join stream_points_1 on stream_points_1.cat = stream_points_2.lcat 
    where length-along > 0.5*$nsres and length-along < 1.5*$nsres"`
cats=`echo $cats | tr " " ,`
v.extract input=stream_points layer=2 cats=$cats output=stream_outlets

# create the longest flow paths for all outlets
r.lfp input=drain_directions output=lfp id_column=id outlet=stream_outlets layer=2 outlet_id_column=lcat

And this one for r.accumulate:

# set computational region
g.region raster=elevation -p

# calculate drainage directions using r.watershed
r.watershed elevation=elevation drainage=drain_directions -s -a

# get nsres
eval `r.info -g map=elevation`

# delineate streams using a threshold
r.accumulate direction=drain_directions threshold=50000 stream=streams

# populate stream lengths
v.db.addtable map=streams
v.to.db map=streams option=length columns=length

# create points along the streams starting from downstream
v.to.points -r input=streams output=stream_points dmax=$nsres

# find outlets (downstream-most less nsres points)
cats=`db.select -c sql="select stream_points_2.cat from stream_points_2 
    inner join stream_points_1 on stream_points_1.cat = stream_points_2.lcat 
    where length-along > 0.5*$nsres and length-along < 1.5*$nsres"`
cats=`echo $cats | tr " " ,`
v.extract input=stream_points layer=2 cats=$cats output=stream_outlets

# calculate longest flow paths and delineate subwatersheds for all outlets
r.accumulate direction=drain_directions lfp=lfp id_column=id 
    outlet=stream_outlets outlet_layer=2 outlet_id_column=lcat 
    subwatershed=subwatersheds

# convert subwatersheds to vector
r.to.vect input=subwatersheds type=area output=subwatersheds

Not sure what I’m missing. Trying to execute this code from the GRASS Console tab maybe I need to do it from somewhere else?

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP