问题
I want to project many coordinates. For example, 4 million coordinates.
First, I tested with 100 coordinates. The test result was 13.95 sec.
In calculation, it takes 155 hours to process 4 million coordinates.
Is there a good way to get results as fast as possible?
import pandas as pd
import pyproj
import time
def projection(points):
from_proj = pyproj.Proj('EPSG:4326')
to_proj = pyproj.Proj('EPSG:2448')
points[0], points[1] = pyproj.transform(from_proj, to_proj, points[1], points[0], always_xy=True)
return points
data = pd.read_csv('data.txt', header=None, delim_whitespace=True)
start = time.perf_counter()
output = data.apply(projection, axis=1)
end = time.perf_counter()
print('{0} sec.'.format(end - start))
data.txt
34.705185 135.498468
...
回答1:
I would recommend looking here: https://gis.stackexchange.com/questions/334271/converting-large-data-with-lat-and-long-into-x-and-y
https://pyproj4.github.io/pyproj/stable/advanced_examples.html#advanced-examples
Two speedups:
1. Use Transformer for repeated transformations
2. Use values from columns directly instead of apply
来源:https://stackoverflow.com/questions/61440619/how-to-speed-up-projection-conversion