v.mkgrid(1)
π v.mkgrid π
okay so welcome to the v.mkgrid(1) page, straight outta the GRASS GIS User's Manual β this is the little module that makes grids, and bestie, it eats β¨
β¨ NAME β¨
v.mkgrid β Creates a vector map of a user-defined grid. that's it. that's the whole job. π
π 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β Create hexagons (default: rectangles). hexagon era fr fr π-aβ Allow asymmetric hexagons. no cap, sometimes you want the lopsided ones π-dβ EXPERIMENTAL: Add diagonals to rectangular lines. Applies only to lines for rectangles. (experimental!! she's testing the waters, be nice π«Ά)--overwriteβ Allow output files to overwrite existing files. it will simply replace them. iconic but dangerous π--helpβ Print usage summary--verboseβ Verbose module output--quietβ Quiet module output--uiβ Force launching GUI dialog
π Parameters π
map=name[required] β Name for output vector map. this one is literally required, no skipping πgrid=rows,columnsβ Number of rows and columns in gridposition=stringβ Where to place the grid- Options:
region,coor - Default:
region region: current regioncoor: usecoorandboxoptions
- Options:
coordinates=east,northβ Lower left easting and northing coordinates of mapbox=width,heightβ Width and height of boxes in gridangle=floatβ Angle of rotation (in degrees counter-clockwise)- Default:
0
- Default:
breaks=integerβ Number of vertex points per grid cell- Options:
0-60 - Default:
0
- Options:
type=stringβ Output feature type- Options:
point,line,area - Default:
area
- Options:
πΈ DESCRIPTION πΈ
v.mkgrid creates a vector map representation of a regular coordinate grid. Point, line, and area vector grids can be created. so basically: pick a shape, get a grid. main character energy π
π¦ NOTES π¦
okay so the tea β
- Grid points created with the
type=pointoption will be placed at the center of each grid cell, like centroids with the defaulttype=areaoption. - Grid lines created with the
type=lineoption will be identical to the edges of each grid cell, like boundaries with the defaulttype=areaoption. - The resultant grid can be rotated around the origin (center of the grid) with the
angleoption. spinny β¨ - Optionally hexagons can be created with the
-hflag. Hexagons are by default symmetric. Asymmetric hexagons can be allowed with the-aflag. - This module is NOT to be used to generate a vector map of USGS quadrangles, because USGS quads are not exact rectangles. like literally not the vibe, don't do it π
π 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 GIS 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
(figure: 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
(figure: 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
(figure: Point density in a hexagonal grid)
π SEE ALSO π
d.grid, v.in.region, v.patch, v.vect.stats
go read those too, they're all besties with this one π
π 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)
Accessed: Saturday Jan 17 05:41:25 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 page bestie, no notes, 10/10, would grid again π«Ά this was GRASS GIS 8.4.2, accessed Saturday Jan 17 05:41:25 2026, and yes the Β© 2003-2025 GRASS Development Team is holding it down πβ¨
π¦ 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