{"id":99,"date":"2023-07-06T20:19:51","date_gmt":"2023-07-06T20:19:51","guid":{"rendered":"https:\/\/editor.mediahack.co.za\/databites\/?p=99"},"modified":"2025-11-17T17:42:01","modified_gmt":"2025-11-17T17:42:01","slug":"how-to-extract-multiple-features-from-a-shapefile-in-qgis","status":"publish","type":"post","link":"https:\/\/outliereditor.co.za\/index.php\/2023\/07\/06\/how-to-extract-multiple-features-from-a-shapefile-in-qgis\/","title":{"rendered":"How to extract multiple features from a shapefile in QGIS"},"content":{"rendered":"\n<p>This is a simple(ish) guide to finding and extracting features from a larger map into a smaller one. In this example selected rivers in South Africa are copied into a new GeoJSON format file. <\/p>\n\n\n\n<p>Start with a shapefile and <a href=\"https:\/\/qgis.org\/\">QGIS<\/a>. This shapefile is of rivers in South Africa and is a good example of selecting multiple portions of a file: <\/p>\n\n\n\n<p><a href=\"https:\/\/hosted.mediahack.co.za\/databites\/allrivers.zip\">allrivers.zip<\/a><\/p>\n\n\n\n<p>Download this or use your own shapefile.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">1. Open the file in QGIS<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Open QGIS and click Project\u2192New to create a new project<\/li>\n\n\n\n<li>Drag the zip file into the main QGIS window<\/li>\n\n\n\n<li>A popup will appear. You only need the \u201cwriall500.shp\u201d layer in this case, so click that to select it and then OK to open.<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/editor.mediahack.co.za\/databites\/wp-content\/uploads\/sites\/3\/2023\/07\/image1-1024x469.png\" alt=\"\" class=\"wp-image-100\"\/><\/figure>\n\n\n\n<p>The map file will open in the main window and look something like this:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/editor.mediahack.co.za\/databites\/wp-content\/uploads\/sites\/3\/2023\/07\/image2-1024x654.png\" alt=\"\" class=\"wp-image-101\"\/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">2. Search for the rivers<\/h2>\n\n\n\n<p>Right click on the \u201cwriall500\u201d layer in the bottom left pane and then select \u201cFilter\u201d.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/editor.mediahack.co.za\/databites\/wp-content\/uploads\/sites\/3\/2023\/07\/Filter.png\" alt=\"\" class=\"wp-image-102\"\/><\/figure>\n\n\n\n<p>On the next screen select the columns to search and the values.<\/p>\n\n\n\n<p>Double click on the buttons, columns and values to add them to the query box at the bottom.<\/p>\n\n\n\n<p>This can take a bit of experimentation but as a starting point, it\u2019s possible to find a number of rivers by using this query:<\/p>\n\n\n\n<p>&#8220;NAME&#8221; IN (&#8216;Klip&#8217;, &#8216;Vaal&#8217;, &#8216;Sandspruit&#8217;, &#8216;Harringtonspruit&#8217;, &#8216;Natalspruit&#8217;)<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/editor.mediahack.co.za\/databites\/wp-content\/uploads\/sites\/3\/2023\/07\/query-1018x1024.png\" alt=\"\" class=\"wp-image-103\"\/><\/figure>\n\n\n\n<p>Add additional river names in single quote marks and separated by commas.<\/p>\n\n\n\n<p>Use the \u201cTest\u201d button to check the results for errors.<\/p>\n\n\n\n<p>Click OK to select these features. This will close the filter window and get you back to the main QGIS window. You may or may not see the features you selected in the main window at this point. Either way, you can export the selected features: <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">3. Export the river features<\/h2>\n\n\n\n<p>Right-click on wriall500 layer and select Export\u2192Save Features as<\/p>\n\n\n\n<p>On the next pop-up screen:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Select GeoJSON for the export<\/li>\n\n\n\n<li>Add a filename<\/li>\n\n\n\n<li>In the \u201cCRS\u201d section you may see \u201cInvalid Projection\u201d. Change this to something like \u201cWGS84\u201d<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/editor.mediahack.co.za\/databites\/wp-content\/uploads\/sites\/3\/2023\/07\/image3-920x1024.png\" alt=\"\" class=\"wp-image-104\"\/><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Click OK to export the file.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">4. Test in Mapshaper<\/h2>\n\n\n\n<p>The easiest way to check the export is to open <a href=\"https:\/\/mapshaper.org\/\">Mapshaper<\/a> and drag the newly exported geoJSON file into the main window.<\/p>\n\n\n\n<p>This should show just the rivers selected:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/editor.mediahack.co.za\/databites\/wp-content\/uploads\/sites\/3\/2023\/07\/image4-1024x564.png\" alt=\"\" class=\"wp-image-105\"\/><\/figure>\n\n\n\n<p>Add a basemap layer to check the river positioning:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/editor.mediahack.co.za\/databites\/wp-content\/uploads\/sites\/3\/2023\/07\/image5-1024x800.png\" alt=\"\" class=\"wp-image-106\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">5. Export to SVG<\/h2>\n\n\n\n<p>In Mapshaper it\u2019s easy to export to SVG which can then be used in Figma or Illustrator to touch up or add details.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/editor.mediahack.co.za\/databites\/wp-content\/uploads\/sites\/3\/2023\/07\/image6-1024x481.png\" alt=\"\" class=\"wp-image-107\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">6. Final files<\/h2>\n\n\n\n<p>The process above produces the following files:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/hosted.mediahack.co.za\/databites\/my-rivers.geojson\">A GeoJSON file<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/hosted.mediahack.co.za\/databites\/my-rivers.svg\">An SVG file<\/a><\/li>\n<\/ul>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This guide will help you find and extract features from a larger map into a smaller one. In this example, selected rivers in South Africa are copied into a new GeoJSON format file.<\/p>\n","protected":false},"author":1,"featured_media":86701,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[447,448,1387],"tags":[449,451,452,463],"newsletter-post":[],"site":[],"class_list":["post-99","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-databites","category-how-to","category-the-outlier","tag-how-to","tag-maps","tag-qgis","tag-visualisation"],"acf":{"big_number":"","big_number_caption":"","big_number_link":"","big_number_background":"","big_number_text_colour":"#000000","big_number_icon":false,"big_number_wide":"yes","featured_chart":false,"flourish_chart_id":"","flourish_sub_title":"","flourish_chart_width":"medium","is_newsletter_post":"No","post_style":"bc","show_on_front":"Yes","link_through":"Yes","chart_url":"","background_colour":"#0089AA","text_colour":"#FFFFFF"},"_links":{"self":[{"href":"https:\/\/outliereditor.co.za\/index.php\/wp-json\/wp\/v2\/posts\/99","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/outliereditor.co.za\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/outliereditor.co.za\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/outliereditor.co.za\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/outliereditor.co.za\/index.php\/wp-json\/wp\/v2\/comments?post=99"}],"version-history":[{"count":2,"href":"https:\/\/outliereditor.co.za\/index.php\/wp-json\/wp\/v2\/posts\/99\/revisions"}],"predecessor-version":[{"id":89530,"href":"https:\/\/outliereditor.co.za\/index.php\/wp-json\/wp\/v2\/posts\/99\/revisions\/89530"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/outliereditor.co.za\/index.php\/wp-json\/wp\/v2\/media\/86701"}],"wp:attachment":[{"href":"https:\/\/outliereditor.co.za\/index.php\/wp-json\/wp\/v2\/media?parent=99"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/outliereditor.co.za\/index.php\/wp-json\/wp\/v2\/categories?post=99"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/outliereditor.co.za\/index.php\/wp-json\/wp\/v2\/tags?post=99"},{"taxonomy":"newsletter-post","embeddable":true,"href":"https:\/\/outliereditor.co.za\/index.php\/wp-json\/wp\/v2\/newsletter-post?post=99"},{"taxonomy":"site","embeddable":true,"href":"https:\/\/outliereditor.co.za\/index.php\/wp-json\/wp\/v2\/site?post=99"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}