[GRASS-user] v.in.ascii error: G_realloc

-----Ursprüngliche Nachricht-----
Von: Maciej Sieczka [mailto:tutey@o2.pl]
Gesendet am: Montag, 7. August 2006 13:21
An: Praktikant/in2 ARP
Cc: 'grassuser@grass.itc.it'
Betreff: Re: [GRASS-user] v.in.ascii error: G_realloc

Praktikant/in2 ARP napisa?(a):

I have about 50 tiles with geodetic points. These geodetic points should

be

transformed into a Digital terrain model (DTM) by v.surf.rst.

Can you patch those 50 tiles points outside Grass?

If they are only plain text files, formatted like

x1 y1 z1
x2 y2 z2
x3 y3 z3
...

it will be very easy on Unix:

cat patch49 >> patch50
cat patch48 >> patch50
cat patch47 >> patch50
...

and so forth till they all are in a one file, the "patch50".

Now import that huge patch50 as 3D, not building topology (v.in.ascii -zb).

Set the region *manually* to cover the whole vector patch50 ('g.region
vect=' will not work with topologyless vector as you know, so you must
use 'g.region n= s= e= w= res=' explicitely).

Interpoloate dem out of your 3D points (v.surf.rst layer=0).

Thank you for the help. I've done everything like Maciek suggested. So
everything is working fine until using v.surf.rst.
I have one big vector file in Grass with about 11Million points. But when I
try to interpolate the file
with v.surf.rst the same error occurs:

ERROR: G_realloc: out of memory

Seems that the file is too big for v.surf.rst. 7952735 points are used for
the interpolation an 60521936bytes are used for the temporary files.
v.surf.idw as alternative doesn`t work because of the missing topology.
It is not possible to make the file smaller.

So any suggestions will be very welcome :slight_smile:

Best regards

Michael

If somebody wants a DTM for a defined extract of the area the DTM should

be calculated

exactly for this area. Everything should be automated by a PHP-Script. I
thought about first identifing the needed tiles then patch these tiles

with

v.patch, setting the region to the defined extract (g.region) and as last
point transform the points by v.surf.rst into a DTM.

It will be not optimal at all to interpolate new dem each time a subset
is required. Better interploate full dem only once (as I described
above) and only adjust region settings as needed, for each query your
PHP script gets, with g.region, then use 'r.mapcalc current_subset=dem'
to extract that particular subset from the whole dem. Easier and much
faster.

Best,
Maciek

Praktikant/in2 ARP napisa?(a):

-----Ursprüngliche Nachricht-----
Von: Maciej Sieczka [mailto:tutey@o2.pl]
Gesendet am: Montag, 7. August 2006 13:21
An: Praktikant/in2 ARP
Cc: 'grassuser@grass.itc.it'
Betreff: Re: [GRASS-user] v.in.ascii error: G_realloc

Praktikant/in2 ARP napisa?(a):

I have about 50 tiles with geodetic points. These geodetic points should

be

transformed into a Digital terrain model (DTM) by v.surf.rst.

Can you patch those 50 tiles points outside Grass?

If they are only plain text files, formatted like

x1 y1 z1
x2 y2 z2
x3 y3 z3
...

it will be very easy on Unix:

cat patch49 >> patch50
cat patch48 >> patch50
cat patch47 >> patch50
...

and so forth till they all are in a one file, the "patch50".

Now import that huge patch50 as 3D, not building topology (v.in.ascii -zb).

Set the region *manually* to cover the whole vector patch50 ('g.region
vect=' will not work with topologyless vector as you know, so you must
use 'g.region n= s= e= w= res=' explicitely).

Interpoloate dem out of your 3D points (v.surf.rst layer=0).

Thank you for the help. I've done everything like Maciek suggested. So
everything is working fine until using v.surf.rst.
I have one big vector file in Grass with about 11Million points. But when I
try to interpolate the file
with v.surf.rst the same error occurs:

ERROR: G_realloc: out of memory

I can't help you with v.surf.rst then. But maybe you could try the
nnbathy tool from nn library (if natural neighbor interpolation suits
your needs). It should let you interpolate a huge raster, and requires
only simple x,y,z ASCII input.

1. download nn.tar.gz from http://www.marine.csiro.au/~sakov/
2. tar xzvf nn.tar.gz
3. cd nn
4. ./configure
5. make
6. gcc -o nnbathy nnbathy.c -g -O2 -Wall -pedantic -I. -DNN_SERIAL
libnn.a -lm
7. chmod u+x ./nnbathy

Copy the nnbathy executable to a directory listed in your PATH.

Run it as:

nnbathy -W 0 -P alg=nn -n "$cols"x"$rows" -x "$west" "$east" -y "$north"
"$south" -i your_huge_xyz_input > interpolated_xyz_output

where cols, rows, east etc. are your region settings obtained with
g.region -g.

Now import interpolated_xyz_output directly as a raster with r.in.xyz or
see lines 155-165 of my r.surf.nnbathy (on Grass WIKI) for how to
transform it into Grass ascii raster to be imported with r.in.ascii.

Refer to nnbathy help screen for details.

Let me know if it worked.

Maciek