0 274 593869.99 6734999.96 121.83 1,
0 273 593869.51 6734999.92 121.57 1,
0 273 593869.15 6734999.89 121.57 1,
0 273 593868.79 6734999.86 121.65 1,
0 273 593868.44 6734999.84 121.65 1,
0 273 593869.00 6734999.94 124.21 1,
0 273 593868.68 6734999.92 124.32 1,
0 273 593868.39 6734999.90 124.44 1,
0 273 593866.94 6734999.71 121.37 1,
0 273 593868.73 6734999.99 127.28 1,
我在Windows上使用Python 2.7编写了一个简单的函数,用于过滤。该函数会读取整个文件,选择具有相同idtile
(第一列和第二列)的行,并返回点(x、y、z和标签)列表和idtile
。
tiles_id = [j for j in np.ndindex(ny, nx)] #ny = number of row, nx= number of columns
idtile = tiles_id[0]
def file_filter(name,idtile):
lst = []
for line in file(name, mode="r"):
element = line.split() # add value
if (int(element[0]),int(element[1])) == idtile:
lst.append(element[2:])
dy, dx = int(element[0]),int(element[1])
return(lst, dy, dx)
文件大小超过32 GB,瓶颈在于文件的读取速度。我正在寻找一些建议或示例,以加快我的功能(例如:并行计算或其他方法)。
我的解决方案是将文本文件分割成瓦片(使用x和y位置)。这个解决方案并不优雅,我正在寻找一个高效的方法。
file_filter()
函数被调用了多少次? - Berhash(idtile)%N
作为文件名。 - HYRY