<jupyter_start><jupyter_text>Laserchicken tutorialThis document shows how Laserchicken can be used to calculate features that describe a point cloud.  Load a las file<jupyter_code>from laserchicken import load
point_cloud = load('testdata/AHN3.las')
point_cloud<jupyter_output><empty_output><jupyter_text>Normalize dataAdds the attribute 'normaiized_height' to the point cloud. Note that data is added to the given point cloud  in place<jupyter_code>from laserchicken.normalize import normalize
normalize(point_cloud)
point_cloud<jupyter_output><empty_output><jupyter_text>Filter points inside a polygonWe filter points within a polygon<jupyter_code>from laserchicken.filter import select_polygon
polygon = "POLYGON(( 131963.984125 549718.375000," + \
                   " 132000.000125 549718.375000," + \
                   " 132000.000125 549797.063000," + \
                   " 131963.984125 549797.063000," + \
                   " 131963.984125 549718.375000))"
point_cloud = select_polygon(point_cloud, polygon)<jupyter_output><empty_output><jupyter_text>Filter points by attribute threshold<jupyter_code>from laserchicken.filter import select_above, select_below
points_below_1_meter = select_below(point_cloud, 'normalized_height', 1)
points_above_1_meter = select_above(point_cloud, 'normalized_height', 1)<jupyter_output><empty_output><jupyter_text>Compute neighborsComputer neighbors for every point in the point cloud. This means that the target point cloud should contain the same points as the environment point cloud. The target point cloud contains the point at which the neighbors should be calculated.The code below finds for every target point, the neighbors within a Spherical neighborhood with radius of 5 meters.<jupyter_code>from laserchicken import compute_neighborhoods
from laserchicken import build_volume
targets = point_cloud
volume = build_volume('sphere', radius=5)
neighborhoods = compute_neighborhoods(point_cloud, targets, volume)<jupyter_output><empty_output><jupyter_text>Calculate features<jupyter_code>from laserchicken import compute_features
compute_features(point_cloud, neighborhoods, targets, ['std_z','mean_z','slope'], volume)<jupyter_output>Cylinder size in Bytes: 1262794583.0369534
Memory size in Bytes: 17179869184
Start tree creation
Done with env tree creation
Done with target tree creation
Extracting feature(s) "['eigenv_1', 'eigenv_2', 'eigenv_3', 'normal_vector_1', 'normal_vector_2', 'normal_vector_3', 'slope']"Extracting feature(s) "['eigenv_1', 'eigenv_2', 'eigenv_3', 'normal_vector_1', 'normal_vector_2', 'normal_vector_3', 'slope']" took 0.22 seconds
Extracting feature(s) "['mean_z', 'std_z', 'coeff_var_z']"Extracting feature(s) "['mean_z', 'std_z', 'coeff_var_z']" took 0.21 seconds
The following unrequested features were calculated as a side effect, but will not be returned: ['normal_vector_3', 'normal_vector_2', 'normal_vector_1', 'eigenv_3', 'eigenv_2', 'eigenv_1', 'coeff_var_z']<jupyter_text>Calculate parameterized featuresWe add 4 parameterized features.<jupyter_code>from laserchicken import register_new_feature_extractor
from laserchicken.feature_extractor.band_ratio_feature_extractor import BandRatioFeatureExtractor
register_new_feature_extractor(BandRatioFeatureExtractor(None,1,data_key='normalized_height'))
register_new_feature_extractor(BandRatioFeatureExtractor(1,2,data_key='normalized_height'))
register_new_feature_extractor(BandRatioFeatureExtractor(2,None,data_key='normalized_height'))
register_new_feature_extractor(BandRatioFeatureExtractor(None,0,data_key='z'))<jupyter_output><empty_output><jupyter_text>Print a list of all available feature names and notice the parameterized features we just registered, 'band_ratio_1<z<2'.<jupyter_code>from laserchicken.feature_extractor.feature_extraction import list_feature_names
sorted(list_feature_names())<jupyter_output><empty_output><jupyter_text>Recalculate neighbors and calculate the parameterized featureNeighbors is a generator and can only be iterated once. We therefore recalculate them here. If we would want to do multiple calculations without recalculating the neighbors, we could copy the neighbors to a list. This is not done by default because neighbors can quickly grow quite large so that available RAM unnecessarily becomes the bottle neck.<jupyter_code>cylinder = build_volume('infinite cylinder', radius=5)
neighborhoods = compute_neighborhoods(point_cloud, targets, cylinder)
compute_features(point_cloud, neighborhoods, targets, ['band_ratio_1<normalized_height<2'], cylinder)<jupyter_output>Cylinder size in Bytes: 1262794583.0369534
Memory size in Bytes: 17179869184
Start tree creation
Done with env tree creation
Done with target tree creation
Extracting feature(s) "['band_ratio_1<normalized_height<2']"Extracting feature(s) "['band_ratio_1<normalized_height<2']" took 0.08 seconds<jupyter_text>Write result to ply file<jupyter_code>from laserchicken import export
export(point_cloud, 'my_output.ply')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.08058388322335533, 'fraction_numerical': 0.04499100179964007, 'mean_word_length': 8.177981651376147, 'pattern_counts': {'":': 0, '<': 47, '<?xml version=': 0, '>': 39, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '10', 'dir': 'jupyter-structured-clean-dedup', 'id': '454880', 'license': 'Apache-2.0', 'n_tokens_mistral': 1675, 'n_tokens_neox': 1500, 'n_words': 404, 'path': 'tutorial.ipynb', 'repo_name': 'eEcoLiDAR/eEcoLiDAR', 'size': '5001'}