Dear Members list,<br><br>I wrote a script to read in chunk-by-chunk and check if the points are inside a polygon. <span style="color:rgb(0,0,0);font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif;font-size:14px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:18px;text-align:left;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);display:inline!important;float:none">When I arrive at the end of the file I get this message:<span class="Apple-converted-space"> </span></span><code style="margin:0px;padding:0px;border:0px;font-size:14px;vertical-align:baseline;background-color:rgb(238,238,238);font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif;color:rgb(0,0,0);font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:18px;text-align:left;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-repeat:initial initial">LASException: LASError in "LASReader_GetPointAt": point subscript out of range</code><span style="color:rgb(0,0,0);font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif;font-size:14px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:18px;text-align:left;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);display:inline!important;float:none"><span class="Apple-converted-space"> </span>because the number of points is under the chunk dimension. I cannot figure how to resolve this problem.<br>
<b><br><span style="font-family:verdana,sans-serif">Traceback (most recent call last):<br>File "<interactive input>", line 1, in <module><br>File "C:\Python27\lib\site-packages\liblas\file.py", line 358, in __getitem__<br>
output.append(self.read(i))<br>File "C:\Python27\lib\site-packages\liblas\file.py", line 305, in read<br>handle=core.las.LASReader_GetPointAt(self.handle, index),<br>File "C:\Python27\lib\site-packages\liblas\core.py", line 85, in check_void_done<br>
raise LASException(msg)<br>LASException: LASError in "LASReader_GetPointAt": point subscript out of range<br></span></b><br>For this reasion i used "try:" and "except LASException:" but i get this error message<br>
<br><b>Traceback (most recent call last):<br> File "<interactive input>", line 4, in <module><br>NameError: name 'LASException' is not defined</b><br><br>some people have some suggestions or help?<br>
Thanks in advance<br><br>Gianni<br><br>Below i post my code in python <br><br><br>sf = shapefile.Reader(poly)#open shpfile<br>shapes = sf.shapes()<br>verts = np.array(shapes[0].points,float)<br><br>f = lasfile.File(inFile,None,'r') # open LAS<br>
h = f.header<br>file_out = lasfile.File(outFile,mode='w',header= h)<br><br><br>chunkSize = 100000<br>for i in xrange(0,len(f), chunkSize):<br> try:<br> chunk = f[i:i+chunkSize]<br> except LASException:<br>
rem = len(f)-i<br> chunk = f[i:i+rem]<br><br> x,y = [],[]<br><br> for p in xrange(len(chunk)):<br> x.append(chunk[p].x)<br> y.append(chunk[p].y)<br><br> points = np.array(zip(x,y))<br>
index = nonzero(points_inside_poly(points, verts))[0]<br><br> if len(index) != 0:<br> c = [chunk[l] for l in index]<br> a = [file_out.write(c[m]) for m in xrange(len(c))]<br><br>f.close()<br>file_out.close()<br>
<br><br><br><br><br><br><br><br><br><br>Traceback (most recent call last):<br> File "<interactive input>", line 4, in <module><br>NameError: name 'LASException' is not defined<br></span>