Skip to content

m.measure

Measures the lengths and areas of features.

m.measure [-g] coordinates=east,north [,east,north,...] [units=string] format=name [--verbose] [--quiet] [--qq] [--ui]

Example:

m.measure coordinates=0.0 format=plain

grass.script.parse_command("m.measure", coordinates, units=None, format="plain", flags=None, verbose=None, quiet=None, superquiet=None)

Example:

gs.parse_command("m.measure", coordinates=0.0, format="json")

grass.tools.Tools.m_measure(coordinates, units=None, format="plain", flags=None, verbose=None, quiet=None, superquiet=None)

Example:

tools = Tools()
tools.m_measure(coordinates=0.0, format="json")

This grass.tools API is experimental in version 8.5 and expected to be stable in version 8.6.

Parameters

coordinates=east,north [,east,north,...] [required]
    Coordinates
units=string
    Units
    Default: project map units
    Allowed values: miles, feet, meters, kilometers, acres, hectares
format=name [required]
    Output format
    Allowed values: plain, shell, json
    Default: plain
    plain: Plain text output
    shell: shell script style output
    json: JSON (JavaScript Object Notation)
-g
    Shell script style [deprecated]
    This flag is deprecated and will be removed in a future release. Use format=shell instead.
--help
    Print usage summary
--verbose
    Verbose module output
--quiet
    Quiet module output
--qq
    Very quiet module output
--ui
    Force launching GUI dialog

coordinates : list[tuple[float, float]] | tuple[float, float] | list[float] | str, required
    Coordinates
    Used as: input, coords, east,north
units : str, optional
    Units
    Default: project map units
    Allowed values: miles, feet, meters, kilometers, acres, hectares
format : str, required
    Output format
    Used as: name
    Allowed values: plain, shell, json
    plain: Plain text output
    shell: shell script style output
    json: JSON (JavaScript Object Notation)
    Default: plain
flags : str, optional
    Allowed values: g
    g
        Shell script style [deprecated]
        This flag is deprecated and will be removed in a future release. Use format=shell instead.
verbose : bool, optional
    Verbose module output
    Default: None
quiet : bool, optional
    Quiet module output
    Default: None
superquiet : bool, optional
    Very quiet module output
    Default: None

coordinates : list[tuple[float, float]] | tuple[float, float] | list[float] | str, required
    Coordinates
    Used as: input, coords, east,north
units : str, optional
    Units
    Default: project map units
    Allowed values: miles, feet, meters, kilometers, acres, hectares
format : str, required
    Output format
    Used as: name
    Allowed values: plain, shell, json
    plain: Plain text output
    shell: shell script style output
    json: JSON (JavaScript Object Notation)
    Default: plain
flags : str, optional
    Allowed values: g
    g
        Shell script style [deprecated]
        This flag is deprecated and will be removed in a future release. Use format=shell instead.
verbose : bool, optional
    Verbose module output
    Default: None
quiet : bool, optional
    Quiet module output
    Default: None
superquiet : bool, optional
    Very quiet module output
    Default: None

Returns:

result : grass.tools.support.ToolResult | None
If the tool produces text as standard output, a ToolResult object will be returned. Otherwise, None will be returned.

DESCRIPTION

m.measure provides the user with a way to measure the lengths and areas of lines and polygons. Areas can be stated in acres, hectares, square miles, square feet, square meters and square kilometers.

EXAMPLES

Distance example in a latitude-longitude coordinate reference system (on great circle, i.e. an orthodrome):

Bonn_DE="7.09549,50.73438"
Philadelphia_US="-75.16379,39.95233"

m.measure coordinates="$Bonn_DE,$Philadelphia_US" units=kilometers
Length:  6217.916452 kilometers

Visualization (with d.geodesic) of m.measure distance example
Visualization (with d.geodesic) of m.measure distance example

As an example for the North Carolina sample dataset, here four points describing a square of 1000m side length:

m.measure units=meters \
  coordinates=922000,2106000,923000,2106000,923000,2107000,922000,2107000
Length:  3000.000000 meters
Area:    1000000.000000 square meters

# script style output:
m.measure -g units=hectares \
  coordinates=922000,2106000,923000,2106000,923000,2107000,922000,2107000
units=meters,square meters
length=3000.000000
area=1000000.000000

Measuring length and area using Python (JSON output):

import grass.script as gs

data = gs.parse_command(
    "m.measure",
    coordinates=[
        "922000",
        "2106000",
        "923000",
        "2106000",
        "923000",
        "2107000",
        "922000",
        "2107000",
    ],
    format="json",
)
print(data)

Possible output:

{'units': {'length': 'meters', 'area': 'square meters'}, 'length': 3000, 'area': 1000000}

SEE ALSO

d.geodesic

AUTHORS

Glynn Clements
Some updates by Martin Landa, CTU in Prague, Czech Republic

Derived from d.measure by James Westervelt, Michael Shapiro, U.S. Army Construction Engineering Research Laboratory

SOURCE CODE

Available at: m.measure source code (history)
Latest change: Thursday Jul 17 16:28:40 2025 in commit 2e97eb8