[GRASS-user] help with batch exporting r.out.gdal

Dear All,

I just created a list of files (NPPFILES) using g,mlist command in grass7.

Now I would like to export these files as .tiff files.

I tried this command
for files in $NPPFILES; do
r.out.gdal input=“$NPPFILES” output=“$NPPFILES.tiff” format=GTiff ; done

This is not working for me. I tried giving directory path, still no result.

I will be grateful if anybody can help me with this.

Thanking you,

Regards

Rajat Nayak

Rajat,

I assume you are running this at the GRASS prompt? If not, you must do this. Also, if you don’t provide the full path for ‘NPPFILES’, you should run the command from the directory where ‘NPPFILES’ is located. Additionally, you may want to change your code to this:

for files in $(cat NPPFILES); do
echo $files;
r.out.gdal input=“$NPPFILES” output=“$NPPFILES.tiff” format=GTiff ; done

You may want to include the line “echo $files;” to see if the individual map names are being read correctly

Regards,

Tom

···

On Tue, Sep 2, 2014 at 8:57 AM, Rajat Nayak <rajat27404@gmail.com> wrote:

Dear All,

I just created a list of files (NPPFILES) using g,mlist command in grass7.

Now I would like to export these files as .tiff files.

I tried this command
for files in $NPPFILES; do
r.out.gdal input=“$NPPFILES” output=“$NPPFILES.tiff” format=GTiff ; done

This is not working for me. I tried giving directory path, still no result.

I will be grateful if anybody can help me with this.

Thanking you,

Regards

Rajat Nayak


grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user

Thank you Tom for the mail.

I’m still unable to get it working. Some smaller cliche I guess,

will try again.

Regards

···

Rajat Nayak

On Tue, Sep 2, 2014 at 6:50 PM, Thomas Adams <tea3rd@gmail.com> wrote:

Rajat,

I assume you are running this at the GRASS prompt? If not, you must do this. Also, if you don’t provide the full path for ‘NPPFILES’, you should run the command from the directory where ‘NPPFILES’ is located. Additionally, you may want to change your code to this:

for files in $(cat NPPFILES); do
echo $files;

r.out.gdal input=“$NPPFILES” output=“$NPPFILES.tiff” format=GTiff ; done

You may want to include the line “echo $files;” to see if the individual map names are being read correctly

Regards,

Tom

On Tue, Sep 2, 2014 at 8:57 AM, Rajat Nayak <rajat27404@gmail.com> wrote:

Dear All,

I just created a list of files (NPPFILES) using g,mlist command in grass7.

Now I would like to export these files as .tiff files.

I tried this command
for files in $NPPFILES; do
r.out.gdal input=“$NPPFILES” output=“$NPPFILES.tiff” format=GTiff ; done

This is not working for me. I tried giving directory path, still no result.

I will be grateful if anybody can help me with this.

Thanking you,

Regards

Rajat Nayak


grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user

Rajat Nayak <rajat27404@gmail.com> wrote:

>> I just created a list of files (NPPFILES) using g,mlist command in
>> grass7. Now I would like to export these files as .tiff files.
>> I tried this command

>> for files in $NPPFILES; do
>> r.out.gdal input="$NPPFILES" output="$NPPFILES.tiff" format=GTiff ; done

Here, you ask the string "files" to get each of the whatsoever values
are stored inside the variable $NPPFILES.

1. is there an NPPFILES variable defined already? Something like

NPPFILES="
file_1
file_2
flie_3"

2. What you actually need to feed the "input=" parameter, is the "files"
term, not the "$NPPFILES".

>> This is not working for me. I tried giving directory path, still no
>> result.

ok, assuming you are running this from inside a GRASSy session, you
should be, at the time of executing the for loop, inside the directory
where the "list of files" is also present. I guess you created a file,
say "nppfiles_list".

To be sure, just instruct

cat nppfiles_list

and expect to get the list of files you created.

If that's ok, then it should work, e.g.:

for File in `cat nppfiles_list`; do r.out.gdal input=${File}
output=${File}.tiff; done

Note, instead of "File" it could be any other string you like.

Hope this helps a bit.

Nikos

Thank you Nikos and Tom.

The command worked.
This is what I used,
for files in cat NPPFILES; do r.out.gdal in=“${files}” out=“${files}” format=“GTiff”; done

Regards

···

Rajat Nayak

On Thu, Sep 4, 2014 at 12:39 PM, Nikos Alexandris <nik@nikosalexandris.net> wrote:

Rajat Nayak <rajat27404@gmail.com> wrote:

I just created a list of files (NPPFILES) using g,mlist command in
grass7. Now I would like to export these files as .tiff files.
I tried this command

for files in $NPPFILES; do
r.out.gdal input=“$NPPFILES” output=“$NPPFILES.tiff” format=GTiff ; done

Here, you ask the string “files” to get each of the whatsoever values
are stored inside the variable $NPPFILES.

  1. is there an NPPFILES variable defined already? Something like

NPPFILES="
file_1
file_2
flie_3"

  1. What you actually need to feed the “input=” parameter, is the “files”
    term, not the “$NPPFILES”.

This is not working for me. I tried giving directory path, still no
result.

ok, assuming you are running this from inside a GRASSy session, you
should be, at the time of executing the for loop, inside the directory
where the “list of files” is also present. I guess you created a file,
say “nppfiles_list”.

To be sure, just instruct

cat nppfiles_list

and expect to get the list of files you created.

If that’s ok, then it should work, e.g.:

for File in cat nppfiles_list; do r.out.gdal input=${File}
output=${File}.tiff; done

Note, instead of “File” it could be any other string you like.

Hope this helps a bit.

Nikos