wiki:WikiStart/Ruby/Georeference

You need to install GDAL/Ruby 1.8 bindings.

On Debian/Ubuntu:

sudo apt-get install libgdal-ruby1.8

Example script, to convert from lat/long in WGS84 into UTM coordinates

require 'gdal/osr'
from = Gdal::Osr::SpatialReference.new
from.set_well_known_geog_cs('WGS84')
to   = Gdal::Osr::SpatialReference.new
to.set_well_known_geog_cs('WGS84')
to.set_utm(32, 1) # UTM band 32, north

transform = Gdal::Osr::CoordinateTransformation.new(from, to)

Then, you can do the convertion with

x, y, z = transform.transform_point(longitude, latitude, altitude)
Last modified 8 years ago Last modified on 04/08/11 17:59:19