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 the length option, ok? just so you know.
  • -f β€” force segments to be exactly the given length, except for the last one. also only applies to the length option. (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: -1
  • output=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: map
  • vertices=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