v.mkgrid(1grass)

πŸ’… v.mkgrid β€” GRASS User's Manual πŸ’…

okay bestie, welcome to v.mkgrid, the tool that literally makes grids. it's giving geometry, it's giving point pattern, it's giving hexagons. no cap. πŸ¦‹


✨ NAME ✨

v.mkgrid β€” creates a vector map of a grid that you define, and she ate. πŸ’–

πŸŽ€ KEYWORDS πŸŽ€

vector, geometry, grid, point pattern, hexagon

🌸 SYNOPSIS 🌸

v.mkgrid
v.mkgrid --help
v.mkgrid [-had] map=name  [grid=rows,columns]   [position=string]
[coordinates=east,north]   [box=width,height]   [angle=float]
[breaks=integer]   [type=string]   [--overwrite]  [--help]  [--verbose]
[--quiet]  [--ui]

🚩 Flags

  • -h β€” makes hexagons instead of rectangles (rectangles are the default, iykyk)
  • -a β€” lets the hexagons be asymmetric (symmetric is the default vibe)
  • -d β€” EXPERIMENTAL: adds diagonals to rectangular lines. heads up: this one only applies to lines for rectangles, bestie
  • --overwrite β€” lets output files overwrite files that already exist
  • --help β€” prints the usage summary
  • --verbose β€” verbose module output, for when you wanna know everything
  • --quiet β€” quiet module output, for when you do NOT
  • --ui β€” force launches the GUI dialog

🧚 Parameters

  • map=name [required] β€” the name for your output vector map, you gotta give her a name πŸ’•
  • grid=rows,columns β€” how many rows and columns are in the grid
  • position=string β€” where to place the grid. Options: region, coor. Default: region. region = use the current region. coor = use the coor and box options.
  • coordinates=east,north β€” the lower left easting and northing coordinates of the map
  • box=width,height β€” width and height of the boxes in the grid
  • angle=float β€” angle of rotation, in degrees, counter-clockwise. Default: 0
  • breaks=integer β€” number of vertex points per grid cell. Options: 0-60. Default: 0
  • type=string β€” output feature type. Options: point, line, area. Default: area

πŸ”₯ DESCRIPTION πŸ”₯

v.mkgrid creates a vector map representation of a regular coordinate grid. you can make point vector grids, line vector grids, and area vector grids. three icons, one module. periodt. πŸ’…

πŸ‘‘ NOTES πŸ‘‘

  • Grid points made with the type=point option get placed at the center of each grid cell β€” literally the same spot as centroids with the default type=area option. same energy.
  • Grid lines made with the type=line option are identical to the edges of each grid cell, just like boundaries with the default type=area option.
  • the resultant grid can be rotated around the origin (that's the center of the grid) with the angle option.
  • Optionally you can make hexagons with the -h flag. hexagons are symmetric by default. Asymmetric hexagons can be allowed with the -a flag. 🐝
  • This module is NOT to be used to generate a vector map of USGS quadrangles, because USGS quads are not exact rectangles. not me warning you, but like... i'm warning you. πŸ™ˆ

🌈 EXAMPLES 🌈

🌍 Creating a global grid in a latitude-longitude

to be run in a latitude-longitude project (WGS84):

# set the region:
g.region n=90 s=-90 w=-180 e=180 res=10 -p
projection: 3 (Latitude-Longitude)
zone:       0
datum:      wgs84
ellipsoid:  wgs84
north:      90N
south:      90S
west:       180W
east:       180E
nsres:      10
ewres:      10
rows:       18
cols:       36
cells:      648
# create 10 degree size grid:
v.mkgrid map=grid_10deg
# create 20 degree size grid:
v.mkgrid map=grid_20deg box=20,20

πŸ“ Creating a grid in a metric projection

Creating a 4x3 grid, cells 20km a side, with lower left corner at 2716500,6447000:

v.mkgrid map=coro_grid grid=4,3 position=coor coordinates=2716500,6447000 box=20000,20000

πŸ—ΊοΈ Creating a positioned grid in a latitude-longitude

Creating a 10x12 lat/lon grid, cells 2 arc-min a side, with lower left corner at 167deg 52min east, 47deg 6min south. For use with e.g. QGIS you can then pull this grid into a project with projected coordinate reference system (CRS) using v.proj before exporting as a vector file with v.out.ogr (within GRASS you could just use d.grid -w from the project with projected CRS for the same effect):

v.mkgrid map=p2min_grid grid=10,12 position=coor coordinates=167:52E,47:06S box=0:02,0:02

✨ Creating a simple point pattern

North Carolina sample dataset example, creating a 1km spaced point grid based on the current region extent defined by the "elevation" map:

g.region raster=elevation res=1000 -pa
v.mkgrid type=point map=pointpattern

🎯 Creating a regular point pattern

North Carolina sample dataset example, creating a regular spaced point grid based on the current region extent defined by the "elevation" map, using a two-step approach:

# create first set of points, covering extent of "elevation" raster map
g.region raster=elevation res=1000 -pa
v.mkgrid type=point map=pointpattern1
# shift grid by half point distance (map units)
g.region n=n+500 w=w+500 e=e+500 s=s+500 -p
# create second set of points
v.mkgrid type=point map=pointpattern2
# merge into final point pattern
v.patch input=pointpattern1,pointpattern2 output=pointpattern3

Different point patterns for sampling design πŸ’–

🐝 Creating hexagons in a metric projection

North Carolina sample dataset example, creating regular hexagons based on the current region extent defined by the "elevation" map and raster resolution for the hexagon size:

g.region raster=elevation res=5000 -pa
v.mkgrid map=hexagons -h
d.grid 5000

Hexagon map 🍯

πŸ’œ Using hexagons for point density

To compute point density in a hexagonal grid for the vector map points_of_interest in the basic North Carolina sample dataset, the vector map itself is used to set extent of the computational region. The resolution is based on the desired size of hexagons.

g.region vector=points_of_interest res=2000 -pa

The hexagonal grid is created as a vector map based on the previously selected extent and size of the grid.

v.mkgrid map=hexagons -h

The following counts the number of points per hexagon using the v.vect.stats module.

v.vect.stats points=points_of_interest areas=hexagons count_column=count
Users should note that some of the points may be outside the grid since the hexagons cannot cover all the area around the edges (the computational region extent needs to be enlarged if all points should be considered).

The last command sets the vector map color table to viridis based on the count column.

v.colors map=hexagons use=attr column=count color=viridis

Point density in a hexagonal grid 🌈


πŸ‘€ SEE ALSO πŸ‘€

d.grid, v.in.region, v.patch, v.vect.stats

🫢 AUTHORS 🫢

Michael Higgins, U.S.Army Construction Engineering Research Laboratory

Update for new vectors Radim Blazek 10/2004

πŸ’Ύ SOURCE CODE πŸ’Ύ

Available at: v.mkgrid source code (history)

Latest change: Friday Aug 08 09:39:19 2025 in commit: ed72c71d8580e872cd6fd345c84a15c324764465

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

Β© 2003-2026 GRASS Development Team, GRASS 8.5.0 Reference Manual


and that's the whole page bestie, pls go make a grid that slays πŸ’–βœ¨πŸŒΈ this was v.mkgrid from the GRASS 8.5.0 Reference Manual, footer date and all β€” Friday Aug 08 09:39:19 2025 was literally when she was last changed, and Β© 2003-2026 GRASS Development Team said so. mwah πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from