Rechercher une page de manuel

Chercher une autre page de manuel:


Langue: en

Version: 329728 (ubuntu - 24/10/10)

Section: 1 (Commandes utilisateur)


v.segment - Creates points/segments from input vector lines and positions.


vector, geometry


v.segment help
v.segment input=name output=name [llayer=integer] [file=name] [--overwrite] [--verbose] [--quiet]



Allow output files to overwrite existing files

Verbose module output

Quiet module output



Name of input vector map containing lines

Name for output vector map where segments will be written

Line layer
A single vector map can be connected to multiple database tables. This number determines which table to use.
Default: 1

Name of file containing segment rules. If not given, read from stdin.


v.segment generates segments or points from input lines and from positions read from a text file or 'stdin'.

The format is:
P <point id> <line cat> <offset> [<side offset>]
L <segment id> <line cat> <start offset> <end offset> [<;side offset>;]


The user could send to stdin something like:
P 1 356 24.56
P 2 495 12.31

(pipe or redirect from file into the command).


A segment is only created for the first line found of the specified category.

Points are generated along the lines at the given distance(s) from the beginning of the vector line.

The side offset is the orthogonal distance from the line. Positive side offsets are to the right side of the line going forward, negative offsets are to the left (d.vect with display=shape,dir shows the direction of vector lines). As the segment distance is measured along the original line, side-offset lines will be longer than the start-end segment distance for outside corners of curving lines, and shorter for inside corners.

All offsets are measured in map units (see "g.proj -p").

To place a point in the middle of a line, the module may be used to find the line's length. Then half of that distance can be used as the along-line offset.


Spearfish location:
# extract lines from railroad map:
v.extract railroads out=myrr list=1

# join segments into polyline and reassign category numbers myrr out=myrr_pol
v.category myrr_pol out=myrailroads option=add

# zoom to an area of interest
g.region n=4928200 s=4921100 w=605600 e=613200

# show line, category, direction (to find the beginning)
d.vect myrailroads disp=shape,cat,dir lsize=12

# extract line segment from 400m to 5000m from beginning of line 1
echo "L 1 1 400 5000" | v.segment myrailroads out=myrailroads_segl
d.vect myrailroads
d.vect myrailroads_segl col=green width=2

# set node at 5000m from beginning of line 1
echo "P 1 1 5000" | v.segment myrailroads out=myrailroads_segp
d.vect myrailroads_segp icon=basic/circle color=red fcolor=red size=5

# get points from a text file
cat mypoints.txt | v.segment myrailroads out=myrailroads_mypoints

# create parallel 1km long line segments along first 8km of track,
# offset 500m to the left of the tracks.
v.segment myrailroads out=myrailroads_segl_side << EOF
L 1 1 1000 2000 -500
L 2 1 3000 4000 -500
L 3 1 5000 6000 -500
L 4 1 7000 8000 -500
d.vect myrailroads disp=shape,dir
d.vect -c myrailroads_segl_side width=2

# A series of points, spaced every 2km along the tracks
v.segment myrailroads out=myrailroads_pt2km << EOF
P 1 1 1000
P 2 1 3000
P 3 1 5000
P 4 1 7000
d.vect myrailroads_pt2km icon=basic/circle color=blue fcolor=blue size=5

# A series of points, spaced every 2km along the tracks, offset 500m to the right
v.segment myrailroads out=myrailroads_pt2kmO500m << EOF
P 1 1 1000 500
P 2 1 3000 500
P 3 1 5000 500
P 4 1 7000 500
d.vect myrailroads_pt2kmO500m icon=basic/circle color=aqua fcolor=aqua size=5


There is a problem with side-offset parallel line generation for inside corners.


LRS tutorial (Linear Referencing System),
d.vect,, v.lrs.segment, v.parallel, v.split,,


Radim Blazek, ITC-Irst, Trento, Italy

Last changed: $Date: 2007-12-17 14:42:56 +0100 (lun, 17 dic 2007) $

Full index

© 2003-2010 GRASS Development Team

Aimer, c'est trouver sa richesse hors de soi.
-+- Émile Chartier, dit Alain (1868-1951), Éléments de philosophie -+-