我是Python的初学者(几个星期),最近我在Stackoverflow上读到了一些关于多处理模块的帖子。通常我使用百万点格式的数据(*.las文件)。这video了解我的数据来源)我有兴趣更好地了解如何使用多处理模块。在
我在windows 7上使用Python 2.7,intel core i7-3770CPU
通常,我用我写的这个def作为基准来理解:
# load line-by-line the las file, check if the points are inside the polygon
# if yes save a new *.las file
import shapefile
import numpy
import numpy as np
from numpy import nonzero
from matplotlib.mlab import griddata
from matplotlib.nxutils import pnpoly
from liblas import file as lasfile
def LAS2LASClip(inFile,poly,outFile):
f = lasfile.File(inFile,None,'r') # open LAS
h = f.header
# change the software id to libLAS
h.software_id = "Python 2.7"
file_out = lasfile.File(outFile,mode='w',header= h)
f.close()
sf = shapefile.Reader(poly) #open shpfile
shapes = sf.shapes()
for i in xrange(len(shapes)):
verts = np.array(shapes[i].points,float)
inside_points = [p for p in lasfile.File(inFile,None,'r') if pnpoly(p.x, p.y, verts)]
for p in inside_points:
file_out.write(p)
file_out.close()
目前没有回答
相关问题 更多 >
编程相关推荐