GeoUtm
require 'geoutm' coordinate = GeoUtm::LatLon.new 100.0, 100.0 to_utm = coordinate.to_utm and_back = utm_coord.to_lat_lon
gem install geoutm
This gem translates between latitude and longitude coordinates to Universal Transverse Mercator(UTM) coordinates. The first kind is generally reported by GPS units, while the second is useful as they are represented in meters, thus making distance calculations easier.
For more information please refer to en.wikipedia.org/wiki/Universal_Transverse_Mercator_coordinate_system
A description of the available ellipsoids and sample usage of the conversion routines follows
Ellipsoids describe the shape of the earth used to calculate the UTM grid. As a default, WGS-84 is selected, but any of the following ellipses may be used:
-
Airy
-
Australian National
-
Bessel 1841
-
Bessel 1841 Nambia
-
Clarke 1866
-
Clarke 1880
-
Everest 1830 India
-
Everest 1830 Malaysia
-
Everest 1956 India
-
Everest 1964 Malaysia and Singapore
-
Everest 1969 Malaysia
-
Everest Pakistan
-
Fischer 1960 Mercury
-
Fischer 1968
-
GRS 1967
-
GRS 1980
-
Helmert 1906
-
Hough
-
Indonesian 1974
-
International
-
Krassovsky
-
Modified Airy
-
Modified Everest
-
Modified Fischer 1960
-
South American 1969
-
WGS 60
-
WGS 66
-
WGS-72
-
WGS-84
When specifying the ellipsoid as a parameter, you may use an instance of the GeoUtm::Ellipsoid class, a string containing the name above, or alternatively just a symbol (eg. :wgs84). The name is not case sensitive and symbols are allowed. Spaces and - are ignored.
Latitude values in the southern hemisphere should be supplied as negative values (e.g. 30 deg South will be -30). Similarly Longitude values West of the meridian should also be supplied as negative values. Both latitude and longitude should not be entered as deg,min,sec but as their decimal equivalent, e.g. 30 deg 12 min 22.432 sec should be entered as 30.2062311
The ellipsoid value should correspond to one of the numbers above, e.g. to use WGS-84, the ellipsoid value should be 23
For latitude 57deg 49min 59.000sec North
longitude 02deg 47min 20.226sec West
using Clarke 1866 (Ellipsoid 5)
utm = LatLon.new(57.803055556, -2.788951667).to_utm(Ellipsoid::lookup('clarke 1866'))
returns
utm.zone = 30V utm.e = 512533.364651484 utm.n = 6409932.13416127
This gem is heavily inspired and to a large extent also copied directly from by the Perl library Geo::Coordinates::UTM written by Graham Crookham. Graham Crookham, [email protected]
Ruby port by Tallak Tveide, Erling Linde 2009/2011
Copyright © 2000,2002,2004 by Graham Crookham. All rights reserved.
This package is free software; you can redistribute it and/or modify it under the same terms as Perl itself.