I am trying to convert lat,lon
to x,y
coordinates in France, using the pyproj
library and what I am doing is obviously wrong.
Here is some of my code:
import pyproj
import math
PROJ='+proj=utm +zone=31, +north +ellps=WGS84 +datum=WGS84 +units=m +no_defs'
def LatLon_To_XY(Lat,Lon):
p1=pyproj.Proj(PROJ,preserve_units=True)
(x,y)=p1(Lat,Lon)
return(x,y)
def XY_To_LatLon(x,y):
p1=pyproj.Proj(PROJ,preserve_units=True)
(lat,lon)=p1(x,y,inverse=True)
return(lat,lon)
def distance(x1,y1,x2,y2):
d1=x1-x2
d2=y1-y2
out=math.sqrt(d1*d1+d2*d2)
return(out)
Problem is when I am validating this computing the distance between Paris and Toulouse, I get 816km
where the distance is supposed to be around 580km
.
I guess I have wrong parameters for the projection definition.
Here are the values displayed:
For Paris
lat,lon (48.856614, 2.3522219)
andx,y: 6253348.594037977 374425.11288885673
For Toulouse
lat,lon (43.604652, 1.444209)
andx,y: 5453729.038474649 210744.18988320036