v.split(1grass)
π v.split β the GRASS manual, but make it bestie v.split(1grass) π
okay so. hi. you're in the GRASS User's Manual, this is page v.split(1grass), and I'm about to explain it to you like we're texting at 1am. it's genuinely not hard, I promise. π«Ά
β¨ NAME β¨
v.split β splits vector lines to shorter segments. that's it, that's the whole job. iconic honestly.
π·οΈ KEYWORDS π·οΈ
vector, geometry, densification, node, segment, vertex
π SYNOPSIS π
v.split
v.split --help
v.split [-nf] input=name [layer=string] output=name [length=float]
[units=string] [vertices=integer] [--overwrite] [--help]
[--verbose] [--quiet] [--ui]
π© Flags π©
-nβ add new vertices, but do not split. this one only applies to thelengthoption, ok? just so you know.-fβ force segments to be exactly the given length, except for the last one. also only applies to thelengthoption. (yes, the last one gets to be the exception, main character behaviour fr)--overwriteβ let output files overwrite existing files. use with intention bestie.--helpβ print usage summary.--verboseβ verbose module output.--quietβ quiet module output. (the introvert flag)--uiβ force launching GUI dialog.
π Parameters π
input=nameβ required! name of input vector map. or, plot twist, a data source for direct OGR access.layer=stringβ layer number or name ('-1'for all layers). a single vector map can be connected to multiple database tables, and this number determines which table to use. when used with direct OGR access this is the layer name. Default:-1output=nameβ required! name for output vector map.length=floatβ maximum segment length.units=stringβ length units. Options:map,meters,kilometers,feet,surveyfeet,miles,nautmiles. Default:mapvertices=integerβ maximum number of vertices in segment.
π DESCRIPTION π
so v.split splits vector lines into shorter segments using a maximal distance between nodes. the resulting length of all segments is expected to be equal and not higher than the given length parameter. periodt. no cap.
π¦ NOTES π¦
here's the tea: v.split does not change the layer, nor the category information, nor the attribute table links of the original file. it just splits each line into segments and gives the same category to all segments of the same original line. and because the attribute table is linked to the features with their category as the key, all segments originating from the same original line are linked to the same line in the original attribute table β which is just copied over to the new map. it's giving "same energy, more pieces". π
π Notes on individual segment information π
when you run v.to.db on a map produced by v.split, v.to.db will add length information for each segment in its respective attribute line. but here's the catch bestie β since all the segments of the same original line share the same attribute table line, it only gets updated once. π
to actually get the length of each segment, you'll have to attribute different category values to each of them. the best way to do this is on a separate layer, using v.category:
v.category v_split op=add layer=2 output=v_split_2
and then run the following commands on the new layer 2:
v.db.addtable v_split_2 layer=2
v.db.addcolumn map=v_split_2 column="length double precision" layer=2
v.to.db map=v_split_2 type=line option=length columns=length units=meters layer=2
to link the new segments in the new layer to the original segments, use:
v.db.addcolumn map=v_split_2 layer=2 column="cat_1 int"
v.to.db map=v_split_2 layer=2 option=query query_layer=1 query_column=cat columns=cat_1
slay. now you can tell which baby segment came from which parent line. π
πΈ EXAMPLES πΈ
the examples are based on the North Carolina sample data. yes, that's a real thing, it's a whole vibe.
π Example 1: Inserting nodes to railroad lines map π
# extract one railroad line for this example
v.extract input=railroads output=myrr cats=1
# show line, category, direction (to find the beginning)
g.region vector=myrr
d.erase
d.vect myrr display=shape,cat,dir
# insert nodes at a distance not longer than 1000m
v.split input=myrr output=myrr_split_1km length=1000
d.vect myrr_split_1km display=shape,topo
Note: in case that the vector line data are not polylines, generate first polylines as the second step, eg.:
# join segments into polyline
v.build.polylines input=myrr output=myrr_polylines
# regenerate categories
v.category input=myrr_polylines output=myrailroads option=add
β¨ Example 2: Inserting vertices to railroad lines map β¨
Note: first run the two steps from example 1.
# insert vertices at a distance not longer than 1000m
v.split -n input=myrr output=myrr_split length=1000
d.vect myrr_split display=shape,topo
π SEE ALSO π
v.edit, v.build.polylines, v.to.points, v.segment
π AUTHOR π
Radim Blazek
π§ SOURCE CODE π§
available at: v.split source code (history)
latest change: Friday Feb 07 19:16:09 2025 in commit:
a82a39f673b97fafcfce1604dc3e6015cb96487a
main index | Vector index | Topics index | Keywords index | Graphical index | Full index
and that's the whole page, bestie!! π you just read a manpage and honestly? you ate. this was Β© 2003-2026 GRASS Development Team, GRASS 8.5.0 Reference Manual, and the page was... say it with me... GRASS 8.5.0 β v.split(1grass). go split some lines. ily. ππ¦πΈ
π¦ where this page comes from
- alpine 3.24: grass-gis-doc 8.5.0-r1 Β· GPL-2.0-or-later
- ubuntu stonking: grass-doc 8.5.0-1ubuntu1 Β· 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