7

I have a lot of DEMs that I want to use to create hillshades, slopes and color relief from and would like to automate the processes using a shell script within OSgeo4W shell. Here is the code I used within the shell script to automate the creation of hillshades.

for f in *.tif
do
  echo "Processing $f"
gdaldem hillshade $f $f-hillshade" -z 1.0 -s 1.0 -az 315.0 -alt 45.0 -compute_edges -of GTiff
done

I'm new to OSgeo4W and shell scripting. I'm working off this example as a starting point. When I call the shell script within the OSgeo4W I get an error message that Windows can't open the file and then it gives me an option to use the web to find the correct program or to manually select a program to use.

I had assumed that OSgeo4W installed everything I would need to run shell scripts in Windows. What am I missing?

1 Answer 1

7

It turns out that I forgot to type sh before the shell script in the osgeo4w. I also had an extra pair of quotes after hillshade in script. Once I removed the quotes and typed "sh hillshade.sh" into the osgeo4w shell everything worked like a charm. See below for the updated and correct script.

for f in *.tif
do
  echo "Processing $f"
gdaldem hillshade $f $f-hillshade -z 1.0 -s 1.0 -az 315.0 -alt 45.0 -compute_edges -of GTiff
done
2
  • If this answers your question, please mark it as accepted (click grey checkmark below question vote count up/down). Commented Dec 31, 2012 at 0:58
  • 1
    sh files are used in the linux world. The Windows command line equivalent are .bat files. These do not need a sh command to start them.
    – AndreJ
    Commented Jan 27, 2015 at 16:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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