How to speed up projection conversion?

孤人 提交于 2021-01-29 16:12:52

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!