# [Proj] pj_transform function

Hugo Tyson Hugo.Tyson at cpslocates.com
Fri Oct 6 05:15:20 EDT 2006

```Sandeep Kumar Jakkaraju [sandeepkumar.jakkaraju at gmail.com] wrote:
> So what should be the  projection definition then .. to make
> it general..???
>
> I am trying to convert the geographical co-ordinates to
> screen co-ordinates ..
> so i require to convert the lat/lon to some projection and
> the convert that X,Y to pixels...
> hope this is correct ...

Ah.  So you just want like a map of the whole world, as
a rectangle, sort of thing?  That's not a "projection"
in the proj4 sense, as I understand it.

double x = (lon + 180.0)/360.0 * pixelswidth;
double y = (lat +  90.0)/180.0 * pixelsheight;
of course that'll be ugly at far north and south,
but at least it maps the whole space.

> or is there some function in proj4/or anywhere else which
> does this ....??

I don't think this is the sort of thing that proj is for.

Alternatively if you're mapping a small areas of the world
into one page or bitmap, you need to pick a proj4 projection
that works for that small area.

- Huge

PS I was mistaken in what I wrote before, mercator maps to a
half-cylinder wrapped around the globe.  Your example touches
at long 0.0, so it's still true that your long -104 is "around
the back".

> On 10/6/06, Hugo Tyson <Hugo.Tyson at cpslocates.com> wrote:
>
> 	proj-bounces at lists.maptools.org <> wrote:
> 	> I want to transform ... this lat/lon 39.739/-104.985...
> 	> to world mercator project ..with the defintition 	>
> 	> World Mercator <54004> +proj=merc +latts=0 +lon0=0
> 	> +k=1.000000 +x0=0 +y0=0 +ellps=WGS84 +datum=WGS84 +units=m no_defs
> 	<> >
> 	> but the method gives an "error"....
> 	>
> 	> this method works fine if i give lat/lon say 42.4182,-74.2643
>
> 	I've not heard of "world mercator", but looking at the parameters
> 	it's projecting into a plane tangent to the sphere at
> lat 0, lon 0.
> 	So it only works for longitudes from -90 to +90 (though
> these map
> 	to infinities in the projected plane).
>
> 	Your example of -104 longitude is around the back of the earth,
> 	on the "far side" from the projection plane.   Therefore a
> 	line from the origin through the point never intersects the
> 	projection plane, so no result can be calculated.  Hence your
> 	error.  Lon -74 is in range, so it's OK.

--
Hugo Tyson, Cambridge Positioning Systems Ltd
=************************************************************
********************************************************************************
This email and any attachments are confidential. They have been checked for viruses but it is your
responsibility to conduct your own virus checks.
Cambridge Positioning Systems Limited, 62-64 Hills Road, Cambridge, CB2 1LA, is registered in England
under company number 2808344.
********************************************************************************

```