[GRASS-user] points to lines

Hi,

I have to admit that I am an absolute beginner in GRASS.

I need to import vector data from a text-file with this format:
x-begin,y-begin,x-end,y-end

Any suggestion?

I recall such an extension for Arcview, points2lines, I think.

Does anybody have developed something like this?

Thanks in advance.



<br>-- <br>Jorge Echeverri, BSc Civ. Eng.<br>S & P CONSULT GMBH<br>Technologiequartier<br>Konrad-Zuse-Str. 6<br>D-44801 Bochum, Germany<br>Geschäftsführer: Dipl.-Ing. Robert Stein<br>Registergericht: Amtsgericht Bochum HRB 10769<br><br><br>Phone: +49(0) 234 51 67 193<br>Fax: +49(0) 234 51 67 109<br><br>Email: [jorge.echeverri@stein.de](mailto:jorge.echeverri@stein.de)<br>Internet: [www.stein.de](http://www.stein.de)<br><br>

Jorge Echeverri wrote:

I need to import vector data from a text-file with this format:
x-begin,y-begin,x-end,y-end

v.in.ascii -n format=standard

the format is like:

L 2
x1-begin y1-begin
x1-end y1-end
L 2
x2-begin y2-begin
x2-end y2-end

...
(L for line, 2 for 2 vertices in the line)

see the help page.

Hamish

On 08/03/07 18:00, Jorge Echeverri wrote:

Hi,

I have to admit that I am an absolute beginner in GRASS.

I need to import vector data from a text-file with this format:
x-begin,y-begin,x-end,y-end

Any suggestion?

v.in.ascii

You will have to transform your data (e.g. with awk) to fit the standard format. Something like this (untested) should work:

awk -F"," 'BEGIN{i=0} {i++;print "L 2 1";print $1,$2,i;i++;print $3,$4,i;print "1"}' YourFile | v.in.ascii -n format=standard out=YourMapName fs=" "

See the v.in.ascii man page for details.

Moritz

Thanks for your comments.

I rewrote my file like this:
“X_COORDINATE”,“Y_COORDINATE”
L 2 1
3400630.04 5718486.603
3400639.238 5718515.776
1 1
L 2 1
3400639.238 5718515.776
3400648.641 5718546.057
1 2
L 2 1
3400648.641 5718546.057
3400665.041 5718562.99
1 3
L 2 1
3400665.041 5718562.99
3400625.996 5718597.349
1 4

Then I perform the import:

GRASS 6.2.1 (luenenxy):~ > v.in.ascii input=/home/jorge/GrassGIS/luenenxy/jorge/koord1.csv out=koord_grass format=standard --overwrite skip=1 cat=0 fs=‘space’
WARNUNG: Die Vektorkarte ‘koord_grass’ existiert bereits und wird
überschrieben.
Error reading ascii file:

Erzeuge Topologie …
4 primitives registriert
Building areas: 100%
0 Flächen erstellt
0 Inselflächen erstellt
Füge Inselflächen hinzu:
Füge Zentroide hinzu: 100%
Die Topologie wurde erstellt.
Anzahl von Knoten : 5
Anzahl von Primitives : 4
Anzahl von Punkten : 0
Anzahl von Linien : 4
Anzahl von Boundaries : 0
Anzahl von Zentroiden : 0
Anzahl von Flächen : 0
Anzahl von Inseln : 0
GRASS 6.2.1 (luenenxy):~ >

It seems to recognise the entities in the file but what does this error message means ???

Error reading ascii file:
???

Thanks in advace,

Jorge

Am Donnerstag, den 08.03.2007, 23:17 +0100 schrieb Moritz Lennert:

On 08/03/07 18:00, Jorge Echeverri wrote:
> Hi,
> 
> I have to admit that I am an absolute beginner in GRASS.
> 
> I need to import vector data from a text-file with this format:
> x-begin,y-begin,x-end,y-end
> 
> Any suggestion?

v.in.ascii

You will have to transform your data (e.g. with awk) to fit the standard 
format. Something like this (untested) should work:

awk -F"," 'BEGIN{i=0} {i++;print "L 2 1";print $1,$2,i;i++;print 
$3,$4,i;print "1"}' YourFile | v.in.ascii -n format=standard 
out=YourMapName fs=" "

See the v.in.ascii man page for details.

Moritz



<br>-- <br>Jorge Echeverri, BSc Civ. Eng.<br>S & P CONSULT GMBH<br>Technologiequartier<br>Konrad-Zuse-Str. 6<br>D-44801 Bochum, Germany<br>Geschäftsführer: Dipl.-Ing. Robert Stein<br>Registergericht: Amtsgericht Bochum HRB 10769<br><br><br>Phone: +49(0) 234 51 67 193<br>Fax: +49(0) 234 51 67 109<br><br>Email: [jorge.echeverri@stein.de](mailto:jorge.echeverri@stein.de)<br>Internet: [www.stein.de](http://www.stein.de)<br><br>

Jorge Echeverri wrote:

Thanks for your comments.

I rewrote my file like this:
"X_COORDINATE","Y_COORDINATE"
L 2 1
3400630.04 5718486.603
3400639.238 5718515.776
1 1
L 2 1
3400639.238 5718515.776
3400648.641 5718546.057
1 2
L 2 1
3400648.641 5718546.057
3400665.041 5718562.99
1 3
L 2 1
3400665.041 5718562.99
3400625.996 5718597.349
1 4

Then I perform the import:

GRASS 6.2.1 (luenenxy):~ > v.in.ascii
input=/home/jorge/GrassGIS/luenenxy/jorge/koord1.csv out=koord_grass
format=standard --overwrite skip=1 cat=0 fs='space'
WARNUNG: Die Vektorkarte 'koord_grass' existiert bereits und wird
         überschrieben.
Error reading ascii file:

Erzeuge Topologie ...
4 primitives registriert
Building areas: 100%
0 Flächen erstellt
0 Inselflächen erstellt
Füge Inselflächen hinzu:
Füge Zentroide hinzu: 100%
Die Topologie wurde erstellt.
Anzahl von Knoten : 5
Anzahl von Primitives : 4
Anzahl von Punkten : 0
Anzahl von Linien : 4
Anzahl von Boundaries : 0
Anzahl von Zentroiden : 0
Anzahl von Flächen : 0
Anzahl von Inseln : 0
GRASS 6.2.1 (luenenxy):~ >

It seems to recognise the entities in the file but what does this error
message means ???

(tip: you can force GRASS to talk English, by doing "LC_ALL=C; export
LC_ALL" from GRASS CLI first)

My guesses:

1. you don't need the "fs=" and "cat=" for "format=standard", it's for
"format=point" only
2. GRASS expects a header in a GRASS vector ASCII file; use "-n" to
avoid this

Let us know if that helps.

Maciek

Jorge Echeverri wrote:

It seems to recognise the entities in the file but what does this
error message means ???

Error reading ascii file:
???

is there a blank line in the file with a single " " space in it?

v.in.ascii will skip truely blank lines and lines which start with a
hash (#), but no lines with just spaces in them.

Hamish

Jorge Echeverri wrote:

I still don't find out the error:

Input file:
#"X_COORDINATE","Y_COORDINATE"
L 2 1
3400630.04 5718486.603
3400639.238 5718515.776
1 1
L 2 1
3400639.238 5718515.776
3400648.641 5718546.057
1 2
L 2 1
3400648.641 5718546.057
3400665.041 5718562.99
1 3
L 2 1
3400665.041 5718562.99
3400625.996 5718597.349
1 4

Then
GRASS 6.2.1 (luenenxy):~ > v.in.ascii
input=/home/jorge/GrassGIS/luenenxy/jorge/koord2.csv out=koord_grass2
format=standard --overwrite
Error reading ascii file:

Use -n to omit checking for header in the input ASCII vector, like I
wrote before. Look into v.in.ascii, v.out.ascii and pages linked there
for details.

Erzeuge Topologie ...
4 primitives registriert
Building areas: 100%
0 Flächen erstellt
0 Inselflächen erstellt
Füge Inselflächen hinzu:
Füge Zentroide hinzu: 100%
Die Topologie wurde erstellt.
Anzahl von Knoten : 5
Anzahl von Primitives : 4
Anzahl von Punkten : 0
Anzahl von Linien : 4
Anzahl von Boundaries : 0
Anzahl von Zentroiden : 0
Anzahl von Flächen : 0
Anzahl von Inseln : 0

But the lines are rightly imported, so I guess this error message can be
ignored, isn't it?

Are you sure there was no more info about the error besides the:

Error reading ascii file:

as you quoted it? Strange.

Anyway, in 6.3 CVS v.in.ascii format=standard won't proceed with a
malformed or missing header if -n is not used. It might be different in
6.2.1 which you are using though. But that would be a bug.

[after a while]

I have confirmed the -n switch is not processed right in 6.2.2 CVS
either (yet somewhat diffrently than in 6.2.1, which issues an
enigmatic error, while 6.2.2 does not issue any Error); see the note
dated 2007-03-13 20:07 on
http://wald.intevation.org/tracker/index.php?func=detail&aid=328&group_id=21&atid=204

Maciek