v.segment(1)
π v.segment π
okay bestie, welcome to v.segment, a GRASS GIS User's Manual page, and it's giving geometry girlboss. She takes your input vector lines plus a lil list of positions, and boom β out come points and segments. π
β¨ NAME β¨
v.segment β makes points/segments out of input vector lines + positions. no cap. π
πΈ KEYWORDS πΈ
vector, geometry, node, point, segment, vertex
π¦ SYNOPSIS π¦
v.segment
v.segment --help
v.segment input=name [layer=string] output=name [rules=name]
[--overwrite] [--help] [--verbose] [--quiet] [--ui]
β Flags β
--overwriteβ bestie you can let output files overwrite existing files. the audacity, the power. π₯--helpβ prints the usage summary. the lil cheat sheet. π--verboseβ verbose module output, she's chatty. π¬--quietβ quiet module output, she's mysterious. π€«--uiβ forces the GUI dialog to launch. pop-up era. β¨
π Parameters π
input=name[required] β name of the input vector lines map. or a data source for direct OGR access, if that's the vibe. πlayer=stringβ layer number or name. vector features can carry category values in different layers, and this number decides which layer we're using. when you're doing direct OGR access, this is the layer name instead. default is1. πoutput=name[required] β the name for your output vector map. name her something cute. πrules=nameβ name of the file holding the segment rules.'-'means standard input. π
π DESCRIPTION π
v.segment generates segments or points from input lines and from positions it reads out of a text file or 'stdin'. it also does the whole parallel lines / points in a given destination from the line thing. multi-talented, honestly.
the format is literally:
P <point id> <line cat> <offset> [<side offset>]
L <segment id> <line cat> <start offset> <end offset> [<side offset>]
so the offsets can be percent values of the line length. and if the offsets are negative, they start from the end node of the line. -0 means the end of the line. yes, -0. she contains multitudes. π
you could send something like this to stdin:
P 1 356 24.56
P 2 495 12.31
P 3 500 -12.31
P 4 510 -20%
...
(pipe it, or redirect from a file into the command. either one, we're flexible. π«Ά)
π NOTES π
a segment only gets created for the first line found of the specified category. first come, first served, periodt.
points are generated along the lines at the given distance(s) or percent(s) of the line length, measured from the beginning β or from the end, if the offsets are negative β of the vector line.
the side offset is the orthogonal distance from the line. positive side offsets go to the right side of the line going forward, negative offsets go to the left (and d.vect with display=shape,dir will show you which way vector lines are heading). and because the segment distance is measured along the original line, side-offset lines will be longer than the start-end segment distance at outside corners of curving lines, and shorter for inside corners. geometry said "i contain drama." π
all offsets are measured in map units (see "g.proj -p"), or as percents of the line length if you slap a % character after them. π
to place a point in the middle of a line, you can use a 50% offset β or you can use the v.to.db module to find the line's length, and then use half of that distance as the along-line offset. two paths, same slay. πΈ
π₯ EXAMPLES π₯
these examples are all based on the North Carolina sample dataset, iconic dataset, no notes.
π§ Extraction of a line segment π§
extract a line segment from 400m to 5000m from the beginning of line 1:
# extract lines from railroad map:
v.extract input=railroads output=myrr cats=1
# join segments into polyline and reassign category numbers
v.build.polylines myrr out=myrr_pol
v.category input=myrr_pol output=myrailroads option=add
# zoom to an area of interest
g.region vector=myrailroads -p
# show line, category, direction (to find the beginning)
d.mon wx0
d.vect map=myrailroads display=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 input=myrailroads output=myrailroads_segl
d.erase
d.vect map=myrailroads
d.vect map=myrailroads_segl col=green width=2
# set node at 5000m from beginning of line 1
echo "P 1 1 5000" | v.segment input=myrailroads output=myrailroads_segp
d.vect map=myrailroads_segp icon=basic/circle color=red fcolor=red size=5
extract line segment from 400m to 5000m from beginning of line 1. (that's the goal, bestie, we got there. π―)
π Parallel line segments π
creation of parallel, 1km long line segments along the first 8km of track, offset 500m to the left of the tracks:
v.segment input=myrailroads output=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
EOF
d.erase
d.vect map=myrailroads display=shape,dir
d.vect -c map=myrailroads_segl_side width=2
β Points equidistant along the tracks β
creation of a series of points, spaced every 2km along the tracks:
v.segment input=myrailroads output=myrailroads_pt2km << EOF
P 1 1 1000
P 2 1 3000
P 3 1 5000
P 4 1 7000
EOF
d.erase
d.vect map=myrailroads display=shape,dir
d.vect map=myrailroads_pt2km icon=basic/circle color=blue fcolor=blue size=5
a series of points, spaced every 2km along the tracks. evenly spaced queen. π
π¦ Points equidistant along and offset the tracks π¦
creation of a series of points, spaced every 2km along the tracks, offset 500m to the right:
v.segment input=myrailroads output=myrailroads_pt2kmO500m << EOF
P 1 1 1000 500
P 2 1 3000 500
P 3 1 5000 500
P 4 1 7000 500
EOF
d.erase
d.vect map=myrailroads display=shape,dir
d.vect map=myrailroads_pt2kmO500m icon=basic/circle color=aqua fcolor=aqua size=5
a series of points, spaced every 2km along the tracks, offset 500m to the right. main character energy fr fr. β¨
π Points equidistant in percent along and offset the tracks π
creation of a series of points, spaced every 10% of the line's length along the tracks from the end of the line up to the middle point, offset 500m to the right:
v.segment input=myrailroads output=myrailroads_pt10pctO500m << EOF
P 1 1 -0% 500
P 2 1 -10% 500
P 3 1 -20% 500
P 4 1 -30% 500
P 5 1 -40% 500
P 6 1 -50% 500
EOF
d.erase
d.vect map=myrailroads display=shape,dir
d.vect map=myrailroads_pt10pctO500m icon=basic/circle color=red fcolor=black size=5
a series of points, spaced every 10% of the line's length along the tracks from the end of the line up to the middle point, offset 500m to the right. percentages?? we love a proportional girlie. π
π KNOWN ISSUES π
there is a problem with side-offset parallel line generation for inside corners. that's it. that's the bug. she's imperfect but we love her. π
π SEE ALSO π
- LRS tutorial (Linear Referencing System)
d.vectv.build.polylinesv.lrs.segmentv.parallelv.splitv.to.dbv.to.points
π AUTHOR π
Radim Blazek, ITC-Irst, Trento, Italy. respect the icon. π«Ά
π SOURCE CODE π
available at: v.segment source code (history)
accessed: Saturday Jan 17 05:41:30 2026
main index | vector index | topics index | keywords index | graphical index | full index
Β© 2003-2025 GRASS Development Team, GRASS GIS 8.4.2 Reference Manual
and that's the whole manual bestie!! this is GRASS 8.4.2, page v.segment(1), last touched Saturday Jan 17 05:41:30 2026 β go forth and segment, mwah π β¨π
π¦ where this page comes from
- fedora 44: grass 8.4.2-4.fc44 Β· GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms