1v.mkgrid(1) GRASS GIS User's Manual v.mkgrid(1)
2
3
4
6 v.mkgrid - Creates a vector map of a user-defined grid.
7
9 vector, geometry, grid, point pattern, hexagon
10
12 v.mkgrid
13 v.mkgrid --help
14 v.mkgrid [-had] map=name [grid=rows,columns] [position=string]
15 [coordinates=east,north] [box=width,height] [angle=float]
16 [breaks=integer] [type=string] [--overwrite] [--help] [--verbose]
17 [--quiet] [--ui]
18
19 Flags:
20 -h
21 Create hexagons (default: rectangles)
22
23 -a
24 Allow asymmetric hexagons
25
26 -d
27 EXPERIMENTAL: Add diagonals to rectangular lines
28 Applies only to lines for rectangles
29
30 --overwrite
31 Allow output files to overwrite existing files
32
33 --help
34 Print usage summary
35
36 --verbose
37 Verbose module output
38
39 --quiet
40 Quiet module output
41
42 --ui
43 Force launching GUI dialog
44
45 Parameters:
46 map=name [required]
47 Name for output vector map
48
49 grid=rows,columns
50 Number of rows and columns in grid
51
52 position=string
53 Where to place the grid
54 Options: region, coor
55 Default: region
56 region: current region
57 coor: use ’coor’ and ’box’ options
58
59 coordinates=east,north
60 Lower left easting and northing coordinates of map
61
62 box=width,height
63 Width and height of boxes in grid
64
65 angle=float
66 Angle of rotation (in degrees counter-clockwise)
67 Default: 0
68
69 breaks=integer
70 Number of vertex points per grid cell
71 Options: 0-60
72 Default: 0
73
74 type=string
75 Output feature type
76 Options: point, line, area
77 Default: area
78
80 v.mkgrid creates a vector map representation of a regular coordinate
81 grid. Point, line, and area vector grids can be created.
82
84 Grid points created with the type=point option will be placed at the
85 center of each grid cell, like centroids with the default type=area op‐
86 tion.
87
88 Grid lines created with the type=line option will be identical to the
89 edges of each grid cell, like boundaries with the default type=area op‐
90 tion.
91
92 The resultant grid can be rotated around the origin (center of the
93 grid) with the angle option.
94
95 Optionally hexagons can be created with the -h flag. Hexagons are by
96 default symmetric. Asymmetric hexagons can be allowed with the -a flag.
97
98 This module is NOT to be used to generate a vector map of USGS quadran‐
99 gles, because USGS quads are not exact rectangles.
100
102 Creating a global grid in a latitude-longitude
103 To be run in a latitude-longitude location (WGS84)
104 # set the region:
105 g.region n=90 s=-90 w=-180 e=180 res=10 -p
106 projection: 3 (Latitude-Longitude)
107 zone: 0
108 datum: wgs84
109 ellipsoid: wgs84
110 north: 90N
111 south: 90S
112 west: 180W
113 east: 180E
114 nsres: 10
115 ewres: 10
116 rows: 18
117 cols: 36
118 cells: 648
119 # create 10 degree size grid:
120 v.mkgrid map=grid_10deg
121 # create 20 degree size grid:
122 v.mkgrid map=grid_20deg box=20,20
123
124 Creating a grid in a metric projection
125 Creating a 4x3 grid, cells 20km a side, with lower left corner at
126 2716500,6447000:
127 v.mkgrid map=coro_grid grid=4,3 position=coor coordinates=2716500,6447000 box=20000,20000
128
129 Creating a positioned grid in a latitude-longitude
130 Creating a 10x12 lat/lon grid, cells 2 arc-min a side, with lower left
131 corner at 167deg 52min east, 47deg 6min south. For use with e.g. QGIS
132 you can then pull this grid into a projected location with v.proj be‐
133 fore exporting as a Shapefile with v.out.ogr (within GRASS GIS you
134 could just use d.grid -w from the projected location for the same ef‐
135 fect):
136 v.mkgrid map=p2min_grid grid=10,12 position=coor coordinates=167:52E,47:06S box=0:02,0:02
137
138 Creating a simple point pattern
139 North Carolina sample dataset example, creating a 1km spaced point grid
140 based on the current region extent defined by the "elevation" map:
141 g.region raster=elevation res=1000 -pa
142 v.mkgrid type=point map=pointpattern
143
144 Creating a regular point pattern
145 North Carolina sample dataset example, creating a regular spaced point
146 grid based on the current region extent defined by the "elevation" map,
147 using a two-step approach:
148 # create first set of points, covering extent of "elevation" raster map
149 g.region raster=elevation res=1000 -pa
150 v.mkgrid type=point map=pointpattern1
151 # shift grid by half point distance (map units)
152 g.region n=n+500 w=w+500 e=e+500 s=s+500 -p
153 # create second set of points
154 v.mkgrid type=point map=pointpattern2
155 # merge into final point pattern
156 v.patch input=pointpattern1,pointpattern2 output=pointpattern3
157 Different point patterns for sampling design
158
159 Creating hexagons in a metric projection
160 North Carolina sample dataset example, creating regular hexagons based
161 on the current region extent defined by the "elevation" map and raster
162 resolution for the hexagon size:
163 g.region raster=elevation res=5000 -pa
164 v.mkgrid map=hexagons -h
165 d.grid 5000
166 Hexagon map
167
168 Using hexagons for point density
169 To compute point density in a hexagonal grid for the vector map
170 points_of_interest in the basic North Carolina sample dataset, the vec‐
171 tor map itself is used to set extent of the computational region. The
172 resolution is based on the desired size of hexagons.
173 g.region vector=points_of_interest res=2000 -pa
174 The hexagonal grid is created as a vector map based on the previously
175 selected extent and size of the grid.
176 v.mkgrid map=hexagons -h
177 The following counts the number of points per hexagon using the
178 v.vect.stats module.
179 v.vect.stats points=points_of_interest areas=hexagons count_column=count
180 User should note that some of the points may be outside the grid since
181 the hexagons cannot cover all the area around the edges (the computa‐
182 tional region extent needs to be enlarged if all points should be con‐
183 sidered). The last command sets the vector map color table to viridis
184 based on the count column.
185 v.colors map=hexagons use=attr column=count color=viridis
186 Point density in a hexagonal grid
187
189 d.grid, v.in.region, v.patch, v.vect.stats
190
192 Michael Higgins, U.S.Army Construction Engineering Research Laboratory
193
194 Update for new vectors Radim Blazek 10/2004
195
197 Available at: v.mkgrid source code (history)
198
199 Accessed: Saturday Oct 28 18:18:37 2023
200
201 Main index | Vector index | Topics index | Keywords index | Graphical
202 index | Full index
203
204 © 2003-2023 GRASS Development Team, GRASS GIS 8.3.1 Reference Manual
205
206
207
208GRASS 8.3.1 v.mkgrid(1)