[Proj] pj_transform function

Gerald I. Evenden gerald.evenden at verizon.mail
Sat Oct 7 10:12:46 EDT 2006


On Saturday 07 October 2006 1:24 am, Sandeep Kumar Jakkaraju wrote:
> Hi
>
> I am doing this ....
>
> I have lat/lon of Top Left Corner of the Map and  Bottom Right Corner of
> The Map
> iam converting them to projected X,Y using this projection defintion
>
> World Mercator <54004> +proj=merc +latts=0 +lon0=0 +k=1.000000 +x0=0
> +y0=0 +ellps=WGS84 +datum=WGS84 +units=m no_defs <>
>
> ( I have found on some site that Google Maps use this projection !!)
>
>
> For example:
>
>        tl_lat = 42.8483;
>        tl_lon = -74.2935;
>        br_lat = 42.3813;
>        br_lon = -73.6509;

I agree with these values-- for lat_ts=0.  No such option as "latts=0" above.  
But fortunately, the default value is 0 anyway.

> using pj_transform of proj4.. iam converting them to X,Y.
>
>
> top left xy
>
> -8270314.5893 , 5259843.0071
>
> btm right xy
>
> -8198780.6845 , 5189458.4882
>
> I calculate the Centre cX,cY using the top left X,Y and Btm right X,Y...
>
> The Size of the Image I have generated from the Map is (1031,801)...
>
> width = absolute value of (btm right X - top left X)
>
> height = absolute value of (btm right Y - top left Y)
>
> Now I am trying to get the pixel x,y from the projected X,Y using this
> formula
>
>        px = 515.5 +  (1031/width)*(X-cX);
>        py = 400.5  -  (801/height)*(Y-cY);
>
> This gives correct pixels if i give top left or bottom right or the centre
> X,Y...
>
> But for some point inside the Image ...
>
> the calcualted pixel X is some 2/3 pixels away from actual pixel X
>
> the calcualted pixel Y is some 8/10 pixels away from actual pixel Y
>
> where am I going wrong ... is the projection iam using correct for such
> calculations ..???

I have no idea other than the selected projection is in error *or* the lat_ts 
value is not 0.  None of the other options would produce errors if the corner 
values compute correctly.


More information about the Proj mailing list