问问题
7380 次
2 回答
7
In order to keep using the old syntax (feeding the transformer (Lon,Lat)
pairs) you can use the always_xy=True
parameter when creating the transformer object:
from pyproj import Transformer
transformer = Transformer.from_crs(4326, 3857, always_xy=True)
points = [
(6.783333, 51.233333), # Dusseldorf
(-122.416389, 37.7775) # San Francisco
]
for pt in transformer.itransform(points):
print(pt)
Output
(755117.1754412088, 6662671.876828446)
(-13627330.088231295, 4548041.532457043)
于 2020-04-09T17:38:32.833 回答
-1
This is my current guess for the fix:
#e4326=Proj(init='epsg:4326')
e4326=CRS('EPSG:4326')
#e3857=Proj(init='epsg:3857')
e3857=CRS('EPSG:3857')
Projection helper class
from pyproj import Proj, CRS,transform
class Projection:
'''
helper to project lat/lon values to map
'''
#e4326=Proj(init='epsg:4326')
e4326=CRS('EPSG:4326')
#e3857=Proj(init='epsg:3857')
e3857=CRS('EPSG:3857')
@staticmethod
def wgsToXy(lon,lat):
t1=transform(Projection.e4326,Projection.e3857, lon,lat)
#t2=transform(Proj('epsg:4326'), Proj('epsg:3857'), lon,lat)
return t1
@staticmethod
def pointToXy(point):
xy=point.split(",")
return Projection.wgsToXy(float(xy[0]),float(xy[1]))
于 2020-04-04T06:32:02.347 回答