Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
G

geodist

> 编程语言
Open source

Golang package to compute the distance between two geographic latitude, longitude coordinates

192 stars0 likes1 views
WebsiteGitHub

About

Golang package to compute the distance between two geographic latitude, longitude coordinates

geodist

GoLang package to compute the distance between two geographic latitude, longitude coordinates

Algorithm Comparison

  • Vincenty is more accurate than Haversine because is considers the Earth's ellipticity when performing the calculation, but takes a longer time to compute.
  • Wikipedia: Haversine
  • Wikipedia: Vincenty
  • Is the Haversine Formula or the Vincenty's Formula better for calculating distance?

Example

  • example.go
go
	var newYork = geodist.Coord{Lat: 40.7128, Lon: 74.0060}
	var sanDiego = geodist.Coord{Lat: 32.7157, Lon: 117.1611}
	miles, km, ok := geodist.VincentyDistance(newYork, sanDiego)
	if !ok {
		fmt.Println("Unable to compute Vincenty Distance.")
		return
	}
	fmt.Printf(" [Vincenty] New York to San Diego: %.3f m, %.3f km\n", miles, km)

	var elPaso = geodist.Coord{Lat: 31.7619, Lon: 106.4850}
	var stLouis = geodist.Coord{Lat: 38.6270, Lon: 90.1994}
	miles, km = geodist.HaversineDistance(elPaso, stLouis)
	fmt.Printf("[Haversine] El Paso to St. Louis:  %.3f m, %.3f km\n", miles, km)

Online Calculators

  • Great Circle: NOAA: Latitude/Longitude Distance Calculator
  • Haversine: Moveable Type: Calculate distance, bearing and more between Latitude/Longitude points
  • Vincenty: CQSRG: WGS-84 World Geodetic System Distance Calculator

Acknowledgements

  • Haversine Algorithm in GoLang
  • Vincenty Algorithm in JavaScript

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Godistancegeolocationgogolang

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 18, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言