# https://pyproj4.github.io/pyproj/stable/gotchas.html#upgrading-to-pyproj-2-from-pyproj-1
from pyproj import Transformer
import time
start = time.time()
x = 61759.831
y = -41125.585
transformer = Transformer.from_crs("+proj=cass +lat_0=43.318293 +lon_0=11.332212 +x_0=0.000000000000000 +y_0=0.000000000000000 +datum=WGS84 +units=m +no_defs", "epsg:3003")
ret = transformer.transform(y, x)
stop = time.time()
print "TIME: {}".format(stop - start)
print ret
TIME: 0.0580408573151
(1646302.7175560538, 4859396.61741957)
TIME: 0.0537190437317
(1646302.7175560538, 4859396.61741957)
TIME: 0.0591440200806
(1646302.7175560538, 4859396.61741957)
TIME: 0.0580699443817
(1646302.7175560538, 4859396.61741957)
TIME: 0.0595941543579
(1646302.7175560538, 4859396.61741957)
TIME: 0.0600090026855
(1646302.7175560538, 4859396.61741957)
TIME: 0.059278011322
(1646302.7175560538, 4859396.61741957)
TIME: 0.0588028430939
(1646302.7175560538, 4859396.61741957)
TIME: 0.0584590435028
(1646302.7175560538, 4859396.61741957)
TIME: 0.0585939884186
(1646302.7175560538, 4859396.61741957)
TIME: 0.0572869777679
(1646302.7175560538, 4859396.61741957)
TIME: 0.0574839115143
(1646302.7175560538, 4859396.61741957)
TIME: 0.0569059848785
(1646302.7175560538, 4859396.61741957)
TIME: 0.0589108467102
(1646302.7175560538, 4859396.61741957)
TIME: 0.0600910186768
(1646302.7175560538, 4859396.61741957)
TIME: 0.0592269897461
(1646302.7175560538, 4859396.61741957)
TIME: 0.058445930481
(1646302.7175560538, 4859396.61741957)
TIME: 0.0585761070251
(1646302.7175560538, 4859396.61741957)
TIME: 0.0573010444641
(1646302.7175560538, 4859396.61741957)
TIME: 0.067663192749
(1646302.7175560538, 4859396.61741957)
TIME: 0.0576071739197
(1646302.7175560538, 4859396.61741957)
TIME: 6.41345977783e-05
(1646302.7175560538, 4859396.61741957)
TIME: 1.50203704834e-05
(1646302.7175560538, 4859396.61741957)
TIME: 1.21593475342e-05
(1646302.7175560538, 4859396.61741957)
TIME: 1.31130218506e-05
(1646302.7175560538, 4859396.61741957)
TIME: 9.77516174316e-06
(1646302.7175560538, 4859396.61741957)
TIME: 1.09672546387e-05
(1646302.7175560538, 4859396.61741957)
TIME: 1.38282775879e-05
(1646302.7175560538, 4859396.61741957)
TIME: 9.05990600586e-06
(1646302.7175560538, 4859396.61741957)
TIME: 1.00135803223e-05
(1646302.7175560538, 4859396.61741957)
TIME: 1.09672546387e-05
(1646302.7175560538, 4859396.61741957)
TIME: 8.10623168945e-06
(1646302.7175560538, 4859396.61741957)
TIME: 7.86781311035e-06
(1646302.7175560538, 4859396.61741957)
TIME: 1.69277191162e-05
(1646302.7175560538, 4859396.61741957)
TIME: 1.09672546387e-05
(1646302.7175560538, 4859396.61741957)
TIME: 8.10623168945e-06
(1646302.7175560538, 4859396.61741957)
TIME: 1.4066696167e-05
(1646302.7175560538, 4859396.61741957)
TIME: 1.4066696167e-05
(1646302.7175560538, 4859396.61741957)
TIME: 1.09672546387e-05
(1646302.7175560538, 4859396.61741957)
TIME: 1.71661376953e-05
(1646302.7175560538, 4859396.61741957)
TIME: 1.69277191162e-05
(1646302.7175560538, 4859396.61741957)
+proj=geos
projection. I was thinking of defining my own EPSG code for this, but with the changes to PROJ where it uses a sqlite DB now, is it possible to do this any more?
other.extra
file (https://github.com/OSGeo/PROJ/blob/master/data/other.extra). From what I can tell they don't and I don't think they are included in the PROJ database. So are the files just there for backwards compatibility?
I'm a little bit confused about Proj initialization. I have a following code for geometry transformation:
from functools import partial
import pyproj
from pyproj import Proj
from shapely.geometry import Point
from shapely.ops import transform
if __name__ == '__main__':
p = Point(400_000, 6_000_000)
old_proj = partial(pyproj.transform, Proj(init="epsg:32649"), Proj(init="epsg:4326"))
new_proj = partial(pyproj.transform, Proj("epsg:32649"), Proj("epsg:4326"))
print(transform(old_proj, p))
print(transform(new_proj, p))
It results in:
/home/ilya/.cache/pypoetry/virtualenvs/pyprojbug-Ra-0DuD_-py3.6/lib/python3.6/site-packages/pyproj/crs.py:77: FutureWarning: '+init=<authority>:<code>' syntax is deprecated. '<authority>:<code>' is the preferred initialization method.
return _prepare_from_string(" ".join(pjargs))
/home/ilya/.cache/pypoetry/virtualenvs/pyprojbug-Ra-0DuD_-py3.6/lib/python3.6/site-packages/pyproj/crs.py:77: FutureWarning: '+init=<authority>:<code>' syntax is deprecated. '<authority>:<code>' is the preferred initialization method.
return _prepare_from_string(" ".join(pjargs))
POINT (109.4692987436448 54.13837331779994)
POINT (54.13837331779994 109.4692987436448)
Why is Proj(init="epsg:32649")
and Proj("epsg:32649")
giving different results?
always_xy
for a simple fix.
string = "+proj=pipeline +ellps=GRS80 +step +proj=cart"
pipe = Transformer.from_pipeline(string)
pipe.transform(50, 25, errcheck=True)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.7/site-packages/pyproj/transformer.py", line 446, in transform
errcheck=errcheck,
File "pyproj/_transformer.pyx", line 463, in pyproj._transformer._Transformer._transform
pyproj.exceptions.ProjError: transform error: latitude or longitude exceeded limits
echo 50 25 0 | cct +proj=pipeline +ellps=GRS80 +step +proj=cart
3717892.6072 4430811.8715 2679074.4629 inf
@snowman2 Coming with another shot in the dark question: Have you had any issues pop up recently with unicode issues with pyproj or PROJ? We have a Satpy user on Windows that is having random (I think) errors with a particular PROJ dict being passed to pyproj. It errors and says either:
pyproj.exceptions.ProjError: Invalid projection b'\x02\x01roj=geos +sweep=x +lon_0=-75 +h=35786023 +x_0=0 +y_0=0 +ellps=GRS80 +units=m +no_defs'.: (Internal Proj Error: proj_create: unrecognized format / unknown name)
Or:
File "pyproj/_crs.pyx", line 24, in pyproj._crs.cstrdecode
File "C:\ProgramData\Miniconda3\lib\site-packages\pyproj\compat.py", line 21, in pystrdecode
return cstr.decode("utf-8")
UnicodeDecodeError: 'utf-8' codec can't decode bytes in position 8-9: invalid continuation byte
I'm currently working with them to narrow this down, but it seems related to a particular type of processing with various dask workers, etc. Note the PROJ string they are using stays the same and will sometimes work. Any ideas?