1

私は Python の初心者 (数週間) で、最近、マルチプロセッシング モジュールに関する Stackoverflow の投稿を読みました。通常、私は何百万ものポイント形式のデータ (*.las ファイル。データのソースを理解するためのこのビデオ) を使用しており、マルチプロセッシング モジュールの使用方法をよりよく理解することに興味があります。

Windows 7、Intel Core i7-3770CPUでPython 2.7を使用しています

通常、私は理解するためのベンチマークとして私から書いたこの定義を使用します。

# 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()
4

0 に答える 0