# Calculating Distance in the Lambert Conformal Conic projection vs WGS84/GDA94

## Lambert Conformal Conic 2 Standard Parallels

This projection is commonly used around the world. An example is the NSW Lambert projection.

The definition of the projection is described here.

Note that “[the] two standard parallels […] maintain exact scale, while the scale varies along the meridians” being reduced between the parallels and increased beyond them.

### Use Case

I worked on a national (Australia) scale database which stored its data in a LCC projection. What was not understood by those who chose the projection was the distance/scale issue.

When accurate distances were required the application had to project the data into a geographic SRID (4283), compute the distance/length, and then throw away the projected data (a run-time penalty).

If the database had been defined to use a geographic SRID in the first place this additional processing could have been avoided.

## Examples

The question of scale difference can be easily demonstrated using PostGIS.

### Lines along parallels

Firstly we calculate distance along parallels including the two standard parallels for the NSW Lambert projection.

```-- NSW Lambert
-- -30.75 is standard_parallel_1 (latitude)
-- -35.75 is standard_parallel_2 (latitude)
-- Length along parallel should be same.
select round(latitude,2) as latitude,
round(ST_Length(line,true)::numeric,3) as llLength,
round(ST_Length(ST_Transform(line,3308))::numeric,3) as lamLength,
round(ABS(ST_Length(line,true)::numeric - ST_Length(ST_Transform(line,3308))::numeric),3) as diff
from (select gs::decimal/100.0 as latitude,
ST_GeomFromEWKT('SRID=4283;LINESTRING(139.0 '||gs::decimal/100.0||',141.0 '||gs::decimal/100.0||')') as line
from generate_series(-4075,-2575,100) as gs
) as f;
```
latitudelllengthlamlengthdiff
-40.75168900.910170231.9091330.999
-39.75171405.356172372.050966.694
-38.75173857.373174507.424650.051
-37.75176256.234176638.748382.514
-36.75178601.231178766.725165.494
-35.75180891.670180892.0430.372
-34.75183126.877183015.379111.498
-33.75185306.192185137.399168.794
-32.75187428.976187258.759170.217
-31.75189494.604189380.109114.496
-30.75191502.471191502.0880.383
-29.75193451.989193625.335173.347
-28.75195342.586195750.480407.894
-27.75197173.711197878.152704.441
-26.75198944.828200008.9771064.148
-25.75200655.423202143.5791488.156

Note here that lines along the two standard parallels are, effectively, equal (as predicted) with parallels between and beyond the parallels being unequal.

### Lines of random direction

```-- Random linestrings
-- Projected Bounds: 8709235.6860, 4009911.3943, 9951732.0554, 5048642.3129
with data as (
select 8709235.6860 as llx, 4009911.3943 as lly, 9951732.0554 as urx, 5048642.3129 as ury
)
select round(g.lamLength::numeric,3) as LamLength,
round(g.llLength::numeric,3) as LLLength,
round(ABS(g.lamLength-g.llLength)::numeric,3) as diff,
ST_Transform(g.line,4283)::geography as line
from (select ST_Length(f.line) as lamLength,
ST_Length(ST_Transform(f.line,4283)::geography,true) as llLength,
line
from (select gs as id,
ST_SetSrid(
ST_MakeLine(ST_MakePoint(spdba.random_between(llx,urx),
spdba.random_between(lly,ury)),
ST_MakePoint(spdba.random_between(llx,urx),
spdba.random_between(lly,ury))
),3308) as line
from data,
generate_series(1,10,1) as gs
) as f
) as g;
```
lamlengthlllengthdiffline
754406.739754650.329243.5900102000020BB10000002000000CA37AE7EDB4B62404759EA5666303DC0CC214EA682EF614037E5A12907C541C0