Skip to content

Instantly share code, notes, and snippets.

@mdbauman
mdbauman / Albers.class.php
Created March 1, 2017 22:16
Albers Equal Area Conic projection in PHP
<?php
//based on albers.js by Tom Carden https://gist.github.com/RandomEtc/476238
//ex. for a 954.66669*601.46283pt SVG of contiguous US, I used:
// $albers = new Albers([23.0,-96.0], [29.5, 45.5]);
// $coords = $albers->project($lat,$long);
// $coords = ['x'=>$coords['x']*1315+485, 'y'=>$coords['y']*1315+654]; //scale and translate
class Albers{
private static $origin, $parallels, $n, $c, $C, $p0, $lat0, $lng0, $phi1, $phi2;
private $t, $p;