m.proj(1grass)

๐Ÿ’… m.proj โ€” the GRASS manual, but make it cute

okay bestie, welcome to m.proj from the GRASS User's Manual ๐Ÿ’– this is the one that converts coordinates from one projection to another โ€” it's literally a cs2cs frontend, no cap. She's little, she's powerful, she's giving main character energy โœจ

KEYWORDS: miscellaneous, projection, transformation ๐Ÿฆ‹


โœจ SYNOPSIS โœจ

m.proj
m.proj --help
m.proj [-iodec]  [coordinates=east,north]   [input=name]   [output=name]
[separator=character]   [proj_in=string]   [proj_out=string]
[--overwrite]  [--help]  [--verbose]  [--quiet]  [--ui]

๐ŸŽ€ FLAGS (the little switches, she's obsessed) ๐ŸŽ€

  • -i โ€” use LL WGS84 as the input and your current location as the output projection. it's giving "i have lat/long, pls make it map-shaped" ๐Ÿซถ
  • -o โ€” the other way around: use your current location as input and LL WGS84 as output ๐ŸŒธ
  • -d โ€” output long/lat in decimal degrees, or use it for other projections when you want many decimal places ๐Ÿ”ฅ
  • -e โ€” include the input coordinates in the output file ๐Ÿ“
  • -c โ€” include column names in the output file โญ
  • --overwrite โ€” allow output files to overwrite existing files (chaotic, but permitted) ๐Ÿ’€
  • --help โ€” print usage summary ๐Ÿ™ˆ
  • --verbose โ€” verbose module output (she tells you EVERYTHING) ๐Ÿ‘‘
  • --quiet โ€” quiet module output ๐Ÿคซ
  • --ui โ€” force launching the GUI dialog โœจ

๐Ÿฆ‹ PARAMETERS ๐Ÿฆ‹

  • coordinates=east,north โ€” the input coordinates you want reprojected ๐Ÿ“
  • input=name โ€” name of the input coordinate file. use '-' for standard input ๐Ÿ’ซ
  • output=name โ€” name for the output coordinate file (just omit it and she sends everything to <cyan>stdout</cyan>) ๐ŸŒˆ
  • separator=character โ€” field separator, formatted as input[,output]. special characters you can use: pipe, comma, space, tab, newline. Default: pipe ๐Ÿงš
  • proj_in=string โ€” input projection parameters, PROJ.4 style ๐Ÿ’œ
  • proj_out=string โ€” output projection parameters, PROJ.4 style ๐Ÿ’œ

๐Ÿ’– DESCRIPTION ๐Ÿ’–

okay so here's the whole vibe: this program lets you convert coordinates from one projection to another. you can read coordinates from one file, convert them, and write the results to another file. OR, if you set input=-, you can pass eastings and northings straight to the program from standard input ๐Ÿซถ. and if you just... don't give an output option? she sends the results directly to standard output. so in that way, m.proj is basically a simple frontend to the PROJ cs2cs utility โญ. the -i or -o flags make it especially easy for the super common problem of converting to or from lat/long WGS84 โœจ

Note: this program does NOT transform GRASS maps, bestie. she's designed to determine the equivalent coordinate values of an individual position or a list of positions. use v.proj to reproject vector maps, or r.proj for raster maps ๐Ÿ—บ๏ธ

for an introduction to map projections (with PROJ), see the manual page of r.proj ๐Ÿ“š


๐ŸŒธ NOTES (the fine print, but make it fashion) ๐ŸŒธ

cs2cs expects input data to be formatted as x y, so if you're working with latitude-longitude data, be sure to send the x value first โ€” i.e. longitude latitude. output data will be exported using the same convention, periodt ๐Ÿ’…

cs2cs will treat a third data column as a z value (elevation) and will modify the value accordingly. this usually translates into small but real differences in that data column ๐Ÿ˜ญ

cs2cs does not expect the input stream to contain column headings โ€” only numbers. so if your data file has lines you wish to have passed through without being processed, they must start with the '#' character ๐ŸŽ€

if you're sending m.proj data from standard input, be aware of this: the data is first stored to a temporary file before being processed with cs2cs. so it is therefore not advisable to send m.proj data from an open data stream ๐Ÿ’€. the module will stop listening for incoming data after 2 seconds of inactivity. in that case, you may use the projection parameters gleaned from m.proj's verbose mode (--verbose) with cs2cs directly ๐Ÿ‘‘

custom projection parameters can be used via the proj_in and proj_out options ๐Ÿ› ๏ธ. full documentation of the projection parameter format may be found on the PROJ website. using these options will fully override the default parameters the module would normally use ๐Ÿ˜ฎ

by using the --verbose verbose flag, you can see exactly what projection parameters will be used in the conversion, plus some other informative messages ๐Ÿ”

if output is to lat/long, it will be formatted using PROJ's Degree:Minute:Second (DMS) convention of DDDdMM'SSS.SS"H. this can be handy if you wish to quickly convert lat/long decimal degree data into its DMS equivalent โœจ

alternatively, to have m.proj output data in decimal degrees, use the -d flag. this flag can also be used with non-lat/long data to force a higher number of decimal places (the cs2cs default is 2) ๐Ÿ”ข

note that lat/long output can be converted to GRASS's DMS convention (DDD:MM:SSS.SSSH) by piping the results of m.proj through the sed stream editor as follows:

m.proj -o ... | sed -e โ€™s/d/:/gโ€™ -e "s/โ€™/:/g"  -e โ€™s/"//gโ€™

๐Ÿ”ฅ EXAMPLES ๐Ÿ”ฅ

the examples are suitable for the North Carolina sample dataset if not stated otherwise ๐ŸŒฒ

๐ŸŒˆ Reproject vector point coordinate pairs to Long/Lat WGS84

the m.proj module is designed to work seamlessly with point data exported from the GIS with v.out.ascii, as the following example shows ๐Ÿ’ซ

# Long/Lat WGS84 output in DMS
v.out.ascii bridges | m.proj -o input=-
# Long/Lat WGS84 output in decimal degree
v.out.ascii bridges | m.proj -o -d input=-

๐Ÿ’œ Reproject Long/Lat WGS84 coordinate pair to current map projection

to convert a Long/Lat WGS84 coordinate pair to the current map CRS using the -i flag โ€” which sets the target projection parameters automatically from the current project definition ๐Ÿ“:

echo "-78.61168178 33.92225767" | m.proj -i input=-
645513.47|19180.31|0.00

the same, but load points from a file named waypoints.txt and continue on to import the results into a GRASS vector points map in the current map projection ๐Ÿซถ:

# check file content
cat waypoints.txt
-78.43977824 33.89587173
-78.54944691 33.88964566
-78.51078074 33.88141495
-77.14037951 35.60543020
# reproject points and generate vector map on the fly
m.proj -i input=waypoints.txt | v.in.ascii input=- output=test_pnts
# verify result
v.db.select test_pnts cat|dbl_1|dbl_2|dbl_3
1|661427.74|16329.14|0
2|651285.43|15586.79|0
3|654867.21|14690.64|0
4|778074.58|207402.6|0

๐ŸŽ€ Custom projection parameter usage

to transform points from a UTM projection (here specified with a detailed projection definition rather than using an EPSG code) into the Gauss-Krรผger Grid System, importing from and exporting to files ๐Ÿ“:

m.proj proj_in="+proj=utm +name=utm +a=6378137.0 +es=0.006694380 \
    +zone=32 +unfact=1.0" proj_out="+proj=tmerc +name=tmerc \
    +a=6377397.155 +es=0.0066743720 +lat_0=0.0 +lon_0=9.0 +k=1.0 \
    +x_0=3500000.0" input=utm.coord.txt output=new.gk.coord.txt

projection parameters provided in the above case, decoded for you bestie ๐Ÿ“–:

  • +proj โ€” projection type
  • +name โ€” projection name
  • +a โ€” ellipsoid: equatorial radius
  • +es โ€” ellipsoid: eccentricity squared
  • +zone โ€” zone for the area
  • +unfact โ€” conversion factor from meters to other units, e.g. feet
  • +lat_0 โ€” standard parallel
  • +lon_0 โ€” central meridian
  • +k โ€” scale factor
  • +x_0 โ€” false easting

sometimes false northing is needed, which is coded as +y_0. internally, the underlying PROJ projection library performs an inverse projection to latitude-longitude and then projects the coordinate list to the target projection ๐ŸŒ€

datum conversions are automatically handled by the PROJ library if +datum settings are specified on both the input and output projections on the command line. the +towgs84 parameter can be used to define either 3 or 7 term datum transform coefficients, satisfying this requirement ๐Ÿงฎ

if a datum is specified there is no need for the +ellps= or underlying parameters, +a=, +es=, etc. ๐Ÿ’…

another custom parameter usage example:

m.proj proj_in="+proj=tmerc +datum=ire65 +lat_0=53.5 +lon_0=-8 +x_0=200000 \
    +y_0=250000 +k=1.000035" proj_out="+proj=ll +datum=wgs84" input=wpt.txt

or without datum transformation:

m.proj proj_in="+proj=tmerc +ellps=modif_airy +lat_0=53.5 +lon_0=-8 +x_0=200000 \
    +y_0=250000 +k=1.000035" proj_out="+proj=ll +datum=wgs84" input=wpt.txt

in this example no datum transformation will take place as a datum was not specified for the input projection ๐Ÿ˜ญ. the datum specified for the output projection will thus be silently ignored and may be left out; all that is achieved is a simple conversion from projected to geodetic co-ordinates, keeping the same datum (and thus also the same ellipsoid) ๐Ÿซถ

for more usage examples, see the documentation for the PROJ cs2cs program ๐Ÿ“š


โญ REFERENCES โญ

  • Evenden, G.I. (1990) Cartographic projection procedures for the UNIX environment - a user's manual. USGS Open-File Report 90-284 (OF90-284.pdf) See also there: Interim Report and 2nd Interim Report on Release 4, Evenden 1994).
  • PROJ Cartographic Projection Library

๐Ÿ‘€ SEE ALSO ๐Ÿ‘€

g.proj, r.proj, v.proj, i.rectify, v.in.ascii, v.out.ascii


๐Ÿ’… AUTHOR ๐Ÿ’…

M. Hamish Bowman, Dept. Marine Science, Otago University, New Zealand ๐ŸŒŠ

Functionality inspired by the m.proj and m.proj2 modules for GRASS GIS 5 โœจ


๐Ÿซถ SOURCE CODE ๐Ÿซถ

Available at: m.proj source code (history)

Latest change: Tuesday Oct 21 09:57:14 2025 in commit: fb0165c2d021b7700528aca09c224847be871729

Main index | Miscellaneous 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 ๐Ÿฅน๐Ÿ’– m.proj(1grass) from the GRASS 8.5.0 manual, latest change Tuesday Oct 21 09:57:14 2025, ยฉ 2003-2026 GRASS Development Team. go reproject something slay ๐Ÿ’…โœจ

๐Ÿ“ฆ where this page comes from