[GRASS-user] v.in.ascii don't work

Hamish hamish_nospam at yahoo.com
Wed May 30 05:18:54 EDT 2007


Poizot Emmanuel wrote:
> >>>>> I'm unable to input  text file in GRASS using v.in.ascii.
> >>>>> I'm (trying) working on GRASS 6.2.1 under Ubuntu Fiesty
> >>>>>
> >>>>> I have a text file (test.txt) which containing:
> >>>>> 1|3.5|43.6|2.3
> >>>>> 2|3.55|43.605|1.2
> >>>>> 3|3.51|43.621|-2.3
> >>>>> 4|3.485|43.704|56.1
> >>>>> 5|3.498|43.5|7.1058
> >>>>>
> >>>>> I would like to import it in a new layer with the following
> >>>>> command: cat test.txt | v.in.ascii  out=test columns='nul int,
> >>>>> x double, y double, val double' fs="|" x=2 y=3 z=0
> >>>>>
> >>>>> and the outputs of that command is:
> >>>>>
> >>>>> Maximum input row length: 20
> >>>>> Maximum number of columns: 4
> >>>>> Minimum number of columns: 4
> >>>>> column: 1  type: integer
> >>>>> column: 2  type: double
> >>>>> column: 3  type: double
> >>>>> column: 4  type: double

 ^^^ the scan part worked ok.

> >>>>> Building topology ...
> >>>>> 0 primitives registered     0 areas built     0 isles built
> >>>>> Attaching islands:
> >>>>> Attaching centroids: Topology was built.
> >>>>> Number of nodes     :   0
> >>>>> Number of primitives:   0
> >>>>> Number of points    :   0
> >>>>> Number of lines     :   0
> >>>>> Number of boundaries:   0
> >>>>> Number of centroids :   0
> >>>>> Number of areas     :   0
> >>>>> Number of isles     :   0
> >>>>>
> >>>>> So no points are imported in the layer.
> >>>>> I turn around that problem wich normally should work, as what I
> >>>>> raed everywhere, but not for me !!

certainly it is a well tested module. but a hard thing to make 100% bug
free.


> Michael Barton a écrit :
> > Is the region correct? That is, do these coordinates occur in your
> > region (check extents and resolution using g.region -gp or directly
> > from the menu)?

v.in.ascii only cares about the region if you use the -r flag.
(and that's only in 6.3) The current region and resolution settings are
not used by most vector modules.

> > Are the end of line/carriage return characters correct? You are on a
> > Linux system which ought to produce the correct ones, but it's worth
> > checking.

all UNIX, Mac OS9, and DOS newlines should work without problems these
days. An single space at the end of a line might make an integer column
look like a string column though.


> I found the problem, now it's working.
> I think it was a problem of rights at the group level. I explain:
> I wanted to work on a directory located on a server (Debian).
> I did create without problems the GRASS database and the mapset.
> But using the v.in.ascii command in debug mode, I discovered that
> there  was a problem with a .tmp file which couldn't be deleted.
> I dedided then to move the entire directory on the local machine on 
> which I was running GRASS and then everything becomes ok.

v.in.ascii in.c does this:
    /* Open temporary file */
    tmp = G_tempfile();
    if (NULL == (tmpascii = fopen(tmp, "w+"))) {
	G_fatal_error(_("Can't open temp file %s"), tmp);
    }
    unlink(tmp);
...
[points.c writes then reads from the tmp file]
...
    fclose (tmpascii);
...


why the unlink()?


Hamish




More information about the grass-user mailing list