v.transform(1grass)

✨ v.transform ✨

okay bestie, gather round, because v.transform (that's the 1grass manual entry, mwah) is about to do a whole glow-up on your vector map πŸ’…

πŸŽ€ NAME πŸŽ€

v.transform β€” bestie it performs an affine transformation (that's shift, scale and rotate, the holy trinity πŸ’–) on a vector map.

πŸ”‘ KEYWORDS πŸ”‘

vector, transformation, geometry, GCP ✨

πŸ¦‹ SYNOPSIS πŸ¦‹

v.transform
v.transform --help
v.transform [-twxyab] input=name  [layer=string]  output=name
[xshift=float]   [yshift=float]   [zshift=float]   [xscale=float]
[yscale=float]   [zscale=float]   [zrotation=float]
[columns=name[,name,...]]   [--overwrite]  [--help]  [--verbose]
[--quiet]  [--ui]

🚩 Flags 🚩

  • -t β€” shifts all the z values to bottom=0 πŸ‘‘
  • -w β€” swaps coordinates x, y first, and then applies the other parameters πŸ”„
  • -x β€” swaps coordinates x, z first, and then applies the other parameters πŸ”„
  • -y β€” swaps coordinates y, z first, and then applies the other parameters πŸ”„
  • -a β€” swaps coordinates after the other transformations (not before, bestie, timing is everything ⏰)
  • -b β€” do not build topology πŸ™ˆ
  • --overwrite β€” lets output files overwrite existing files, no cap
  • --help β€” prints the usage summary, the lil cheat sheet πŸ“
  • --verbose β€” verbose module output, she's chatty πŸ’¬
  • --quiet β€” quiet module output, she's giving mysterious 🀫
  • --ui β€” forces launching the GUI dialog, fancy ✨

🌸 Parameters 🌸

  • input=name [required] β€” name of input vector map. Or, alternatively, 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 it's used with direct OGR access, this is the layer name instead. Default: -1
  • output=name [required] β€” name for output vector map 🫢
  • xshift=float β€” shifting value for x coordinates. Default: 0.0
  • yshift=float β€” shifting value for y coordinates. Default: 0.0
  • zshift=float β€” shifting value for z coordinates. Default: 0.0
  • xscale=float β€” scaling factor for x coordinates. Default: 1.0
  • yscale=float β€” scaling factor for y coordinates. Default: 1.0
  • zscale=float β€” scaling factor for z coordinates. Default: 1.0
  • zrotation=float β€” rotation around the z axis, in degrees, counter-clockwise. Default: 0.0
  • columns=name[,name,...] β€” name of attribute column(s) used as transformation parameters. Format: parameter:column, e.g. xshift:xs,yshift:ys,zrot:zr

πŸ’œ DESCRIPTION πŸ’œ

So v.transform performs an affine transformation (that's translate and rotate, periodt) of a vector map. An affine transform includes one or several linear transformations (scaling, rotation) plus translation (shifting), and honestly the way that several linear transformations can be combined into a single operation? Obsessed. 😌

You can use this command to georeference unreferenced vector maps or to modify existing geocoded maps. Both. Iconic behaviour.

🧠 NOTES 🧠

Coordinate transformation based on Ground Control Points (GCPs) is handled by v.rectify, and it is not supported by v.transform. Different girl, different job πŸ’…

Transformation parameters (i.e. xshift, yshift, etc.) can be fetched from the attribute table connected to the vector map. In that case, vector objects can be transformed with different parameters based on their category number. And if a parameter cannot be fetched from the table, the default value gets used instead. Simple as that.

bestie, note that the transformation matrix can be printed by m.transform. πŸ“

🌈 EXAMPLE 🌈

πŸ“ DXF/DWG drawings πŸ“

Most DXF/DWG drawings are done within XY coordinate space. To transform them to a national grid, we can use v.transform together with v.rectify and a first-order transformation. Look at her go:

v.transform -t in=watertowerXY out=watertower_z zscale=0.04 zshift=1320
v.rectify in=watertower_z out=watertowerUTM points=wt.points order=1

🧚 Extrude 2D vector points to 3D based on attribute column values 🧚

Spearfish example with manual table editing for vertical shift β€” she's doing it by hand, artisanal:

# work on own map copy:
g.copy vect=archsites@PERMANENT,myarchsites
# add new ’zs’ column to later store height of each site:
v.db.addcolumn myarchsites col="zs double precision"
v.db.update myarchsites layer=1 column=zs value="cat * 1000"
# perform z transformation:
v.transform -t input=archsites output=myarchsites3d column="zshift:zs" table="archsites_t"
# drop table containing transformation parameters:
echo "drop table archsites_t" | db.execute

The resulting map is a 3D vector map. Slay. ✨

πŸ¦‹ Extrude 2D vector points to 3D based on attribute column values πŸ¦‹

Spearfish example with automated elevation extraction for vertical shift β€” now she's letting the machine do the work, main character energy:

# work on own map copy:
g.copy vect=archsites@PERMANENT,myarchsites
# add new ’zs’ column to later store height of each site:
v.db.addcolumn myarchsites col="zs double precision"
# set region to elevation map and fetch individual heights:
g.region raster=elevation.10m -p
v.what.rast myarchsites rast=elevation.10m col=zs
# verify:
v.db.select myarchsites
# perform transformation to 3D
v.transform -t myarchsites output=myarchsites3d column="zshift:zs" layer=1
# drop table containing transformation parameters
v.db.dropcolumn myarchsites3d col=zs

The resulting map is a 3D vector map. Again. Because she ate. πŸ”₯


πŸ‘€ SEE ALSO πŸ‘€

m.transform, i.rectify, v.rectify, r.region

go read those too, iykyk πŸ’–

πŸ‘‘ AUTHORS πŸ‘‘

Radim Blazek, ITC-irst, Trento, Italy, Column support added by Martin Landa, FBK-irst (formerly ITC-irst), Trento, Italy (2007/09)

absolute legends, fr fr 🫢

πŸ’» SOURCE CODE πŸ’»

Available at: v.transform source code (history)

Latest change: Friday May 09 14:33:40 2025 in commit: b356c7e108fcbeca77474c8e83ebec8f1e7b3e4a

Main index | Vector index | Topics index | Keywords index | Graphical index | Full index


and that's the whole page bestie πŸ’… one last cute sign-off: this gorgeous little manual is Β© 2003-2026 GRASS Development Team, from the GRASS 8.5.0 Reference Manual β€” so you know exactly which era of the lore you're reading. mwah! πŸ’–βœ¨πŸŽ€πŸ¦‹πŸŒΈ

πŸ“¦ where this page comes from