Bidirectional UTM-WGS84 converter for golang :earth_africa: :globe_with_meridians:

Build Status Coverage Status GoDoc

UTM

Bidirectional UTM-WGS84 converter for golang. It use logic from UTM python version by Tobias Bieniek

Usage

go get github.com/im7mortal/UTM

Convert a latitude, longitude into an UTM coordinate

	easting, northing, zoneNumber, zoneLetter, err := UTM.FromLatLon(40.71435, -74.00597, false)

Convert an UTM coordinate into a latitude, longitude.

	latitude, longitude, err := UTM.ToLatLon(377486, 6296562, 30, "V")

Since the zone letter is not strictly needed for the conversion you may also the northern parameter instead, which is a named parameter and can be set to either true or false. In this case you should define fields clearly(!). You can't set ZoneLetter or northern both.

	latitude, longitude, err := UTM.ToLatLon(377486, 6296562, 30, "", false)

The UTM coordinate system is explained on this Wikipedia page

Speed

Benchmark Amount of iterations Average speed
ToLatLon 10000000 123 ns/op
ToLatLonWithNorthern 10000000 121 ns/op
FromLatLon 20000000 80.6 ns/op

go test -bench=.

Full example

package main

import (
	"github.com/im7mortal/UTM"
	"fmt"
)

func main() {

	easting, northing, zoneNumber, zoneLetter, err := UTM.FromLatLon(40.71435, -74.00597, false)
	if err != nil {
		panic(err.Error())
	}
	fmt.Println(
		fmt.Sprintf(
			"Easting: %d; Northing: %d; ZoneNumber: %d; ZoneLetter: %s;",
			easting,
			northing,
			zoneNumber,
			zoneLetter,
		))

	easting, northing, zoneNumber, zoneLetter, err = UTM.FromLatLon(40.71435, -74.00597, true)
	if err != nil {
		panic(err.Error())
	}
	fmt.Println(
		fmt.Sprintf(
			"Easting: %d; Northing: %d; ZoneNumber: %d; ZoneLetter: %s;",
			easting,
			northing,
			zoneNumber,
			zoneLetter,
		))

	latitude, longitude, err := UTM.ToLatLon(377486, 6296562, 30, "", true)
	fmt.Println(fmt.Sprintf("Latitude: %.5f; Longitude: %.5f;", latitude, longitude))

	latitude, longitude, err = UTM.ToLatLon(377486, 6296562, 30, "V")
	fmt.Println(fmt.Sprintf("Latitude: %.5f; Longitude: %.5f;", latitude, longitude))

}

Authors

Owner
Petr
Science fan. DIY enthusiast.
Petr
Similar Resources

Markdown - Markdown converter for golang

markdown ๐Ÿ—ฃ Talks ๐Ÿ’ฌ Join ๐Ÿฉธ Youtube โค๏ธ Sponsor Install via nami nami install ma

Jun 2, 2022

Numtow - Golang number to words converter

numtow golang library to convert number to words. Supported languages: kazakh, e

Dec 31, 2022

Simple ANSi to PNG converter written in pure Go

AnsiGo Description AnsiGo is a simple ANSi to PNG converter written in pure Go. It converts files containing ANSi sequences (.ANS) into PNG images. Fo

May 17, 2022

A CLI markdown converter written in Go.

MDConv is a markdown converter written in Go. It is able to create PDF and HTML files from Markdown without using LaTeX. Instead MDConv u

Dec 20, 2022

Client for KCORES CSPS to ATX Converter

Client for KCORES CSPS to ATX Converter

KCORES Link ๆ่ฟฐ ่ฏฅ KCORES Link ่ฝฏไปถๆ˜ฏไธบ KCORES CSPS to ATX Converter (CSPS่ฝฌATX่ฝฌๆขๅ™จ) ่€Œ็ผ–ๅ†™็š„่ฝฏไปถ็•Œ้ข, ้€š่ฟ‡ๆŽฅๅ…ฅไธฒๅฃ้€šไฟก่ฏปๅ–CSPS่พ“ๅ‡บ็š„ไฟกๆฏ, ๆœ€็ปˆๅฎžๆ—ถๅฑ•็คบๅˆฐWEB็•Œ้ขไธŠ. ไธ‹่ฝฝๅนถ่ฟ่กŒ Windows ็”จๆˆท็›ดๆŽฅไธ‹่ฝฝๆœฌ้กน็›ฎ, ่ฟ่กŒ

Dec 23, 2022

go-playground-converter is formatter error response inspiration like express-validator in nodejs build on top go-playground-validator.

Go Playground Converter go-playground-converter is formatter error response inspiration like express-validator in nodejs build on top in go-playground

Dec 9, 2022

Hugo-to-Gemini Markdown converter

Hugo-to-Gemini converter This repo holds a converter of Hugo Markdown posts to text/gemini (also named Gemtext in this README). The converter is suppo

Nov 19, 2022

Universal JSON, BSON, YAML, CSV, XML converter with templates

Universal JSON, BSON, YAML, CSV, XML converter with templates

Universal JSON, BSON, YAML, CSV, XML translator to ANY format using templates Key features Various input formats (json, bson, yaml, csv, xml) Flexible

Dec 11, 2022

Simple Markdown to Html converter in Go.

Markdown To Html Converter Simple Example package main import ( "github.com/gopherzz/MTDGo/pkg/lexer" "github.com/gopherzz/MTDGo/pkg/parser" "fm

Jan 29, 2022

PCM converter - Resample part relies on SOXR.

Resample part relies on SOXR. To install make sure you have libsoxr installed, then run: go get -u github.com/ZhangJYd/pcm_convertor example: package

Nov 23, 2021

Quick and dirty Minecraft player head to SVG converter

Head SVG Quick and dirty Minecraft player head to SVG converter. Can be used to generate player head icons. Usage usage: Head SVG [-h|--help] -n|--nam

May 29, 2022

Link converter service converts URLs to deeplinks or deeplinks to URLs.

Link converter Link converter service converts URLs to deeplinks or deeplinks to URLs. The service responds to the incoming request and first checks w

Dec 23, 2021

Serial to Keyboard converter for Polar's card readers

polar-serial-to-keyboard Serial to Keyboard converter for Polar's card readers Configuration This program is intended to be run as a background proces

Dec 17, 2021

Eightbit - A converter to create shitty 8-bit like images

eightbit A converter to create shitty 8-bit like images. Usage To install: go in

Jan 8, 2022

Very simple SVG to PNG converter library using the Inkscape.

svg2png Description Very simple SVG to PNG converter library using the Inkscape.

Jan 11, 2022

JPEG-MPO Decoder / Converter Library and CLI Tool

MPO Decoder Library Simple Go JPEG MPO (Multi Picture Object) Decoder - Library and CLI Tool The library and CLI tool contain the ability to convert M

Sep 26, 2022

Typescript type declaration to PostgreSQL CREATE TABLE converter

ts2psql NOTE: This is WIP. Details in this readme are ideal state. Current usage: go build && ./ts2psql (or go build && ts2psql if on Windows OS). A s

Jan 13, 2022

hls converter.

hlsconv hls converter. ๅค–้ƒจไพ่ต– ffmpeg: 4.2.1 ไฝฟ็”จๆ–นๅผ linix/macos # ่ฝฌๆขๅ•ไธชๆ–‡ไปถ bin/hlsconv -i video/in.mp4 -o outvideo/ # ๆ‰น้‡่ฝฌๆขๆ–‡ไปถ bin/hlsconv -i video/ -o outvide

Jan 15, 2022

T80nxbt - Thurastmaster-T80 to ProCon Converter

t80nxbt Thurastmaster-T80 to ProCon Converter. connection T80----usb----Raspberr

Jan 30, 2022
Go (golang) wrapper for GDAL, the Geospatial Data Abstraction Library

------------- About ------------- The gdal.go package provides a go wrapper for GDAL, the Geospatial Data Abstraction Library. More information about

Dec 24, 2022
OpenStreetMap PBF golang parser

pbf OpenStreetMap PBF golang encoder/decoder A golang based OpenStreetMap PBF encoder/decoder with a handy command line utility, pbf. pbf Command Line

Oct 23, 2022
Totem - A Go library that can turn a single gRPC stream into bidirectional unary gRPC servers

Totem is a Go library that can turn a single gRPC stream into bidirectional unar

Jan 6, 2023
XML to MAP converter written Golang

xml2map XML to MAP converter written Golang Sometimes there is a need for the representation of previously unknown structures. Such a universal repres

Dec 8, 2022
Golang HTML to PDF Converter
Golang HTML to PDF Converter

Golang HTML to PDF Converter For reading any document, one prefers PDF format over any other formats as it is considered as a standard format for any

Dec 15, 2022
โ˜„ The golang convenient converter supports Database to Struct, SQL to Struct, and JSON to Struct.
โ˜„ The golang convenient converter supports Database to Struct, SQL to Struct, and JSON to Struct.

Gormat - Cross platform gopher tool The golang convenient converter supports Database to Struct, SQL to Struct, and JSON to Struct. ไธญๆ–‡่ฏดๆ˜Ž Features Data

Dec 20, 2022
Video converter with golang

Requirements Debian-like system (ubuntu, mint, etc...) with apt package manager Golang >1.15 Command tool make (use sudo apt install make -y to instal

Sep 10, 2022
Ethconvert: Ethereum unit converter written in golang

ethconvert Ethereum unit converter written in go. Install go get github.com/jon4

Jul 24, 2022