【发布时间】:2020-04-10 01:38:32
【问题描述】:
Open Street Map (pyproj). How to solve syntax issue? 有一个类似的问题,那里的答案对我没有帮助。
我使用了几百次以下的帮助类,我的控制台被警告淹没了:
/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
当我尝试使用以下提示时:
return transform(Proj('epsg:4326'), Proj('epsg:3857'), lon,lat)
在原始代码有效的情况下,我得到了一些 (inf,inf) 结果。避免语法错误但获得相同结果的正确方法是什么?
显示旧语法,但没有兼容新语句的代码示例。
https://github.com/pyproj4/pyproj/issues/224 状态:
*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*
作为代码示例是什么意思?
从 pyproj 导入 Proj,变换
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]))
【问题讨论】: