OSGeo / PROJ

PROJ - Cartographic Projections and Coordinate Transformations Library
https://proj.org
Other
1.74k stars 787 forks source link

Error with lcc 1sp when compiled under linux or cygwin #82

Closed proj4-bot closed 9 years ago

proj4-bot commented 9 years ago

Reported by jhillman on 12 Oct 2010 07:54 UTC I have finally tracked down the area of a problem I have had for a while. One of our regularly used projections is defined as follows

Spheroid:           Clark 1880
Semi major axis:    a   =   6378249.145
Inverse flattening: 1/f =   293.465

Projection  Lambert Conical Orthomorphic. 
Grid Latitude of Origin: (standard parallel)    31 North 
Grid Longitude of Origin: (C. Meridian) 18 East 
False Easting   1000000 meters
False Northing  550000 meters
Scale Factor on the Origin  0.9993894900

I have sometimes and sometimes not been able to get correct conversions for this projection with proj4 using the following params

+proj=lcc +lon_0=18 +lat_0=31 +lat_1=31 +k_0=0.9993894900 +x_0=1000000 +y_0=550000 +a=6378249.145 +rf=293.465

When converting from local projection (Lambert) to local geographics (Clarke1880) we have (confirmed with Blue Marble Geographic Calculator, Ski Pro and Proj4 when working correctly) the following example values

lambert => clarke1880
1000000 550000 => 18dE    31dN
304530.4 638863.4 => 10d39'46.334"E  31d35'41.752"N

When compiled under windows using Visual Studio 2008, or the old windows 4.4.6 binaries from the Proj4 website, proj4 works fine and produces the correct results. If I compile under Cygwin on windows or use pyProj the python library that comes with precompiled values on either Cygwin or Active State Python, or I use the precompiled Suse linux binaries it does not. The output is consistently wrong on bot Linux and Cygwin and pyProj as below.

WRONG 
SUSE Linux binaries, pyProj binaries, Cygwin
++++
Jules@Julian ~
$ proj
Rel. 4.7.1, 23 September 2009

Jules@Julian ~
$ proj -I -V +proj=lcc +lon_0=18 +lat_0=31 +lat_1=31 +k_0=0.9993894900 +x_0=1000000 +y_0=550000 +a=6378249.145 +rf=293.465
#Lambert Conformal Conic
#       Conic, Sph&Ell
#       lat_1= and lat_2= or lat_0
# +proj=lcc +lon_0=18 +lat_0=31 +lat_1=31 +k_0=0.9993894900 +x_0=1000000
# +y_0=550000 +a=6378249.145 +rf=293.465 +lat_2=45
#--- following specified but NOT used
# +lat_1=33
#Final Earth figure: ellipsoid
#  Major axis (a): 6378249.145
#  1/flattening: 293.465000
#  squared eccentricity: 0.006803511283

Jules@Julian ~
$ proj -I -w4 +proj=lcc +lon_0=18 +lat_0=31 +lat_1=31 +k_0=0.9993894900 +x_0=1000000 +y_0=550000 +a=6378249.145 +rf=293.465
1000000 550000
18dE    31dN
304530.4 638863.4
10d39'18.9138"E 31d33'13.9343"N

wrong - should be 304530.4 638863.4 => 10d39'46.334"E 31d35'41.752"N

Strange that is says # +lat_1=33 is specified but not used as this does not appear on working windows version Also tried just specifying just lat_1 as per remotesensing.org but does not come close then

*** CORRECT ****
Windows compilation : Visual Studio 2008 - Dos prompt (or old 4.4.6 windows binaries)
+++++
C:\proj\bin>proj
Rel. 4.7.1, 23 September 2009

C:\proj\bin>proj -I -w4 -v +proj=lcc +lon_0=18 +lat_0=31 +lat_1=31 +k_0=0.999389
4900 +x_0=1000000 +y_0=550000 +a=6378249.145 +rf=293.465
#Lambert Conformal Conic
#       Conic, Sph&Ell
#       lat_1= and lat_2= or lat_0
# +proj=lcc +lon_0=18 +lat_0=31 +lat_1=31 +k_0=0.9993894900 +x_0=1000000
# +y_0=550000 +a=6378249.145 +rf=293.465
1000000 550000
18dE    31dN
304530.4 638863.4
10d39'46.334"E  31d35'41.752"N

Migrated-From: https://trac.osgeo.org/proj/ticket/82

proj4-bot commented 9 years ago

Comment by jhillman on 13 Oct 2010 15:37 UTC Have now also compiled from scratch on Fedora and get exactly the same error.

proj4-bot commented 9 years ago

Comment by jhillman on 13 Oct 2010 16:17 UTC Ok OK it was my fault.

I finally spotted in the old manual that lcc with 1sp should specify lat_0, lat_1 & lat_2 (all 31 in this case). Correct param string should have been

+proj=lcc +lon_0=18 +lat_0=31 +lat_1=31 +lat_2=31 +k_0=0.9993894900 +x_0=1000000 +y_0=550000 +a=6378249.145 +rf=293.46

Heaven knows why the windows version worked then but all solved now.

Apologies Jules