Open Street Map (pyproj). How to solve syntax issue? has a similar question and the answers there did not help me.
I am using the helper class below a few hundred times and my console gets flooded with warnings:
/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pyproj/crs/crs.py:53: FutureWarning: '+init=<authority>:<code>' syntax is deprecated. '<authority>:<code>' is the preferred initialization method. When making the change, be mindful of axis order changes: https://pyproj4.github.io/pyproj/stable/gotchas.html#axis-order-changes-in-proj-6
return _prepare_from_string(" ".join(pjargs))
https://pyproj4.github.io/pyproj/stable/gotchas.html#axis-order-changes-in-proj-6
When i try to follow the hint by using:
return transform(Proj('epsg:4326'), Proj('epsg:3857'), lon,lat)
I get some (inf,inf) results in cases where the original code worked. What is the proper way to avoid the syntax error but get the same results?
shows the old syntax but no code example for a compatible new statement.
https://github.com/pyproj4/pyproj/issues/224 states:
*What is the preferred way of loading EPSG CRSes now?
use "EPSG:XXXX" in source_crs or target_crs arguments of proj_create_crs_to_crs() when creating a transformation, or as argument of proj_create() to instanciate a CRS object*
What does this mean as a code example?
from pyproj import Proj, transform
class Projection:
@staticmethod
def wgsToXy(lon,lat):
return transform(Proj(init='epsg:4326'), Proj(init='epsg:3857'), lon,lat)
@staticmethod
def pointToXy(point):
xy=point.split(",")
return Projection.wgsToXy(float(xy[0]),float(xy[1]))