[a little bit OT] calculating X,Y from latitude and longitude

Luca Bertoncello lucabert at lucabert.de
Mon Aug 18 06:30:57 PDT 2025


Hi list!

Sorry, I'm OT, but I don't know other one that (hopefully!) can help 
me...

So, my problem: I have a map, generated from Tiles (generated from OSM, 
but this is not very important).
The map is NOT the whole word, just a little part.
In my currently test case, about 2°x2° and this is 1792x1536 pixel.

I need to calculate the X,Y position starting from the coordinates 
(latitude, longitude).
I searched many procedures in Internet, but I cannot locate a marker at 
the wanted place...

I tried to ignore that the word is almost a sphere and calculate the X,Y 
as this is flat (X and Y are the size of the map related to the delta of 
coordinates), but the position is always wrong.

Now, I'm not very good (AKA: very bad!) in geometry, so I really don't 
know how to solve my problem.

I'm working in PHP, but a generic example of the procedure is enough.

Can someone help me?

Thanks a lot
Luca Bertoncello
(lucabert at lucabert.de)


More information about the postgis-users mailing list