[GRASS-user] Importing multiple files with r.in.xyz

Saber Razmjooei razmjooeis at faunalia.co.uk
Tue Aug 10 10:44:45 EDT 2010


Hanile

Try this:

1- Install Paths:
http://www.textpad.com/add-ons/files/utilities/paths.zip
It's a useful tool to copy the path and filenames in windows. It adds a
function to rightclick: Pathcopy. You can select all your rasters and
rightclick to copy the paths:

Paste them in a text file
c:\example\raster1.xyz
c:\example\raster2.xyz 
...

2- change them to something like this (use find/replace..macros, etc:)

r.in.xyz -s -g input="c:\example\raster1.xyz" output=raster1 > tmpRegion
SET /p myregion= < tmpRegion
DEL tmpRegion
g.region %myregion%
r.in.xyz --overwrite input="c:\example\raster1.xyz" output=raster1 fs=,

3- Save that as a import.bat
4- From the Start menu, run Grass in Txt mode, change directory to the
folder where import.bat is
5- import.bat 

If you google around you should be able to make the script a bit smarter
using DOS and loop (http://www.robvanderwoude.com/ntfor.php). 

In linux for example you can shrink it to something like this:



cat list_of_files.txt | while read line; do 
    echo $line+"Being processed" # or whaterver you want to do with the
$line variable
 raster=$line
 r.in.xyz -s -g input=$line output=$line > tmpRegion
myregion= ""`head -n 1 tmpRegion`"
g.region $myregion
r.in.xyz --overwrite input=$line output=$line fs=,
done

and your list_of_files.txt is
raster1
raster2
.....

Hope that helps
Saber



On Tue, 2010-08-10 at 14:59 +0200, Hanlie Pretorius wrote:
> Hi,
> 
> I'm working with WinGRASS 6.4RC6 on Win XP.
> 
> I'm following the steps at http://grass.osgeo.org/wiki/Import_XYZ to
> import hundreds files containing TRMM rainfall data.
> 
> When I try to follow the instruction:
> -----
> Just amend above procedure to use wildcards. Change in above example
> all occurencies of
> 
>  cat VTL2733.XYZ | ...
> 
> to
> 
>  cat *.XYZ | ...
> 
> and use a more reasonable output name of course. That's all to import
> even thousands of files (tiled DEM) easily.
> -----
> 
> Not sure what a 'reasonable output name is', so I run it as shown
> below and get the following error:
> -----
> cat F:\Hanlie\UCT\M.Sc.\Data\TRMM\2000\02_Februrarie\*.txt| r.in.xyz
> -s in=- fs=, out=test
> cat: F:\Hanlie\UCT\M.Sc.\Data\TRMM\2000\02_Februrarie\*.txt: No such
> file or directory
> -----
> 
> If I try it with one file only, it works:
> -----
> cat F:\Hanlie\UCT\M.Sc.\Data\TRMM\2000\02_Februrarie\3B42.000201.0.6.nc.lieb.txt|
> r.in.xyz -s in=- fs=, out=test
> Range:
> x:    -28.625000    -27.375000
> y:     28.125000     28.625000
> z:      0.000000       0.000000
> -----
> 
> How do I get this to work? And how would I get the output filenames to
> be related to the input filenames? For example, if the input filename
> is 3B42.000201.0.6.nc.lieb.txt, then I want the output raster to be
> named '3B42.000201.0.6'.
> 
> Thanks
> Hanlie
> _______________________________________________
> grass-user mailing list
> grass-user at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/grass-user




More information about the grass-user mailing list