Skip to content
forked from tallakt/geoutm

Conversion between latitude/longitude coordinates to UTM

License

Notifications You must be signed in to change notification settings

erlingwl/geoutm

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NAME

GeoUtm

SYNOPSIS

require 'geoutm'

coordinate = LatLon.new 100.0 100.0
utm_coord = coordinate.to_utm
reverse = utm_coord.to_lat_lon

INSTALL

sudo gem sources -a http://gems.github.com
sudo gem install tallakt-geoutm

DESCRIPTION

This module will translate latitude longitude coordinates to Universal Transverse Mercator(UTM) coordinates and vice versa.

This is a shameless port of the Perl library Geo::Coordinates::UTM written by Graham Crookham. Most text is copied directly from this library, adapted to ruby syntax.

Mercator Projection

The Mercator projection was first invented to help mariners. They needed to be able to take a course and know the distance traveled, and draw a line on the map which showed the day’s journey. In order to do this, Mercator invented a projection which preserved length, by projecting the earth’s surface onto a cylinder, sharing the same axis as the earth itself. This caused all Latitude and Longitude lines to intersect at a 90 degree angle, thereby negating the problem that longitude lines get closer together at the poles.

Transverse Mercator Projection

A Transverse Mercator projection takes the cylinder and turns it on its side. Now the cylinder’s axis passes through the equator, and it can be rotated to line up with the area of interest. Many countries use Transverse Mercator for their grid systems.

Universal Transverse Mercator

The Universal Transverse Mercator(UTM) system sets up a universal world wide system for mapping. The Transverse Mercator projection is used, with the cylinder in 60 positions. This creates 60 zones around the world. Positions are measured using Eastings and Northings, measured in meters, instead of Latitude and Longitude. Eastings start at 500,000 on the centre line of each zone. In the Northern Hemisphere, Northings are zero at the equator and increase northward. In the Southern Hemisphere, Northings start at 10 million at the equator, and decrease southward. You must know which hemisphere and zone you are in to interpret your location globally. Distortion of scale, distance, direction and area increase away from the central meridian.

UTM projection is used to define horizontal positions world-wide by dividing the surface of the Earth into 6 degree zones, each mapped by the Transverse Mercator projection with a central meridian in the center of the zone. UTM zone numbers designate 6 degree longitudinal strips extending from 80 degrees South latitude to 84 degrees North latitude. UTM zone characters designate 8 degree zones extending north and south from the equator. Eastings are measured from the central meridian (with a 500 km false easting to insure positive coordinates). Northings are measured from the equator (with a 10,000 km false northing for positions south of the equator).

UTM is applied separately to the Northern and Southern Hemisphere, thus within a single UTM zone, a single X / Y pair of values will occur in both the Northern and Southern Hemisphere. To eliminate this confusion, and to speed location of points, a UTM zone is sometimes subdivided into 20 zones of Latitude. These grids can be further subdivided into 100,000 meter grid squares with double-letter designations. This subdivision by Latitude and further division into grid squares is generally referred to as the Military Grid Reference System (MGRS). The unit of measurement of UTM is always meters and the zones are numbered from 1 to 60 eastward, beginning at the 180th meridian. The scale distortion in a north-south direction parallel to the central meridian (CM) is constant However, the scale distortion increases either direction away from the CM. To equalize the distortion of the map across the UTM zone, a scale factor of 0.9996 is applied to all distance measurements within the zone. The distortion at the zone boundary, 3 degrees away from the CM is approximately 1%.

Datums and Ellipsoids

Unlike local surveys, which treat the Earth as a plane, the precise determination of the latitude and longitude of points over a broad area must take into account the actual shape of the Earth. To achieve the precision necessary for accurate location, the Earth cannot be assumed to be a sphere. Rather, the Earth’s shape more closely approximates an ellipsoid (oblate spheroid): flattened at the poles and bulging at the Equator. Thus the Earth’s shape, when cut through its polar axis, approximates an ellipse. A “Datum” is a standard representation of shape and offset for coordinates, which includes an ellipsoid and an origin. You must consider the Datum when working with geospatial data, since data with two different Datum will not line up. The difference can be as much as a kilometer!

EXAMPLES

A description of the available ellipsoids and sample usage of the conversion routines follows

Ellipsoids

The Ellipsoids available are as follows:

  1. Airy

  2. Australian National

  3. Bessel 1841

  4. Bessel 1841 Nambia

  5. Clarke 1866

  6. Clarke 1880

  7. Everest 1830 India

  8. Everest 1830 Malaysia

  9. Everest 1956 India

  10. Everest 1964 Malaysia and Singapore

  11. Everest 1969 Malaysia

  12. Everest Pakistan

  13. Fischer 1960 Mercury

  14. Fischer 1968

  15. GRS 1967

  16. GRS 1980

  17. Helmert 1906

  18. Hough

  19. Indonesian 1974

  20. International

  21. Krassovsky

  22. Modified Airy

  23. Modified Everest

  24. Modified Fischer 1960

  25. South American 1969

  26. WGS 60

  27. WGS 66

  28. WGS-72

  29. WGS-84

ellipsoid_names

The ellipsoids can be accessed using

GeoUtm::Ellipsoid::list_names

Alternatively

GeouUtm::Ellipsoid::each {|ellipsoid| ... }

When converting to and from UTM coordinates, the ellipsoid is specified as a parameter which defaults to WGS-84. To use another ellipsoid, use

coord.to_utm Ellipsoid::lookup :wgs60

The name is not case sensitive and symbols are allowed. Spaces and - are ignored.

Latitude / longitude to UTM conversion

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

AUTHOR

Graham Crookham, grahamc@cpan.org

Ruby port by Tallak Tveide 2009

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.

About

Conversion between latitude/longitude coordinates to UTM

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Ruby 100.0%