Skip to main content
deleted 47 characters in body
Source Link
PolyGeo
  • 65.4k
  • 29
  • 114
  • 345

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. If someone can help, this would be appreciated.

Here are the values displayed:

  • For Paris lat,lon (48.856614, 2.3522219) and x,y: 6253348.594037977 374425.11288885673

  • For Toulouse lat,lon (43.604652, 1.444209) and x,y: 5453729.038474649 210744.18988320036

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. If someone can help, this would be appreciated.

Here are the values displayed:

  • For Paris lat,lon (48.856614, 2.3522219) and x,y: 6253348.594037977 374425.11288885673

  • For Toulouse lat,lon (43.604652, 1.444209) and x,y: 5453729.038474649 210744.18988320036

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) and x,y: 6253348.594037977 374425.11288885673

  • For Toulouse lat,lon (43.604652, 1.444209) and x,y: 5453729.038474649 210744.18988320036

Code structure adjusted, Question simplified, Tags added, Title changed
Source Link

Hello Converting lat, a question on projections usinglon to x,y coordinates with pyproj

I am trying to convert lat/lonlat,lon to x yx,y coordinates in France, using the pyproj lib (newb inside on geographical things ;) ).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(d1d1+d2d2) return(out)

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 iI am validating this computing the distance between Paris and Toulouse, I get 816 km816km where the distance is supposed to be around 580km580km. 

I guess iI have wrong parameters for the projection definition. If someone can help, this would be appreciated. Thanks a lot !

Here are the values displayed: Paris lat long (48.856614, 2.3522219)

Toulouse lat long (43.604652, 1.444209)

Paris x y : 6253348.594037977 374425.11288885673

Toulouse x y :5453729.038474649 210744.18988320036

  • For Paris lat,lon (48.856614, 2.3522219) and x,y: 6253348.594037977 374425.11288885673

  • For Toulouse lat,lon (43.604652, 1.444209) and x,y: 5453729.038474649 210744.18988320036

Hello, a question on projections using pyproj

I am trying to convert lat/lon to x y coordinates in France, using the pyproj lib (newb inside on geographical things ;) ). and what I am doing is obviously wrong.

Here is some 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(d1d1+d2d2) return(out)

Problem is when i am validating this computing the distance between Paris and Toulouse, I get 816 km where the distance is supposed to be around 580km. I guess i have wrong parameters for the projection definition. If someone can help, this would be appreciated. Thanks a lot !

Here are the values displayed: Paris lat long (48.856614, 2.3522219)

Toulouse lat long (43.604652, 1.444209)

Paris x y : 6253348.594037977 374425.11288885673

Toulouse x y :5453729.038474649 210744.18988320036

Converting lat,lon to x,y coordinates with pyproj

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. If someone can help, this would be appreciated.

Here are the values displayed:

  • For Paris lat,lon (48.856614, 2.3522219) and x,y: 6253348.594037977 374425.11288885673

  • For Toulouse lat,lon (43.604652, 1.444209) and x,y: 5453729.038474649 210744.18988320036

Source Link
Stéphane
  • 41
  • 1
  • 1
  • 2

Hello, a question on projections using pyproj

I am trying to convert lat/lon to x y coordinates in France, using the pyproj lib (newb inside on geographical things ;) ). and what I am doing is obviously wrong.

Here is some 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(d1d1+d2d2) return(out)

Problem is when i am validating this computing the distance between Paris and Toulouse, I get 816 km where the distance is supposed to be around 580km. I guess i have wrong parameters for the projection definition. If someone can help, this would be appreciated. Thanks a lot !

Here are the values displayed: Paris lat long (48.856614, 2.3522219)

Toulouse lat long (43.604652, 1.444209)

Paris x y : 6253348.594037977 374425.11288885673

Toulouse x y :5453729.038474649 210744.18988320036