1

I am trying to average geotiff using grass files using r.external and r.series. The geotiffs are georeferenced with wgs84. The command is below.

grass74 g.proj -c proj4="+proj=longlat +datum=WGS84 +no_defs" r.external input="/media/geodev/Seagate Expansion Drive/chlor_a/2017/chlor_a-modis-aqua-01_01_2017-18_30_00.tif" band=1 output=tmp153263774753364 --overwrite -o r.external "/media/geodev/Seagate Expansion Drive/chlor_a/2017/chlor_a-modis-aqua-01_03_2017-19_55_00.tif" band=1 output=tmp153263774753365 --overwrite -o g.region n=31.4648437503 s=17.4068080185 e=-80.4330407378 w=-98.0539218184 res=0.0142218572079 r.series input="tmp153263774753364,tmp153263774753365" method=average range="-10000000000,10000000000" output="output90e1839842f5448890b14b9d0c406f01" --overwrite g.region raster=output90e1839842f5448890b14b9d0c406f01 r.out.gdal --overwrite -c createopt="TFW=YES,COMPRESS=LZW" input=output90e1839842f5448890b14b9d0c406f01 output="/home/geodev/Desktop/ava2ee4.tif"

However, I am getting the error below.

Creating new GRASS GIS location/mapset...
ERROR: ERROR 4: g.proj: No such file or directory
ERROR: Could not read georeferenced file g.proj using either OGR nor GDAL

Exiting...

How could I fix this issue?

  • I don't think you can create GRASS locations from the CLI using proj4 strings. You could do: grass74 -c /path/to/file.tiff. Adapting this to the answer from @markusN it would be: grass74 -c /path/to/file.tif --exec sh yourscript.sh, and yourscript.sh would begin with the r.external command, not the g.proj command. – mankoff Jul 28 '18 at 13:11
  • Will -c /path/to/file.tif represent the output file? – wondim Jul 28 '18 at 13:52
  • I tried to run it in another file but I get the errors access: No such file or directory ERROR: LOCATION </var/www/html/web_map/simplemap/resources/py/<UNKNOWN>> not available ERROR: Path '/media/myuser/Seagate Expansion Drive/chlor_a/2017/chlor_a-modis-aqua-01_01_2017-18_30_00.tif/PERMANENT' doesn't exist – wondim Jul 28 '18 at 18:20
1

The easiest way is to write all these commands to a text file (e.g. "yourscript.sh") and run it using the --exec parameter:

grass74 -c yourgeofile.tif -e /path/to/grassdata/test1/
grass74 /path/to/grassdata/test1/PERMANENT/ --exec sh yourscript.sh

For an example, see also here:

https://grass.osgeo.org/grass74/manuals/grass7.html#batch-jobs-with-the-exec-interface

--> Execution of shell and Python scripts instead of single commands

  • I am trying to automate the above code. I can create a text file programmatically but what should I put in the text file? – wondim Jul 28 '18 at 13:57
  • Your commands from your question above! g.proj ... r.external ... etc – markusN Jul 30 '18 at 9:58
  • I did but I got an error access: No such file or directory ERROR: LOCATION </var/www/html/web_map/simplemap/resources/py/<UNKNOWN>> not available ERROR: Path '/media/myuser/Seagate Expansion Drive/chlor_a/2017/chlor_a-modis-aqua-01_01_2017-18_30_00.tif/PERMANENT' doesn't exist Why is PERMANENT needed when I use external file? – wondim Jul 30 '18 at 12:59
  • PERMANENT is part of the internal file structure of GRASS GIS, it contains the projection information and more. In your case, that's generated and managed automatically. From your report here I cannot see what you tried, though... – markusN Aug 5 '18 at 20:46
  • I used the above commands using the sh file. – wondim Aug 6 '18 at 0:28

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.