您将数据描述为“坐标列表列表”。从这里我猜你的提取看起来像这样:
for x in points:
for y in x:
for Z in y:
# z is a tuple with GPS coordinates做这个:
# initially, points is a list of lists of lists
points = itertools.chain.from_iterable(points)
# now points is an iterable producing lists
points = itertools.chain.from_iterable(points)
# now points is an iterable producing coordinates
points = itertools.chain.from_iterable(points)
# now points is an iterable producing individual floating points values
data = numpy.fromiter(points, float)
# data is a numpy array containing all the coordinates
data = data.reshape( data.size/2,2)
# data has now been reshaped to be an nx2 arrayitertools和numpy.fromiter都是用c实现的,效率很高。因此,这应该很快进行转换。
问题的第二部分并没有真正说明您想要对数据做什么。索引numpy数组比索引python列表要慢。通过对数据执行大量操作,您可以获得速度。如果不了