= Find Nearest
Commandline tool to find the nearest spatial object(s) in one file (the universe) to each spatial object in another file (the target). This tool is inspired by the Find Nearest Tool in Alteryx.
Start with implementing this for point fields.
This should use a spatial index.
CAUTION: This is Work in Progress
== Usage
----
findnearest -target [path to target] -universe [path to universe]
----
== Background information
=== GeoDistance in go.geo
The GeoDistance calculated by go.geo differs from http://www.movable-type.co.uk/scripts/latlong.html even when haversine option is set to true, because go.geo uses a more precise earth radius.
----
p1 := geo.NewPointFromLatLng(51.92125, 6.57755)
p2 := geo.NewPointFromLatLng(52.377777, 4.905169)
d1 := p1.GeoDistanceFrom(p2, true) // distance is 125024.15596760742 m
geo.EarthRadius = 6371000.0 // set earth radius to value used by movable-type or golang-geo
d2 := p1.GeoDistanceFrom(p2, true) // distance is 124884.25658928727 m or 124.88 km
----
=== Geo in Golang
https://blog.gopheracademy.com/advent-2015/geographical-data-manipulation-using-go/
https://medium.com/@buckhx/unwinding-uber-s-most-efficient-service-406413c5871d#.1ept34xfq
=== How much distance does a degree, minute and second cover on your maps?
(source https://www2.usgs.gov/faq/categories/9794/3022 )
The distances vary. A degree, minute or second of latitude remains fairly constant from the equator to the poles; however a degree, minute, or second of longitude can vary greatly as one approaches the poles (because of the convergence of the meridians). At 38 degrees North latitude, one degree of latitude equals approximately 364,000 ft (69 miles), one minute equals 6068 ft (1.15 miles), one-second equals 101 ft; one-degree of longitude equals 288,200 ft (54.6 miles), one minute equals 4800 ft (0.91 mile), and one second equals 80 ft.