Thursday, 24 November 2016

clip - Clipping LAS data with multiple shapefiles



I am looking for a method to clip with multiple shapefiles (139 shapefiles polygon) a lidar.las file.


I'm using the software Fusion, as described in: How to clip LAS data using shapefile polygons and open source software?


However, because of the overlapping polygons, the process tend to misses around 18 tree plots. So, I split the polygons to become and individual polygon. There is about 139 separated shapefiles representing one polygon each.


The question is:


How am I going to write it in the batch file command to clip this 139 shapefiles data with one LAS file in one execution? I understand the step is to quote the location of the software, shapefiles and lasfile. But what if I have hundreds of shapefiles to clip with one las file.


I cannot dissolve the polygon because each of the polygons represent crown tree (overlapping crown in the dense tropical forest). I'm going to do analysis for individual tree modelling so that's why an alternative for individual polygon is necessary. Using lasclip from lastools only allows to clip one shapefile with one las file.


The pattern in the shapefile's names is: tree_0.shp, tree_1.shp,.....until tree_138.shp


Can you help me on this? In terms of how to write the command?



Answer



Follow the instructions in my answer here to use the Fusion's command line PolyClipData.



Assuming you have:



  • shapefiles named tree_0.shp, tree_1.shp,...,tree_138.shp (as stated through comments).

  • the las file to be clipped with name data.las.

  • the fusion software stored directly under the c: drive.

  • the shp files and the las file stored under a folder named 'forest'


Write the following command line:


 FOR /L %%W IN (0,1,138) DO CALL c:\fusion\polyclipdata /index c:\forest\tree_%%W.shp c:\forest\clipped_data_%%W.las c:\forest\data.las


The FOR /L %%W IN (0,1,138) DO CALL part is a loop which will take one shapefile at a time to clip your main las file. In this case, the output will be 139 las files clipped by their respective shapefile.


I guess the time of processing will depend on how much is the number of shapefiles and the size of the main las file.


The /L part is a shortcut, so there is no need to write:


FOR %%W IN (1,2,3,4,5,6,7,8,9,10,11,12,13,14,....,138) DO CALL .....

With /L it reads the following between the brackets: (start,step,end).


The /index switch creates the .ldx and .ldi files which are necessary for visualization in the Fusion's viewer.


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...