Geo::H...ansform(3pm)

πŸ“¦
version 1.14 Β· 2 versions
  • 1.14 Β· debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking (latest)
  • 1.14 Β· ubuntu jammy
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

✨ Geo::HelmertTransform β€” the manual, but make it make sense ✨

okay bestie so this is Geo::HelmertTransform(3pm), a Perl module that does Helmert transformations between coordinates, and it is genuinely so much less scary than the name suggests, i promise 🫢


πŸ’– VERSION πŸ’–

1.14 β€” that's the one, that's the version, no cap.


🌸 SYNOPSIS 🌸

here's the vibe, copy-paste energy:

use Geo::HelmertTransform;

my ($lat, $lon, $h) = ...; # from OS map
my $airy1830 = Geo::HelmertTransform::datum('Airy1830');
my $wgs84 = Geo::HelmertTransform::datum('WGS84');

($lat, $lon, $h)
    = Geo::HelmertTransform::convert_datum($airy1830, $wgs84,
                                            $lat, $lon, $h);

literally that's it. you grab a datum, you grab another datum, you hand it your coords, it hands them back in the new datum. iconic behavior honestly πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

so the whole point of this module: it transforms geographical coordinates between different datums.

here's the lore. we usually describe geographical points as polar coordinates β€” latitude, longitude and altitude β€” referenced to a "datum ellipsoid", which is basically a shape we use to approximate the Earth's geoid. and the way that the latitude, longitude and altitude of one single physical point change depending on which datum ellipsoid you're using? yeah. not it. because unfortunately a bunch of ellipsoids are in everyday use, so you constantly have to transform geographical coordinates between different datum ellipsoids. it's giving "why is there more than one, bestie" 😭

two different datum ellipsoids can differ in where their centers are, or in their shape β€” and there might even be an angle between their equatorial planes, or between the meridians that longitude gets measured relative to. the Helmert Transform, which this module implements, is a linear transformation of coordinates between pairs of datum ellipsoids, in the limit of small angles of deviation between them.

translation: it's the small-angle approximation version, bestie. don't come at it with huge deviations.

πŸŽ€ CONVENTIONS πŸŽ€

  • Latitude is in degrees, positive-north.
  • Longitude is in degrees, positive-east.
  • Heights (ellipsoid) and cartesian coordinates are in meters.

that's it, that's the whole section, but you needed it, i promise πŸ™ˆ


🌈 FUNCTIONS 🌈

rad_to_deg RADIANS

converts RADIANS to degrees. little conversion moment, very demure πŸŽ€

deg_to_rad DEGREES

converts DEGREES to radians. the other direction, as the name strongly implies.

geo_to_xyz DATUM LAT LON H

give it the geographical coordinates (LAT, LON, H) in the given DATUM and it returns the Cartesian (X, Y, Z) coordinates for them. 🧚

xyz_to_geo DATUM X Y Z

the reverse glow-up: returns the geographical (LAT, LON, H) coordinates for the Cartesian coordinates (X, Y, Z) in the given DATUM. heads up β€” this is an iterative procedure. it's not doing one clean solve, it's looping its way there, and you should know that going in.

convert_datum D1 D2 LAT LON H

the main character of this whole module honestly πŸ‘‘ give it geographical coordinates (LAT, LON, H) in datum D1 and it returns the corresponding coordinates in datum D2. caveat bestie: this assumes that the transformations are small, and it always converts via WGS84 β€” like, it doesn't go direct, it routes through WGS84 every single time. iykyk.

datum NAME

returns the datum of the given NAME. currently implemented are these three and only these three:

  • Airy1830 β€” the 1830 Airy ellipsoid, which the British Ordnance Survey's National Grid is referenced to.
  • Airy1830Modified β€” the modified 1830 Airy ellipsoid, which the Irish Grid is referenced to (as used by Ordnance Survey Ireland and Ordnance Survey Northern Ireland). also known as the Ireland 1975 datum. two names, one ellipsoid, we love a rebrand πŸ’–
  • WGS84 β€” the global datum used for GPS. the famous one. the celebrity.

πŸ”₯ SEE ALSO πŸ”₯

go read them, they're the receipts for everything above πŸ“š


Written by Chris Lightfoot, team@mysociety.org πŸ’Œ

Copyright (c) UK Citizens Online Democracy.

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. so go off, remix it, slay responsibly ✨


ngl the license here is the chillest one possible and we stan that for it 🌸

and that's a wrap bestie β€” perl v5.36.0, dated 2022-11-20, and this whole thing was Geo::HelmertTransform(3pm). take care of your datums, drink water, and remember: always converting via WGS84 πŸ’…πŸ¦‹