<jupyter_start><jupyter_text>Mapping segmentations to filter pipelines When talking about *adaptive* ground point filtering in `adaptivefiltering` we have two types of adaptivity in mind: Parameter adaptivity and spatial adaptivity. This notebook describes the details of how spatial adaptivity is implemented in `adaptivefiltering`. It assumes that you have already created a suitable segmentation of your dataset into spatial features (e.g. in a GIS). We will then see how we can attach filter pipeline information to that segmentation file.<jupyter_code>import adaptivefiltering as af<jupyter_output><empty_output><jupyter_text>We again work on our demonstrator dataset:<jupyter_code>ds = af.DataSet(filename="500k_NZ20_Westport.laz")<jupyter_output><empty_output><jupyter_text>Next, we import the segmentation the GeoJSON file. It is assumed to contain a `FeatureCollection` in the sense of the GeoJSON standard where each features combines the geometric information of the segment (`Polygon` or `Multipolygon`) and a number of properties. One of these properties should contain your custom classification of the segments into classes.<jupyter_code>segmentation = af.load_segmentation(
    "westportSegmentation.geojson", spatial_reference="EPSG:4326"
)<jupyter_output><empty_output><jupyter_text>As we are trying to map features to filter pipelines, we also need to load some filter pipelines. Here, we are directly opening these using `load_filter`. In practice, these should be selected from available filter libraries using e.g. the tools described in [Working with filter libraries](libraries.ipynb).<jupyter_code>pipelines = [af.load_filter("testfilter1.json"), af.load_filter("testfilter2.json")]<jupyter_output><empty_output><jupyter_text>The core task of assigning filter piplines is done by the `assign_pipeline` function which allows us to interactively set filter pipelines. On the right hand side, we can choose which property of our GeoJSON file contains the classification information. A feature can be highlighted on the map by clicking the  button. For each class of segments, a pipeline can be selected from the dropdown menu:<jupyter_code>assigned_segmentation = af.assign_pipeline(
    ds, segmentation=segmentation, pipelines=pipelines
)<jupyter_output><empty_output><jupyter_text>Once the pipelines are assigned, the returned segmentation object has a new property called "pipeline" that will direct the adaptivefiltering command line interface to the corresponding filter pipeline file. The modified file can be saved to disk by using the `save` method:<jupyter_code>assigned_segmentation.save("assigned_segmentation.geojson")<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.05888930301900857, 'fraction_numerical': 0.004099888184867686, 'mean_word_length': 6.847953216374269, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, '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': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '343134', 'license': 'MIT', 'n_tokens_mistral': 713, 'n_tokens_neox': 682, 'n_words': 299, 'path': 'jupyter/segmentation.ipynb', 'repo_name': 'kathapand/adaptivefiltering', 'size': '2683'}