Tool for converting coordinates between different global charting systems.
This tool uses PROJ.4 via the proj4rb gem to convert coordinates between global charting systems with different projections.
Global Convert was greatly influenced by Peter Hick’s blog: Converting OSGB36 (Eastings/Northings) to WGS84 (Longitude/Latitude) in Ruby
Peter Hick’s blog was itself based on Harry Wood’s blog: Ruby code for converting to UK Ordnance Survey coordinate systems from WGS84?
Global Convert is releases as a gem. So either:
gem install 'global_convert'
or add this to your Gemfile:
gem 'global_convert'
require 'global_convert' easting = 529978 northing = 186491 location = GlobalConvert::Location.new( input: { projection: :osgb36, lon: easting, lat: northing }, output: { projection: :wgs84 } ) puts "Latitude = #{location.lat} in radians." puts "Longitude = #{location.lon} in radians."
If you need to start from an OS Map Reference, rather than Eastings and Northings another gem os_map_ref can be used to convert the map reference to eastings and northings.
Projections are defined via /data/projections.yml. This contains a labelled list of PROJ.4 projection configurations. To use an alternative set of projections, define your own projections using the same format as projections.yml and register that with GlobalConvert.
GlobalConvert.projection_file_path = 'path/to/alternative/projections.yml'
Additional projection configurations can be found at:
The options are documented on the PROJ.4 site.