I'm very new on GRASS and trying to extract the viewshed of a SRTM HGT file.

This is what I've done so far: (why I'm using GRASS command line this way is not in question. Please answer this same way)

grass --exec r.in.srtm -1 --overwrite input=S23W044.hgt

grass --exec g.list type=raster

grass --exec g.region raster=S23W044 -p

grass --exec r.viewshed input=S23W044 output=S23W044-shed coordinates=-43.5,-22.5

But I can't find my output file and don't know it format.

GRASS GIS 7.5.svn

  • To simplify your life you can gather all commands in a single script file, set file permission to "executable" and then run it all with --exec yourscript.sh|bat – markusN Apr 30 '18 at 14:16
  • I will code a Java program to execute these tasks. Thanks anyway. – Magno C May 1 '18 at 2:55

Figured out with

grass --exec r.out.gdal in=S23W044-shed output=elevation.tif createopt="PROFILE=GeoTIFF,TFW=YES"

but it came with no data...don't know if it was because some r.viewshed incorrect parameter.

** EDIT ** : Actualy it don't came empty. The default behaviour of r.viewshed is to produce a 0/1 map being 0=can't see and 1=can see.

I must add the -e parameter to get the elevation value for what I can see and null for what I can't see.

All is working now.

  • You are using GRASS in some non-standard way. Can you explain what is grass --exec? Without understanding this syntax, I don't see how to help. Please first start a normal GRASS session, and run your commands to make sure that all the steps work. – Micha Apr 30 '18 at 11:40
  • By using grass --exec I can execute grass commands without invoke GRASS environment. I need my bash available to do some other tasks. I don't want to work inside a normal grass session. – Magno C May 1 '18 at 2:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.