#gis #csv #coordinates #convert #mgrs

app mgrs2latlong

A command-line tool for converting MGRS coordinates to latitude/longitude in CSV files

1 unstable release

0.1.0 Aug 27, 2025

#1976 in Command line utilities

MIT/Apache

8KB
101 lines

MGRS to Lat/Long Converter

A Rust command-line tool for converting MGRS (Military Grid Reference System) coordinates to latitude/longitude in CSV files.

Author

Albert Hui albert@securityronin.com

Features

  • Automatically detects MGRS coordinate columns in CSV files
  • Converts MGRS coordinates to decimal latitude/longitude
  • Preserves original data while adding new latitude and longitude columns
  • Supports flexible MGRS format recognition
  • Command-line interface with input/output file options

Installation

Ensure you have Rust installed, then build the project:

cargo build --release

Usage

# Convert MGRS coordinates in input.csv and write to output.csv
./target/release/mgrs2latlong input.csv --output output.csv

# Convert and output to stdout
./target/release/mgrs2latlong input.csv

Input Format

The tool accepts CSV files with MGRS coordinates in any column. MGRS coordinates should follow the standard format (e.g., "33TWM1234567890" or "33T WM 12345 67890").

Output Format

The tool outputs a CSV file with:

  • All original columns preserved
  • Additional latitude column with decimal degrees
  • Additional longitude column with decimal degrees

Dependencies

  • clap - Command-line argument parsing
  • csv - CSV file handling
  • regex - Pattern matching for MGRS detection
  • geoconvert - MGRS coordinate conversion
  • anyhow - Error handling

License

This project is open source.

Dependencies

~4.5–7MB
~109K SLoC