Given a (lon, lat) point (5.068913, 52.067567) I would like to convert from EPSG 4326 to EPSG 28992 using pyproj
.
The Proj
, and transform
functions in pyproj
both seem to be suitable for such a task:
- https://pyproj4.github.io/pyproj/dev/api/proj.html?highlight=proj#pyproj-proj
- https://pyproj4.github.io/pyproj/dev/api/transformer.html?highlight=transform#pyproj-transform
When I use the Proj
function I get a different result to using transform
, why?
For example
from shapely.geometry import Point
from pyproj import Proj, transform
from matplotlib import pyplot as plt
x1, y1 = 5.068913, 52.067567
in_proj = Proj(init='epsg:4326')
out_proj = Proj(init='epsg:28992')
point1 = Point(out_proj(x1, y1))
point2 = Point(transform(in_proj, out_proj, x1 ,y1))
print(point1 == point2)
fig, ax = plt.subplots()
x, y = point1.xy
ax.plot(x, y, 'ro')
x, y = point2.xy
ax.plot(x, y, 'ro')