How to convert from point to line ?

4 messages Options
Embed this post
Permalink
SGW00412

How to convert from point to line ?

Reply Threaded More More options
Print post
Permalink
Dear all

I am a beginner user of grass gis.

I want to import a text file that included latitude, longitude,ID number and
recordig time, into grass as line data.

The format style is as follows:

id,x,y,time
1,857.8629761,-785.6849976,1
1,987.9949951,-682.4140015,2
1,964.4849854,-710.6849976,3
2,1689.578979,-1070.564941,4
2,1654.074951,-1061.333008,5
2,1618.218018,-1040.505981,6
3,2335.930908,-1180.246948,7
3,2336.694092,-1197.869019,8
3,2336.658936,-1218.124023,9
4,2512.673096,-1689.875977,10
4,2494.010986,-1710.625977,11
5,1826.724976,-1731.743042,12
5,1808.57605,-1726.490967,13
5,1793.598999,-1723.034058,14
.....
.....
.....
.....


Firstly I intended to use 'v in ascii' command.

However, this command imports a text data into points, I think.

I want to import this text file into grass as line data according to the ID
number.

May this question be solved in grass? If it is so, please teach a solution....

Yasuo shimada: Japan weather assocation.
_______________________________________________
grass-user mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-user
Hermann Peifer

Re: How to convert from point to line ?

Reply Threaded More More options
Print post
Permalink
[hidden email] wrote:
> Dear all
>
> I am a beginner user of grass gis.
>

So am I. But as nobody else seems to have a better idea... here is what I would do:

a) reformat yourdata into GMT format (yourdata.gmt) with a small AWK script

$ awk -f reformat_to_gmt.awk yourdata > yourdata.gmt

b) import yourdata.gmt into GRASS via v.in.ogr

$ v.in.ogr -o yourdata.gmt out=yourdata

(This assumes that you already have a GRASS location with the same projection as the coordinates in your data file).

Below some more details.

Hope this helps, Hermann


$ cat yourdata
id,x,y,time
1,857.8629761,-785.6849976,1
1,987.9949951,-682.4140015,2
1,964.4849854,-710.6849976,3
2,1689.578979,-1070.564941,4
2,1654.074951,-1061.333008,5
2,1618.218018,-1040.505981,6
3,2335.930908,-1180.246948,7
3,2336.694092,-1197.869019,8
3,2336.658936,-1218.124023,9
4,2512.673096,-1689.875977,10
4,2494.010986,-1710.625977,11
5,1826.724976,-1731.743042,12
5,1808.57605,-1726.490967,13
5,1793.598999,-1723.034058,14

$ cat reformat_to_gmt.awk
BEGIN { FS = "," }

NR == 1 {
        print "# @VGMT2.0 @GLINESTRING"
        print "# @NID"
        print "# @Tinteger"
        print "# FEATURE_DATA"
        next
}

prev != $1 { print ">" ORS "# @D" $1 }

{ print $2,$3 ; prev = $1 }




$ cat yourdata.gmt
# @VGMT2.0 @GLINESTRING
# @NID
# @Tinteger
# FEATURE_DATA
>
# @D1
857.8629761 -785.6849976
987.9949951 -682.4140015
964.4849854 -710.6849976
>
# @D2
1689.578979 -1070.564941
1654.074951 -1061.333008
1618.218018 -1040.505981
>
# @D3
2335.930908 -1180.246948
2336.694092 -1197.869019
2336.658936 -1218.124023
>
# @D4
2512.673096 -1689.875977
2494.010986 -1710.625977
>
# @D5
1826.724976 -1731.743042
1808.57605 -1726.490967
1793.598999 -1723.034058

_______________________________________________
grass-user mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-user
Juan Carlos Torres Cantero

Re: How to convert from point to line ?

Reply Threaded More More options
Print post
Permalink
In reply to this post by SGW00412
Dear Yasou

You can import any geometric element using v.in.ascii. Use

*format*=///standard/

and include in your a header with primitive code L (that is line).

You can see an example at the manual page

http://grass.itc.it/grass62/manuals/html62_user/v.in.ascii.html

best regards

Juan Carlos Torres


[hidden email] escribió:

> Dear all
>
> I am a beginner user of grass gis.
>
> I want to import a text file that included latitude, longitude,ID number and
> recordig time, into grass as line data.
>
> The format style is as follows:
>
> id,x,y,time
> 1,857.8629761,-785.6849976,1
> 1,987.9949951,-682.4140015,2
> 1,964.4849854,-710.6849976,3
> 2,1689.578979,-1070.564941,4
> 2,1654.074951,-1061.333008,5
> 2,1618.218018,-1040.505981,6
> 3,2335.930908,-1180.246948,7
> 3,2336.694092,-1197.869019,8
> 3,2336.658936,-1218.124023,9
> 4,2512.673096,-1689.875977,10
> 4,2494.010986,-1710.625977,11
> 5,1826.724976,-1731.743042,12
> 5,1808.57605,-1726.490967,13
> 5,1793.598999,-1723.034058,14
> .....
> .....
> .....
> .....
>
>
> Firstly I intended to use 'v in ascii' command.
>
> However, this command imports a text data into points, I think.
>
> I want to import this text file into grass as line data according to the ID
> number.
>
> May this question be solved in grass? If it is so, please teach a solution....
>
> Yasuo shimada: Japan weather assocation.
> _______________________________________________
> grass-user mailing list
> [hidden email]
> http://lists.osgeo.org/mailman/listinfo/grass-user
>  

_______________________________________________
grass-user mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-user
hamish-2

Re: How to convert from point to line ?

Reply Threaded More More options
Print post
Permalink
In reply to this post by SGW00412
If you search in the mailing list archives you'll find a script
I wrote for someone some months ago to do this. (that was for
animal tracks IIRC). Input format is always different, so it's
hard, but possible, to come up with an automatic solution.

as mentioned by others, the typical solution is to use v.in.ascii
format=standard. See also v.in.mapgen but that doesn't give
you the line numbers.


Hamish


SGW00412  wrote:

> I am a beginner user of grass gis.
>
> I want to import a text file that included latitude,
> longitude,ID number and
> recordig time, into grass as line data.
>
> The format style is as follows:
>
> id,x,y,time
> 1,857.8629761,-785.6849976,1
> 1,987.9949951,-682.4140015,2
> 1,964.4849854,-710.6849976,3
> 2,1689.578979,-1070.564941,4
> 2,1654.074951,-1061.333008,5
> 2,1618.218018,-1040.505981,6
> 3,2335.930908,-1180.246948,7
> 3,2336.694092,-1197.869019,8
> 3,2336.658936,-1218.124023,9
> 4,2512.673096,-1689.875977,10
> 4,2494.010986,-1710.625977,11
> 5,1826.724976,-1731.743042,12
> 5,1808.57605,-1726.490967,13
> 5,1793.598999,-1723.034058,14
> .....
> .....
> .....
> .....
>
>
> Firstly I intended to use 'v in ascii' command.
>
> However, this command imports a text data into points, I
> think.
>
> I want to import this text file into grass as line data
> according to the ID
> number.
>
> May this question be solved in grass? If it is so, please
> teach a solution....
>
> Yasuo shimada: Japan weather assocation.
> _______________________________________________
> grass-user mailing list
> [hidden email]
> http://lists.osgeo.org/mailman/listinfo/grass-user
>



_______________________________________________
grass-user mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-user