{"id":3911,"date":"2018-05-28T09:41:26","date_gmt":"2018-05-28T07:41:26","guid":{"rendered":"https:\/\/www.opengis.ch\/?p=3911"},"modified":"2020-04-29T18:57:33","modified_gmt":"2020-04-29T16:57:33","slug":"how-to-filter-features-in-qgis-using-the-graphical-processing-modeler","status":"publish","type":"post","link":"https:\/\/www.opengis.ch\/fr\/2018\/05\/28\/how-to-filter-features-in-qgis-using-the-graphical-processing-modeler\/","title":{"rendered":"How to filter features in QGIS using the graphical processing modeler"},"content":{"rendered":"<p>This article describes a new algorithm for the processing modeler called feature filter algorithm. If you are already familiar with ETL concepts and the graphical modeler, you can directly jump to the section <a href=\"#feature-filter-algorithm\">the feature filter algorithm<\/a>.<\/p>\n<h2>Building workflows for repetitive tasks<\/h2>\n<p>When building workflows for simple or complex geodata infrastructures, one of the most common tasks one encounters is to extract some of the features and copy them to another destination. Sometimes they need to be modified and a few attributes calculated or deleted, maybe even the geometry needs to be adjusted or in some fancy situations one even wants to generate a couple of objects from one input object. This process is often called <em>ETL<\/em> (Extract, Transform, Load) and it is something that is worth mastering as a GIS expert.<br \/>\nLet&rsquo;s imagine a situation where we sent a field worker out to collect information about public infrastructure, equipped with a brand-new tablet and the latest and greatest version of <a href=\"https:\/\/www.qfield.org\/\">QField<\/a>. To make his task super easy, we prepare one single layer for him with an attribute type which can be set to Bus Station, Car Parking or Train Station. Now back in the office we want to integrate this back into our spatially enabled database which has been designed with 3 target tables.<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n<a href=\"https:\/\/i0.wp.com\/www.opengis.ch\/wp-content\/uploads\/2018\/05\/Untitled-Diagram.png?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3912\" src=\"https:\/\/i0.wp.com\/www.opengis.ch\/wp-content\/uploads\/2018\/05\/Untitled-Diagram.png?resize=601%2C371&#038;ssl=1\" alt=\"\" width=\"601\" height=\"371\"><\/a><br \/>\nEasy enough to go to QGIS and select those features by type one after the other and use a bit of copy-paste. And maybe fiddling a bit with the attributes. But hey, after all we are a bit lazy and on the one hand like to have an ice cream later on that afternoon and on the other hand like to avoid errors. Those who are lucky enough to know SQL and have full access to the database are well enough equipped to do the job.<\/p>\n<h2>Short introduction to the graphical modeler<\/h2>\n<p>For those who just want to quickly do this job visually within QGIS, there is a tool called modeler in the processing plugin. With the help of this tool it is straightforward for everyone to automate processes. To get started with the modeler, simply enable the processing plugin and click on <em>Processing<\/em> &gt; <em>Graphical Modeler.<\/em><br \/>\nWithin the modeler, there are <em>Inputs<\/em> and <em>Algorithms<\/em> available. <em>Inputs<\/em> are there to define variables, algorithms on the other hand transform those variables. In its most simple form, there is one vector feature source (a layer) as input and one algorithm, for example a fixed distance buffer which in turn has one output layer with all buffered features. Such a model can be saved and reused. To run a model directly from the modeler, click the play button on top. Once saved, it appears in the processing toolbox. Every time a model is run, the input layer can be handed to the model. Or it can even run in batch mode on a list of layers or files.<br \/>\nWith this in place, the job of doing the buffer can now be run on 200 input layers without any manual interaction. Simple as that.<br \/>\n<strong>Pro tip:<\/strong> processing models do not have to be complex. They can also be used to preconfigure single algorithms so when an algorithm is run, the parameters which you never change are predefined already. For example you can add a <em>Simplify geometries to 1 meter <\/em>algorithm which only takes a layer as parameter and has the 1 meter tolerance built-in.<\/p>\n<h2><a id=\"feature-filter-algorithm\"><\/a>The feature filter algorithm<\/h2>\n<p>Now back to the job of splitting the infrastructure layer into 3 different layers. To do this job visually and easily within QGIS, there is now a new algorithm available in QGIS 3.2. It is called <strong>Feature Filter<\/strong> and available in the processing modeler.<br \/>\nTo make use of it, we open the processing modeler and first add a new <strong>Vector Features<\/strong> input and name it <strong>Infrastructure<\/strong>. Since we know in this project we will always deal with points, we can make already specify that in this first dialog.<br \/>\n&nbsp;<br \/>\n<a href=\"https:\/\/i0.wp.com\/www.opengis.ch\/wp-content\/uploads\/2018\/05\/Screenshot-from-2018-05-24-15-25-15.png?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3913\" src=\"https:\/\/i0.wp.com\/www.opengis.ch\/wp-content\/uploads\/2018\/05\/Screenshot-from-2018-05-24-15-25-15.png?resize=750%2C367&#038;ssl=1\" alt=\"\" width=\"750\" height=\"367\"><\/a><br \/>\nLet&rsquo;s now add a <strong>Feature Filter <\/strong>algorithm and use the following configuration:<br \/>\nThe <strong>Infrastructure <\/strong>layer is set as input, and we define three outputs for <strong>Train Stations<\/strong>, <strong>Bus Stations<\/strong> and <strong>Car Parking<\/strong>. All layers will be final outputs on which no further transformations will be applied within this model and they will be directly written to a new layer.<br \/>\n&nbsp;<br \/>\n<a href=\"https:\/\/i0.wp.com\/www.opengis.ch\/wp-content\/uploads\/2018\/05\/Screenshot-from-2018-05-24-15-30-18.png?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3915\" src=\"https:\/\/i0.wp.com\/www.opengis.ch\/wp-content\/uploads\/2018\/05\/Screenshot-from-2018-05-24-15-30-18.png?resize=592%2C467&#038;ssl=1\" alt=\"\" width=\"592\" height=\"467\"><\/a><br \/>\nNow it&rsquo;s time to run our new model and check that it does what it promised.<br \/>\nWe can also uncheck the final output checkbox and send filtered features to further processing algorithms. For example sending them through a buffer based on an attribute size (although as a QGIS professional you know you should rather be using styles than modifying the geometry in most situations in such cases).<\/p>\n<h2>Conclusion<\/h2>\n<p>With this new algorithm built directly inside the core of QGIS, the processing framework is now able to transform and refine features of a dataset with the same precision as an open heart surgery.<br \/>\nOf course you can get more creative in the filter criteria.<br \/>\nApart from the obvious ones to do geometry modifications, there are two particularly interesting ones if you liked this one<\/p>\n<ul>\n<li>The <a href=\"https:\/\/docs.qgis.org\/testing\/en\/docs\/user_manual\/processing_algs\/qgis\/vectortable.html#refactor-fields\"><strong>Refactor Fields <\/strong><\/a>algorithm allows calculating new fields or rename fields based on expressions<\/li>\n<li>The<a href=\"https:\/\/plugins.qgis.org\/plugins\/AppendFeaturesToLayer\/\"> <strong>Append<\/strong><\/a> plugin allows adding those features to an existing vector layer such as a database table<\/li>\n<\/ul>\n<p>The data from this walkthrough is available for download as [download id=\u00a0\u00bb3917&Prime;].<br \/>\nIf you would like to test this new feature but do not yet have a concrete use-case in mind, here is a task for you: get an openstreetmap extract, import it using ogr2ogr and split the lines into different layers roads, rivers and railways, the polygons into lakes, forests and cities, the points according to your own liking.<br \/>\nIf there is big enough interest for this, we might write another blog post on this topic.<br \/>\n&nbsp;<br \/>\nWe would like to thank the <a href=\"https:\/\/www.qgis.ch\">QGIS user group Switzerland<\/a> for making this project possible through funding.<br \/>\n&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This article describes a new algorithm for the processing modeler called feature filter algorithm. If you are already familiar with ETL concepts and the graphical modeler, you can directly jump to the section the feature filter algorithm. Building workflows for repetitive tasks When building workflows for simple or complex geodata [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":4903,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_themeisle_gutenberg_block_has_review":false,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[32,36,38,15],"tags":[125],"class_list":["post-3911","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-expressions","category-processing","category-qfield","category-qgis","tag-qgis-org"],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/www.opengis.ch\/wp-content\/uploads\/2018\/05\/modeller.png?fit=1016%2C497&ssl=1","jetpack-related-posts":[{"id":13036,"url":"https:\/\/www.opengis.ch\/fr\/2022\/08\/30\/writing-a-feature-based-processing-algorithm-at-the-example-of-m-value-interpolation\/","url_meta":{"origin":3911,"position":0},"title":"Writing a feature-based processing algorithm at the example of M-value interpolation","author":"isabel","date":"30 ao\u00fbt 2022","format":false,"excerpt":"Amongst all the processing algorithms already available in QGIS, sometimes the one thing you need is missing.\u00a0 This happened not a long time ago, when we were asked to find a way to continuously visualise traffic on the Swiss motorway network (polylines) using frequently measured traffic volumes from discrete measurement\u2026","rel":"","context":"Dans &quot;Processing&quot;","block_context":{"text":"Processing","link":"https:\/\/www.opengis.ch\/fr\/category\/gis\/qgis\/processing\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.opengis.ch\/wp-content\/uploads\/2022\/08\/Screenshot-2022-07-26-at-10.25.35.png?fit=1200%2C894&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.opengis.ch\/wp-content\/uploads\/2022\/08\/Screenshot-2022-07-26-at-10.25.35.png?fit=1200%2C894&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.opengis.ch\/wp-content\/uploads\/2022\/08\/Screenshot-2022-07-26-at-10.25.35.png?fit=1200%2C894&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/www.opengis.ch\/wp-content\/uploads\/2022\/08\/Screenshot-2022-07-26-at-10.25.35.png?fit=1200%2C894&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/www.opengis.ch\/wp-content\/uploads\/2022\/08\/Screenshot-2022-07-26-at-10.25.35.png?fit=1200%2C894&ssl=1&resize=1050%2C600 3x"},"classes":[]},{"id":14290,"url":"https:\/\/www.opengis.ch\/fr\/2024\/05\/13\/qgis-dxf-export-enhancements\/","url_meta":{"origin":3911,"position":1},"title":"QGIS DXF Export enhancements","author":"Germ\u00e1n Carrillo","date":"13 mai 2024","format":false,"excerpt":"At OPENGIS.CH, we've been working lately on improving the DXF Export QGIS functionality for the upcoming release 3.38. In the meantime, we've also added nice UX enhancements for making it easier and much more powerful to use! Let's see a short review. DXF Export app dialog and processing algorithm harmonized\u2026","rel":"","context":"Dans &quot;QGIS&quot;","block_context":{"text":"QGIS","link":"https:\/\/www.opengis.ch\/fr\/category\/gis\/qgis\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.opengis.ch\/wp-content\/uploads\/2024\/04\/DXF_Override_output_name_poster_image.jpg?fit=1200%2C899&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.opengis.ch\/wp-content\/uploads\/2024\/04\/DXF_Override_output_name_poster_image.jpg?fit=1200%2C899&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.opengis.ch\/wp-content\/uploads\/2024\/04\/DXF_Override_output_name_poster_image.jpg?fit=1200%2C899&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/www.opengis.ch\/wp-content\/uploads\/2024\/04\/DXF_Override_output_name_poster_image.jpg?fit=1200%2C899&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/www.opengis.ch\/wp-content\/uploads\/2024\/04\/DXF_Override_output_name_poster_image.jpg?fit=1200%2C899&ssl=1&resize=1050%2C600 3x"},"classes":[]},{"id":15321,"url":"https:\/\/www.opengis.ch\/fr\/2025\/03\/25\/a-brief-look-into-our-qgis-processing-workshop\/","url_meta":{"origin":3911,"position":2},"title":"A brief look into our QGIS Processing Workshop","author":"Anja Ottiger","date":"25 mars 2025","format":false,"excerpt":"In the afternoon of our 10 year anniversary, a mixed group of experienced QGIS users and developers from OPENGIS.ch got together to take a close look at the Graphical Modeler tool in QGIS. Example of a processing model This tool is not known, let alone used by all QGIS users.\u2026","rel":"","context":"Dans &quot;Newsletter 2025 March&quot;","block_context":{"text":"Newsletter 2025 March","link":"https:\/\/www.opengis.ch\/fr\/category\/newsletter\/newsletter-2025-march\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.opengis.ch\/wp-content\/uploads\/2025\/03\/processing-blurred-2-1024x767.jpg?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.opengis.ch\/wp-content\/uploads\/2025\/03\/processing-blurred-2-1024x767.jpg?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.opengis.ch\/wp-content\/uploads\/2025\/03\/processing-blurred-2-1024x767.jpg?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/www.opengis.ch\/wp-content\/uploads\/2025\/03\/processing-blurred-2-1024x767.jpg?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":13880,"url":"https:\/\/www.opengis.ch\/fr\/2023\/09\/05\/analyzing-and-visualizing-large-scale-fire-events-using-qgis-processing-with-st-dbscan\/","url_meta":{"origin":3911,"position":3},"title":"Analyzing and visualizing large-scale fire events using QGIS processing with ST-DBSCAN","author":"Mathieu","date":"5 septembre 2023","format":false,"excerpt":"A while back, one of our ninjas added a new algorithm in QGIS\u2019 processing toolbox named ST-DBSCAN Clustering, short for spatio temporal density-based spatial clustering of applications with noise. The algorithm regroups features falling within a user-defined maximum distance and time duration values. This post will walk you through one\u2026","rel":"","context":"Dans &quot;GIS&quot;","block_context":{"text":"GIS","link":"https:\/\/www.opengis.ch\/fr\/category\/gis\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.opengis.ch\/wp-content\/uploads\/2023\/09\/96.png?fit=755%2C566&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.opengis.ch\/wp-content\/uploads\/2023\/09\/96.png?fit=755%2C566&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.opengis.ch\/wp-content\/uploads\/2023\/09\/96.png?fit=755%2C566&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/www.opengis.ch\/wp-content\/uploads\/2023\/09\/96.png?fit=755%2C566&ssl=1&resize=700%2C400 2x"},"classes":[]},{"id":11521,"url":"https:\/\/www.opengis.ch\/fr\/2020\/06\/24\/generate-dxf-on-qgis-server\/","url_meta":{"origin":3911,"position":4},"title":"Generate DXF on QGIS server","author":"Matthias Kuhn","date":"24 juin 2020","format":false,"excerpt":"Everyone knows QGIS is on the desktop and mobile devices. Many know QGIS is on the web with QGIS server through OGC services. Some know QGIS server has its own extension to generate PDFs. But did you know that QGIS server can also produce DXF files? DXF DXF files are\u2026","rel":"","context":"Dans &quot;Uncategorised&quot;","block_context":{"text":"Uncategorised","link":"https:\/\/www.opengis.ch\/fr\/category\/uncategorised\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.opengis.ch\/wp-content\/uploads\/2020\/06\/image.png?fit=1200%2C673&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.opengis.ch\/wp-content\/uploads\/2020\/06\/image.png?fit=1200%2C673&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.opengis.ch\/wp-content\/uploads\/2020\/06\/image.png?fit=1200%2C673&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/www.opengis.ch\/wp-content\/uploads\/2020\/06\/image.png?fit=1200%2C673&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/www.opengis.ch\/wp-content\/uploads\/2020\/06\/image.png?fit=1200%2C673&ssl=1&resize=1050%2C600 3x"},"classes":[]},{"id":2021,"url":"https:\/\/www.opengis.ch\/fr\/2016\/02\/04\/increasing-the-stability-of-processing-algorithms\/","url_meta":{"origin":3911,"position":5},"title":"Increasing the stability of processing algorithms","author":"Matthias Kuhn","date":"4 f\u00e9vrier 2016","format":false,"excerpt":"Processing just got a new testing framework to improve\u00a0the long-term stability of this important plugin. And you can help to improve it, even if you are not a software developer! This is yet another piece in our never-stopping crusade to improve the stability and quality of the best\u00a0desktop GIS on\u2026","rel":"","context":"Dans &quot;C++&quot;","block_context":{"text":"C++","link":"https:\/\/www.opengis.ch\/fr\/category\/programming\/cpp\/"},"img":{"alt_text":"pr","src":"https:\/\/i0.wp.com\/www.opengis.ch\/wp-content\/uploads\/2016\/02\/pr.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.opengis.ch\/wp-content\/uploads\/2016\/02\/pr.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.opengis.ch\/wp-content\/uploads\/2016\/02\/pr.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/www.opengis.ch\/wp-content\/uploads\/2016\/02\/pr.png?resize=700%2C400&ssl=1 2x"},"classes":[]}],"jetpack_shortlink":"https:\/\/wp.me\/pbdBtI-115","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.opengis.ch\/fr\/wp-json\/wp\/v2\/posts\/3911","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.opengis.ch\/fr\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.opengis.ch\/fr\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.opengis.ch\/fr\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.opengis.ch\/fr\/wp-json\/wp\/v2\/comments?post=3911"}],"version-history":[{"count":1,"href":"https:\/\/www.opengis.ch\/fr\/wp-json\/wp\/v2\/posts\/3911\/revisions"}],"predecessor-version":[{"id":4904,"href":"https:\/\/www.opengis.ch\/fr\/wp-json\/wp\/v2\/posts\/3911\/revisions\/4904"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.opengis.ch\/fr\/wp-json\/wp\/v2\/media\/4903"}],"wp:attachment":[{"href":"https:\/\/www.opengis.ch\/fr\/wp-json\/wp\/v2\/media?parent=3911"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.opengis.ch\/fr\/wp-json\/wp\/v2\/categories?post=3911"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.opengis.ch\/fr\/wp-json\/wp\/v2\/tags?post=3911"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}