{"id":1274,"date":"2024-01-08T16:40:38","date_gmt":"2024-01-08T15:40:38","guid":{"rendered":"https:\/\/www.gis-hub.uzh.ch\/?p=1274"},"modified":"2024-11-04T08:27:02","modified_gmt":"2024-11-04T07:27:02","slug":"selecting-point-data-in-qgis","status":"publish","type":"post","link":"https:\/\/www.gis-hub.uzh.ch\/en\/selecting-point-data-in-qgis\/","title":{"rendered":"Selecting point data in QGIS (I)"},"content":{"rendered":"\n<p><strong>You have imported point data into QGIS and want to analyse it further. This short tutorial shows you step by step how you can filter your dataset based on an attribute or on the spatial location. <a aria-label=\"Part II (opens in a new tab)\" href=\"https:\/\/www.gis-hub.uzh.ch\/working-with-point-data\/\" target=\"_blank\" rel=\"noreferrer noopener\" class=\"ek-link\">Part II<\/a> teaches you how to create a grid to calculate a density surface, that is to count the points per grid cell. <\/strong><\/p>\n\n\n\n<p class=\"has-text-align-center has-background\" style=\"background-color:#987db859\">Please note: For better understanding, the <strong><em>QGIS commands<\/em><\/strong> are marked in bold italics.<\/p>\n\n\n\n<p><strong>1. Set up<\/strong> <strong>and Data<\/strong><br>In this tutorial, we need a QGIS project like described in <a aria-label=\"this blog post (opens in a new tab)\" href=\"https:\/\/www.gis-hub.uzh.ch\/how-to-start-a-new-project-in-qgis\/\" target=\"_blank\" rel=\"noreferrer noopener\" class=\"ek-link\">this blog post<\/a> (steps 1 to 5). For step 6, the data, we work with the point data set of <a aria-label=\"swissNames3D (opens in a new tab)\" href=\"https:\/\/www.swisstopo.admin.ch\/en\/geodata\/landscape\/names3d.html\" target=\"_blank\" rel=\"noreferrer noopener\" class=\"ek-link\">swissNames3D<\/a>, a large collection of Swiss geographic names published by the Federal office of Topography swisstopo. You download the shp file and then you add the swissNAMES3D_PKT.shp as vector layer to your project (<strong><em>Layer <\/em><\/strong>&#8211;&gt; <strong><em>Add Layer<\/em><\/strong> &#8211;&gt; <em><strong>Add Vector Layer &#8230;<\/strong><\/em>). We further use the <a aria-label=\"Swiss boundaries (opens in a new tab)\" href=\"https:\/\/www.swisstopo.admin.ch\/de\/geodata\/landscape\/boundaries3d.html\" target=\"_blank\" rel=\"noreferrer noopener\" class=\"ek-link\">Swiss boundaries<\/a> data set (the layer with the different cantons, swissBOUNDARIES3D_1_4_TLM_KANTONSGEBIET.shp, and the layer containing Switzerland, swissBOUNDARIES3D_1_4_TLM_LANDESGEBIET.shp), published by swisstopo as well. They can be added the same way as the swissNAMES3D_PKT layer. <br><br>Hint: The order in which the layer appear in the Layers window matters. Imagine a stack, where the layer on top is also on top in the map window. So make sure your background map is at the bottom, otherwise it hides all the other layers.<br><br>If you already have your sample of point data and are just interested in the grid, then you can skip the following steps and go directly to <a aria-label=\"part II (opens in a new tab)\" href=\"https:\/\/www.gis-hub.uzh.ch\/working-with-point-data\/\" target=\"_blank\" rel=\"noreferrer noopener\" class=\"ek-link\">part II<\/a>.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"505\" src=\"https:\/\/www.gis-hub.uzh.ch\/wp-content\/uploads\/2024\/01\/point_layer-1024x505.png\" alt=\"\" class=\"wp-image-1290\" srcset=\"https:\/\/www.gis-hub.uzh.ch\/wp-content\/uploads\/2024\/01\/point_layer-1024x505.png 1024w, https:\/\/www.gis-hub.uzh.ch\/wp-content\/uploads\/2024\/01\/point_layer-300x148.png 300w, https:\/\/www.gis-hub.uzh.ch\/wp-content\/uploads\/2024\/01\/point_layer-768x378.png 768w, https:\/\/www.gis-hub.uzh.ch\/wp-content\/uploads\/2024\/01\/point_layer-18x9.png 18w, https:\/\/www.gis-hub.uzh.ch\/wp-content\/uploads\/2024\/01\/point_layer.png 1526w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">Switzerland covered by the point data of swissNames3D. <\/figcaption><\/figure>\n\n\n\n<p><strong>2. Filter the point data  <\/strong><br>Right now, the swissNames3D_PKT layer has almost 330&#8217;000 points. You see them when right clicking on the layer, then choose <em><strong>Open Attribute Table<\/strong><\/em>. When displaying the layer, the points cover the entire area of Switzerland. However, we only want a subset of these points which we can create by filtering according to attribute or by spatially intersecting the points with a polygon e.g., a certain canton. We will do both:<\/p>\n\n\n\n<p><strong>a) according to an attribute<\/strong><br>Let&#8217;s say we are interested in all the geographic names containing the word &#8220;wald&#8221; (&#8220;forest&#8221; in English). To filter these names out, we open the attribute table by right clicking on the layer, then <em><strong>Open Attribute Table<\/strong><\/em>. <\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"431\" src=\"https:\/\/www.gis-hub.uzh.ch\/wp-content\/uploads\/2024\/01\/attribute_table-1024x431.png\" alt=\"\" class=\"wp-image-1293\" srcset=\"https:\/\/www.gis-hub.uzh.ch\/wp-content\/uploads\/2024\/01\/attribute_table-1024x431.png 1024w, https:\/\/www.gis-hub.uzh.ch\/wp-content\/uploads\/2024\/01\/attribute_table-300x126.png 300w, https:\/\/www.gis-hub.uzh.ch\/wp-content\/uploads\/2024\/01\/attribute_table-768x323.png 768w, https:\/\/www.gis-hub.uzh.ch\/wp-content\/uploads\/2024\/01\/attribute_table-18x8.png 18w, https:\/\/www.gis-hub.uzh.ch\/wp-content\/uploads\/2024\/01\/attribute_table.png 1527w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">The attribute table of the point layer of swissNAMES3D.<\/figcaption><\/figure>\n\n\n\n<p>You can imagine the attribute as an excel table containing all your data. To filter the data, we click on the <strong><em>funnel symbol<\/em><\/strong> in the middle of the navigation bar (highlighted in yellow in the screenshot below) and we enter &#8220;wald&#8221; in the field <strong><em>NAME<\/em><\/strong>. Then we click on <em><strong>Select Features<\/strong><\/em>.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"991\" height=\"632\" src=\"https:\/\/www.gis-hub.uzh.ch\/wp-content\/uploads\/2024\/01\/filter_attribute_table.png\" alt=\"\" class=\"wp-image-1295\" style=\"width:745px;height:auto\" srcset=\"https:\/\/www.gis-hub.uzh.ch\/wp-content\/uploads\/2024\/01\/filter_attribute_table.png 991w, https:\/\/www.gis-hub.uzh.ch\/wp-content\/uploads\/2024\/01\/filter_attribute_table-300x191.png 300w, https:\/\/www.gis-hub.uzh.ch\/wp-content\/uploads\/2024\/01\/filter_attribute_table-768x490.png 768w, https:\/\/www.gis-hub.uzh.ch\/wp-content\/uploads\/2024\/01\/filter_attribute_table-18x12.png 18w\" sizes=\"auto, (max-width: 991px) 100vw, 991px\" \/><figcaption class=\"wp-element-caption\">Filtering according to &#8220;wald&#8221; in the Name field of the data set.<\/figcaption><\/figure>\n<\/div>\n\n\n<p>QGIS then filters the data and tells us in the header how many features have been found and selected. To save them in a new layer, we go back to the map (just close the attribute table or minimize it). All the geographic names containing &#8220;wald&#8221; are now colored yellow. We right click on the layer swissNames3D_PKT, choose <em><strong>Export<\/strong><\/em>, then <em><strong>Save Selected Features As\u2026<\/strong><\/em> A new window opens, where we click on the three dots <strong><em>&#8230; <\/em><\/strong>and choose the path where we want to save the features,  enter a file name and click on <em><strong>OK<\/strong><\/em>.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"597\" height=\"673\" src=\"https:\/\/www.gis-hub.uzh.ch\/wp-content\/uploads\/2024\/01\/save-layer-as.png\" alt=\"\" class=\"wp-image-1296\" style=\"width:439px;height:auto\" srcset=\"https:\/\/www.gis-hub.uzh.ch\/wp-content\/uploads\/2024\/01\/save-layer-as.png 597w, https:\/\/www.gis-hub.uzh.ch\/wp-content\/uploads\/2024\/01\/save-layer-as-266x300.png 266w, https:\/\/www.gis-hub.uzh.ch\/wp-content\/uploads\/2024\/01\/save-layer-as-11x12.png 11w\" sizes=\"auto, (max-width: 597px) 100vw, 597px\" \/><figcaption class=\"wp-element-caption\">Save the selected features as new layer.<\/figcaption><\/figure>\n<\/div>\n\n<div class=\"wp-block-image\">\n<figure class=\"alignright size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"157\" height=\"56\" src=\"https:\/\/www.gis-hub.uzh.ch\/wp-content\/uploads\/2024\/01\/select-by-area.png\" alt=\"\" class=\"wp-image-1303\" style=\"width:179px;height:auto\" srcset=\"https:\/\/www.gis-hub.uzh.ch\/wp-content\/uploads\/2024\/01\/select-by-area.png 157w, https:\/\/www.gis-hub.uzh.ch\/wp-content\/uploads\/2024\/01\/select-by-area-18x6.png 18w\" sizes=\"auto, (max-width: 157px) 100vw, 157px\" \/><figcaption class=\"wp-element-caption\">Left: Select Features by Area or Single click. (Middle: Invert Selection; right: Deselect)<\/figcaption><\/figure>\n<\/div>\n\n\n<p><strong>b) based on its spatial location<\/strong><br>If we only want the geographical names containing &#8220;wald&#8221; in a certain canton, we have to select the corresponding canton. We make sure the layer with the cantons is displayed on the map and selected (just click once on it in the Layers window). Let&#8217;s say we only want the names containing &#8220;wald&#8221; in Grisons. We can either choose Grisons by attribute as we did in the step before (2a) or go for <em><strong>Select Features by Area or Single Click<\/strong><\/em> (click on that symbol with the yellow square and the white arrow). We do the latter. Then you can directly click on the canton to select it. After the selection, the canton should be colored in yellow.<\/p>\n\n\n\n<p>To select the &#8220;wald&#8221; names in Grisons, you go to the main navigation and choose: <em><strong>Vector<\/strong> <\/em>&#8211;&gt; <em><strong>Research Tools<\/strong><\/em> &#8211;&gt; <em><strong>Select by Location<\/strong><\/em>: <\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"596\" height=\"430\" src=\"https:\/\/www.gis-hub.uzh.ch\/wp-content\/uploads\/2024\/01\/Vector_Research_Tools.png\" alt=\"\" class=\"wp-image-1305\" style=\"width:468px;height:auto\" srcset=\"https:\/\/www.gis-hub.uzh.ch\/wp-content\/uploads\/2024\/01\/Vector_Research_Tools.png 596w, https:\/\/www.gis-hub.uzh.ch\/wp-content\/uploads\/2024\/01\/Vector_Research_Tools-300x216.png 300w, https:\/\/www.gis-hub.uzh.ch\/wp-content\/uploads\/2024\/01\/Vector_Research_Tools-18x12.png 18w\" sizes=\"auto, (max-width: 596px) 100vw, 596px\" \/><\/figure>\n<\/div>\n\n\n<p>In the new window that opens, you choose the &#8220;wald&#8221; layer to <em><strong>Select features from<\/strong><\/em>. The <strong><em>geometric predicate<\/em><\/strong> is <em><strong>are within<\/strong><\/em>. In the field <em><strong>By comparing the features from<\/strong><\/em>, you choose the swissBoundaries3D_14_TLM_KANTONSGEBIET layer with the cantons, additionally you tick the box <em><strong>Selected features only<\/strong><\/em>. Then click on <em><strong>Run<\/strong><\/em>. Now, all the &#8220;wald&#8221; names in Grisons are chosen. We still have to save them by right clicking on the &#8220;wald&#8221; layer and choosing <em><strong>Save selected features as&#8230;<\/strong><\/em> as we did before.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"alignright size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"48\" height=\"52\" src=\"https:\/\/www.gis-hub.uzh.ch\/wp-content\/uploads\/2024\/01\/deselect.png\" alt=\"\" class=\"wp-image-1309\" srcset=\"https:\/\/www.gis-hub.uzh.ch\/wp-content\/uploads\/2024\/01\/deselect.png 48w, https:\/\/www.gis-hub.uzh.ch\/wp-content\/uploads\/2024\/01\/deselect-11x12.png 11w\" sizes=\"auto, (max-width: 48px) 100vw, 48px\" \/><\/figure>\n<\/div>\n\n\n<p>Hint: Since we are done with selecting and filtering data, we can deselect everything by clicking on the symbol on the right (<strong><em>Deselect Features from All Layers<\/em><\/strong>).<\/p>\n\n\n\n<p>Now, we are ready for <a href=\"https:\/\/www.gis-hub.uzh.ch\/working-with-point-data\/\" target=\"_blank\" aria-label=\"part II: create a grid and count the points per grid cell ... (opens in a new tab)\" rel=\"noreferrer noopener\" class=\"ek-link\">part II: create a grid and count the points per grid cell &#8230;<\/a><\/p>\n\n\n\n<div class=\"wp-block-buttons is-content-justification-center is-layout-flex wp-container-core-buttons-is-layout-a89b3969 wp-block-buttons-is-layout-flex\">\n<div class=\"wp-block-button\"><a class=\"wp-block-button__link wp-element-button\" href=\"https:\/\/www.gis-hub.uzh.ch\/wp-content\/uploads\/2024\/01\/2_Punkte_auswahlen_deutsch.pdf\" target=\"_blank\" rel=\"noreferrer noopener\">German Version of the Tutorial (pdf)<\/a><\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Let&#8217;s assume: You have imported point data into QGIS and want to analyse it further. This short tutorial shows you step by step how you can filter your dataset based on an attribute or on the spatial location.<\/p>\n","protected":false},"author":2,"featured_media":1317,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_editorskit_title_hidden":false,"_editorskit_reading_time":0,"_editorskit_is_block_options_detached":false,"_editorskit_block_options_position":"{}","footnotes":""},"categories":[37,38,244,253],"tags":[44,48],"class_list":["post-1274","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-geodata","category-gis-hub","category-qgis","category-tutorial","tag-geographic-visualisation","tag-ortsnamen","entry"],"featured_image_src":"https:\/\/www.gis-hub.uzh.ch\/wp-content\/uploads\/2024\/01\/Header.png","author_info":{"display_name":"Katia Soland","author_link":"https:\/\/www.gis-hub.uzh.ch\/en\/author\/ksolan\/"},"_links":{"self":[{"href":"https:\/\/www.gis-hub.uzh.ch\/en\/wp-json\/wp\/v2\/posts\/1274","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.gis-hub.uzh.ch\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gis-hub.uzh.ch\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gis-hub.uzh.ch\/en\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gis-hub.uzh.ch\/en\/wp-json\/wp\/v2\/comments?post=1274"}],"version-history":[{"count":40,"href":"https:\/\/www.gis-hub.uzh.ch\/en\/wp-json\/wp\/v2\/posts\/1274\/revisions"}],"predecessor-version":[{"id":1773,"href":"https:\/\/www.gis-hub.uzh.ch\/en\/wp-json\/wp\/v2\/posts\/1274\/revisions\/1773"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.gis-hub.uzh.ch\/en\/wp-json\/wp\/v2\/media\/1317"}],"wp:attachment":[{"href":"https:\/\/www.gis-hub.uzh.ch\/en\/wp-json\/wp\/v2\/media?parent=1274"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gis-hub.uzh.ch\/en\/wp-json\/wp\/v2\/categories?post=1274"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gis-hub.uzh.ch\/en\/wp-json\/wp\/v2\/tags?post=1274"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}