question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

transform much slower in 2.0.1 than 1.9.6

See original GitHub issue

I’m using python 3.6.7 on ubuntu 18.04.1. I installed each version of pyproj via pip install pyproj==x.y.z.

I’m using pyproj via geopandas. I recently upgraded from 1.9.5.1 to 2.0.1 and noticed that calls to to_crs which uses pyproj.transform via shapely.ops.transform got much slower.

It seems like there is a large overhead on the call to transform now. When calling transform with large arrays, the difference in less pronounced, but when called on individual coordinates it is quite large.

I tested with individual x,y pairs; arrays of 10 elements each to simulate usage with a “normal” sized geometry; and a test of 1,000,000 elements each which is unrealistic unless you’re working just with points and not more complex geometry.

This was the setup:

import pyproj
proj_in = pyproj.Proj({'init': 'epsg:2263'}, preserve_units=True)
proj_out = pyproj.Proj({'init': 'epsg:4326'}, preserve_units=True)

Testing on Individual coordinate pairs, 2.0.1 is ~1000x slower than 1.9.5.1:

%%t -n50 -r50
pyproj.transform(proj_in, proj_out, random.randint(80000, 120000), random.randint(200000, 250000))
  • 1.9.5.1 - 13.9 µs ± 5.82 µs per loop
  • 1.9.6 - 14.6 µs ± 6.52 µs per loop
  • 2.0.0 - 945 µs ± 152 µs per loop
  • 2.0.1 - 8.77 ms ± 915 µs per loop

For arrays of 10 coordinates each:

%%t -n50 -r50
pyproj.transform(proj_in, proj_out, np.random.randint(80000, 120000, 10), np.random.randint(200000, 250000, 10))
  • 1.9.6 - 25.1 µs ± 16.8 µs per loop
  • 2.0.1 - 8.81 ms ± 798 µs per loop

And for arrays of 1,000,000:

%%t -n5 -r5
pyproj.transform(proj_in, proj_out, np.random.randint(80000, 120000, 1000000), np.random.randint(200000, 250000, 1000000))
  • 1.9.6 - 689 ms ± 7.57 ms per loop
  • 2.0.1 - 1.18 s ± 24.9 ms per loop

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:10
  • Comments:21 (11 by maintainers)

github_iconTop GitHub Comments

2reactions
snowman2commented, Mar 12, 2019

Thoughts using a class based approach? This would mean that the TransProj could be a property on the class and would not need to be generated by the user.

from pyproj import Transformer, Proj

proj_in = Proj({'init': 'epsg:2263'}, preserve_units=True)
proj_out = Proj({'init': 'epsg:4326'}, preserve_units=True)
transformer = Transformer(proj_in, proj_out)
transformer.transform(random.randint(80000, 120000), random.randint(200000, 250000))

Plus, it would be fun to have a class called Transformer.

1reaction
snowman2commented, Mar 24, 2019

Just to be sure, you are following the recommendation here: https://pyproj4.github.io/pyproj/html/optimize_transformations.html?

Read more comments on GitHub >

github_iconTop Results From Across the Web

pyproj4-pyproj/community - Gitter
... above: it will only be faster if you use the transform object repeatedly. For a single transformation, it will still be slower...
Read more >
Faster version of 'pygame.event.get()'. Why are events being ...
This system works, but due to the for event in pygame.event.get() being too slow, it doesn't function properly. Any help is massively appreciated!...
Read more >
Issue with slow flight speed. - Drones Made Easy
Issue with slow flight speed. So I have been having issues with maps made easy ... This is happening on my Phantom 3...
Read more >
Update 1.9.6 - World of Warplanes
Update 1.9.6 has a new branch of Japanese fighters, and a way to get these aircraft pre-researched and earlier than other players.
Read more >
Enscape 2.0 - Running Very Slow - Page 2 - Revit
It is running fluently, but loading time is about triple than in 1.9.6 (about 15min for a big model), and contrast refreshing when...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found