Skip to content

d.grid

Overlays a user-specified grid in the active display frame on the graphics monitor.

d.grid [-agwcdfnbt] size=value [origin=east,north] [direction=string] [width=float] [color=name] [border_color=name] [text_color=name] [bgcolor=name] [fontsize=integer] [--verbose] [--quiet] [--qq] [--ui]

Example:

d.grid size=value

grass.script.parse_command("d.grid", size, origin="0,0", direction="both", width=None, color="gray", border_color="black", text_color="gray", bgcolor="none", fontsize=9, flags=None, verbose=False, quiet=False, superquiet=False)

Example:

gs.parse_command("d.grid", size="value")

Parameters

size=value [required]
    Size of grid to be drawn (in map units)
    0 for north-south resolution of the current region. In map units or DDD:MM:SS format. Example: "1000" or "0:10"
origin=east,north
    Lines of the grid pass through this coordinate
    Default: 0,0
direction=string
    Draw only east-west lines, north-south lines, or both
    Allowed values: both, east-west, north-south
    Default: both
width=float
    Grid line width
color=name
    Grid color
    Either a standard color name or R:G:B triplet
    Default: gray
border_color=name
    Border color
    Either a standard color name or R:G:B triplet
    Default: black
text_color=name
    Text color
    Either a standard color name or R:G:B triplet
    Default: gray
bgcolor=name
    Background color
    Either a standard color name, R:G:B triplet, or "none"
    Default: none
fontsize=integer
    Font size for gridline coordinate labels
    Allowed values: 1-72
    Default: 9
-a
    Align the origin to the east-north corner of the current region
-g
    Draw geographic grid (referenced to current ellipsoid)
-w
    Draw geographic grid (referenced to WGS84 ellipsoid)
-c
    Draw '+' marks instead of grid lines
-d
    Draw '.' marks instead of grid lines
-f
    Draw fiducial marks instead of grid lines
-n
    Disable grid drawing
-b
    Disable border drawing
-t
    Disable text drawing
--help
    Print usage summary
--verbose
    Verbose module output
--quiet
    Quiet module output
--qq
    Very quiet module output
--ui
    Force launching GUI dialog

size : str, required
    Size of grid to be drawn (in map units)
    0 for north-south resolution of the current region. In map units or DDD:MM:SS format. Example: "1000" or "0:10"
    Used as: value
origin : tuple[float, float] | list[float] | str, optional
    Lines of the grid pass through this coordinate
    Used as: input, coords, east,north
    Default: 0,0
direction : str, optional
    Draw only east-west lines, north-south lines, or both
    Allowed values: both, east-west, north-south
    Default: both
width : float, optional
    Grid line width
color : str, optional
    Grid color
    Either a standard color name or R:G:B triplet
    Used as: input, color, name
    Default: gray
border_color : str, optional
    Border color
    Either a standard color name or R:G:B triplet
    Used as: input, color, name
    Default: black
text_color : str, optional
    Text color
    Either a standard color name or R:G:B triplet
    Used as: input, color, name
    Default: gray
bgcolor : str, optional
    Background color
    Either a standard color name, R:G:B triplet, or "none"
    Used as: input, color, name
    Default: none
fontsize : int, optional
    Font size for gridline coordinate labels
    Allowed values: 1-72
    Default: 9
flags : str, optional
    Allowed values: a, g, w, c, d, f, n, b, t
    a
        Align the origin to the east-north corner of the current region
    g
        Draw geographic grid (referenced to current ellipsoid)
    w
        Draw geographic grid (referenced to WGS84 ellipsoid)
    c
        Draw '+' marks instead of grid lines
    d
        Draw '.' marks instead of grid lines
    f
        Draw fiducial marks instead of grid lines
    n
        Disable grid drawing
    b
        Disable border drawing
    t
        Disable text drawing
verbose: bool, optional
    Verbose module output
    Default: False
quiet: bool, optional
    Quiet module output
    Default: False
superquiet: bool, optional
    Very quiet module output
    Default: False

DESCRIPTION

d.grid overlays a grid of user-defined size and color in the active display frame on the graphics monitor. The grid can be created as a standard rectangular grid or a geographic grid.

If the user provides a -g flag a geographic (projected) grid will be drawn. With the -g flag the size argument accepts both decimal degrees and colon separated ddd🇲🇲ss coordinates (eg. 00:30:00 for half of a degree). A geographic grid cannot be drawn for a latitude/longitude or XY projection.

Colors may be standard named GRASS colors (red, green, aqua, etc.) or a numerical R:G:B triplet, where component values range from 0-255. Grid color can be set with option color. Options text_color and bgcolor set the color of the text and its background.

The grid drawing may be turned off by using the -n flag.
The border drawing may be turned off by using the -b flag.
The coordinate text may be turned off by using the -t flag.

To draw grid lines at different intervals, e.g. at high latitudes, you can run the module twice, once with direction=east-west at one interval size, and again with direction=north-south at another interval size.

EXAMPLES

To draw a red geographic grid with 30 minute grid spacing, run one of the following commands:

d.grid -g size=00:30:00 color=red

or

d.grid -g size=0.5 color=255:0:0

d.grid red grid example
Figure: Showing a geographic grid in red line color

To draw a blue standard rectangular grid at a 500 (meter) spacing run the following:

d.grid size=500 color=blue

d.grid blue grid example
Figure: Showing a rectangular grid in blue line color

SEE ALSO

d.barscale, d.legend, d.geodesic, d.rhumbline, d.erase, d.frame, d.rast, v.mkgrid

AUTHORS

James Westervelt, U.S. Army Construction Engineering Research Laboratory
Geogrid support: Bob Covill
Border support: Markus Neteler
Text and RGB support: Hamish Bowman
Background color implemented as part of GSoC 2016 by Adam Laza, CTU in Prague

SOURCE CODE

Available at: d.grid source code (history)
Latest change: Wednesday Feb 12 23:02:46 2025 in commit 9c11460