[GRASS-user] Reading file with with space separators

Markus Metz markus.metz.giswork at gmail.com
Wed Apr 17 03:43:39 PDT 2013


On Wed, Apr 17, 2013 at 10:53 AM, Ralf Schäfer <senator at ecotoxicology.de> wrote:
> Dear all
>
> presumably a trivial question - but what is the argument for space when importing data?
> I have xyz files with the format
> ..x..y...value
> where <.> stands for white space. The spacing is two spaces between x and y and three spaces to data column.

[ rather difficult to produce a file with different kinds of spacing
between columns ]

You could try

cat dgm10_32292_5548_2_rp.xyz | tr -s ' ' >dgm10_32292_5548_2_rp_one_space.xyz
r.in.xyz fs='space', in=dgm10_32292_5548_2_rp_one_space.xyz out=test

Markus M

>
> I used
> r.in.xyz fs='space', in=dgm10_32292_5548_2_rp.xyz out=test
> and obtain:
> ERROR: Bad y-coordinate line 1 column 2. <>
>
> I also tried different options for fs: fs=' ', fs = space, fs = \s (whitespace regular expression) - without success
>
> In R it is no problem - the simple read.table with sep="" for any whitespace works. And with rasterFromXYZ (raster package) I can create a raster without problems.
>
> I guess it is also easy in GRASS but I am just too ignorant :-)
>
> Cheers
> Ralf
>


More information about the grass-user mailing list