{"id":2184,"date":"2018-07-21T13:21:51","date_gmt":"2018-07-21T11:21:51","guid":{"rendered":"https:\/\/blogs.fu-berlin.de\/reseda\/?page_id=2184"},"modified":"2018-09-25T19:36:34","modified_gmt":"2018-09-25T17:36:34","slug":"label-samples-in-qgis","status":"publish","type":"page","link":"https:\/\/blogs.fu-berlin.de\/reseda\/label-samples-in-qgis\/","title":{"rendered":"Label Samples in QGIS"},"content":{"rendered":"<p>Open QGIS and import your initial image dataset (Landsat 8 scene) and the newly created point shapefile <span class=\"crayon-inline theme:amityreseda\">validation_RF.shp<\/span> containing the test samples from the <a href=\"https:\/\/blogs.fu-berlin.de\/reseda\/create-samples-in-r\/\" rel=\"noopener\" target=\"_blank\">previous section<\/a>. Display the image data using a RGB composite of your choice (see section <a href=\"https:\/\/blogs.fu-berlin.de\/reseda\/visualize-in-qgis\/\">Visualization in QGIS<\/a>). A good, high-contrast presentation makes it easier to interpret the scene during validation:<\/p>\n<p><a href=\"https:\/\/blogs.fu-berlin.de\/reseda\/files\/2018\/07\/valid_001.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/blogs.fu-berlin.de\/reseda\/files\/2018\/07\/valid_001.png\" alt=\"\" width=\"1366\" height=\"638\" class=\"aligncenter size-full wp-image-2220\" srcset=\"https:\/\/blogs.fu-berlin.de\/reseda\/files\/2018\/07\/valid_001.png 1366w, https:\/\/blogs.fu-berlin.de\/reseda\/files\/2018\/07\/valid_001-300x140.png 300w, https:\/\/blogs.fu-berlin.de\/reseda\/files\/2018\/07\/valid_001-768x359.png 768w, https:\/\/blogs.fu-berlin.de\/reseda\/files\/2018\/07\/valid_001-1024x478.png 1024w, https:\/\/blogs.fu-berlin.de\/reseda\/files\/2018\/07\/valid_001-1200x560.png 1200w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><\/a><\/p>\n<div style=\"margin: -30px 0 20px 0;text-align: center\"><span style=\"color: #686868;font-size: small\">Landsat 8 scene (RGB 543) and point shapefile containing the test samples<\/span><\/div>\n<p>For visual support, we also want to look at the high-resolution information provided by Google Maps. Starting from the main menu of QGIS, navigate via <em>Web <\/em>&gt; <em>OpenLayers Plugin<\/em> &gt; <em>Google Maps<\/em> &gt; <em>Google Satellite<\/em> to the satellite data from Google:<\/p>\n<p><a href=\"https:\/\/blogs.fu-berlin.de\/reseda\/files\/2018\/07\/valid_002.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/blogs.fu-berlin.de\/reseda\/files\/2018\/07\/valid_002.png\" alt=\"\" width=\"1366\" height=\"638\" class=\"aligncenter size-full wp-image-2227\" srcset=\"https:\/\/blogs.fu-berlin.de\/reseda\/files\/2018\/07\/valid_002.png 1366w, https:\/\/blogs.fu-berlin.de\/reseda\/files\/2018\/07\/valid_002-300x140.png 300w, https:\/\/blogs.fu-berlin.de\/reseda\/files\/2018\/07\/valid_002-768x359.png 768w, https:\/\/blogs.fu-berlin.de\/reseda\/files\/2018\/07\/valid_002-1024x478.png 1024w, https:\/\/blogs.fu-berlin.de\/reseda\/files\/2018\/07\/valid_002-1200x560.png 1200w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><\/a><\/p>\n<div style=\"margin: -30px 0 20px 0;text-align: center\"><span style=\"color: #686868;font-size: small\">Use the OpenLayers Plugin to import Google Maps imagery to your QGIS project<\/span><\/div>\n<p>If you do not use our VM, you must first install the OpenLayers Plugin manually. See <a href=\"http:\/\/www.qgistutorials.com\/en\/docs\/using_plugins.html\" rel=\"noopener\" target=\"_blank\">this guide<\/a> to learn how to install a plugin.<br \/>\nYour data may look slightly rotated after the import of external Google Maps imagery. This is because the Google Maps data are subject to a different projection and they can not be reprojected on-the-fly. Because of this, your data will be temporarily adjusted so that everything is on top of each other.<br \/>\nRight click your point shapefile (&#8220;validation_RF.shp&#8221;) and choose &#8220;Open Attribute Table&#8221;. Enable the editing features by pressing the pencil in the toolbar of the attribute table:<\/p>\n<p><a href=\"https:\/\/blogs.fu-berlin.de\/reseda\/files\/2018\/07\/valid_003.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/blogs.fu-berlin.de\/reseda\/files\/2018\/07\/valid_003.png\" alt=\"\" width=\"718\" height=\"445\" class=\"aligncenter size-full wp-image-2231\" srcset=\"https:\/\/blogs.fu-berlin.de\/reseda\/files\/2018\/07\/valid_003.png 718w, https:\/\/blogs.fu-berlin.de\/reseda\/files\/2018\/07\/valid_003-300x186.png 300w\" sizes=\"auto, (max-width: 718px) 85vw, 718px\" \/><\/a><\/p>\n<div style=\"margin: -30px 0 20px 0;text-align: center\"><span style=\"color: #686868;font-size: small\">Enable editing of attributes<\/span><\/div>\n<p>Now press the &#8220;new field&#8221; button <img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/blogs.fu-berlin.de\/reseda\/files\/2018\/07\/valid_005.png\" alt=\"\" width=\"24\" height=\"22\" class=\"alignnone size-full wp-image-2232\" \/> in the toolbar to add a new column to the attribute table into which we will write the correct class labels. We just want to enter the number for the corresponding class, instead of typing the complete class names every time. So we need an integer column, which we call &#8220;validclass&#8221;. Copy the following settings and confirm with OK:<\/p>\n<p><a href=\"https:\/\/blogs.fu-berlin.de\/reseda\/files\/2018\/07\/valid_004.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/blogs.fu-berlin.de\/reseda\/files\/2018\/07\/valid_004.png\" alt=\"\" width=\"718\" height=\"445\" class=\"aligncenter size-full wp-image-2233\" srcset=\"https:\/\/blogs.fu-berlin.de\/reseda\/files\/2018\/07\/valid_004.png 718w, https:\/\/blogs.fu-berlin.de\/reseda\/files\/2018\/07\/valid_004-300x186.png 300w\" sizes=\"auto, (max-width: 718px) 85vw, 718px\" \/><\/a><\/p>\n<div style=\"margin: -30px 0 20px 0;text-align: center\"><span style=\"color: #686868;font-size: small\">New attribute settings<\/span><\/div>\n<p>Reminder: You wonder what numbers represent which class? Look again at section <a href=\"https:\/\/blogs.fu-berlin.de\/reseda\/prepare-samples\/\" rel=\"noopener\" target=\"_blank\">Prepare Samples in R<\/a>. Starting from our training polygon shapefile, we were able to display the individual class labels and the corresponding class IDs in the following step. The order results according to the alphabetical sorting of the class names:<\/p>\n<pre class=\"theme:amityreseda\">\r\nlevels(as.factor(shp$classes))\r\n## [1] \"baresoil\"  \"forest\"    \"grassland\" \"urban_hd\"  \"urban_ld\"  \"water\"\r\n\r\nfor (i in 1:length(unique(shp$classes))) {cat(paste0(i, \" \", levels(as.factor(shp$classes))[i]), sep=\"\\n\")}\r\n## 1 baresoil\r\n## 2 forest\r\n## 3 grassland\r\n## 4 urban_hd\r\n## 5 urban_ld\r\n## 6 water\r\n<\/pre>\n<p>Write down the classification key! A wrong labeling of the points would be fatal for your validation statistics!<\/p>\n<p>If the class IDs are finally known, you can start:<br \/>\nZoom to a scale level that allows you to differentiate your target classes in Google Earth. Then click on the left part of a line in the attribute table to highlight\/select it. Once selected, press the icon &#8220;Zoom to selected Features&#8221; in the toolbar or simply <strong>Control+J<\/strong> on your keyboard to automatically navigate to the respective point in the Map View:<\/p>\n<p><a href=\"https:\/\/blogs.fu-berlin.de\/reseda\/files\/2018\/07\/valid_008.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/blogs.fu-berlin.de\/reseda\/files\/2018\/07\/valid_008.png\" alt=\"\" width=\"673\" height=\"332\" class=\"aligncenter size-full wp-image-2245\" srcset=\"https:\/\/blogs.fu-berlin.de\/reseda\/files\/2018\/07\/valid_008.png 673w, https:\/\/blogs.fu-berlin.de\/reseda\/files\/2018\/07\/valid_008-300x148.png 300w\" sizes=\"auto, (max-width: 673px) 85vw, 673px\" \/><\/a><\/p>\n<div style=\"margin: -30px 0 20px 0;text-align: center\"><span style=\"color: #686868;font-size: small\">Select a point and automatically zoom to it<\/span><\/div>\n<p>Use both your initial dataset (Landsat 8) and any high-resolution information (Google Maps) to decide which class the pixel that contains the point belongs to.<\/p>\n<p><a href=\"https:\/\/blogs.fu-berlin.de\/reseda\/files\/2018\/07\/valid_006.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/blogs.fu-berlin.de\/reseda\/files\/2018\/07\/valid_006.png\" alt=\"\" width=\"1366\" height=\"637\" class=\"aligncenter size-full wp-image-2241\" srcset=\"https:\/\/blogs.fu-berlin.de\/reseda\/files\/2018\/07\/valid_006.png 1366w, https:\/\/blogs.fu-berlin.de\/reseda\/files\/2018\/07\/valid_006-300x140.png 300w, https:\/\/blogs.fu-berlin.de\/reseda\/files\/2018\/07\/valid_006-768x358.png 768w, https:\/\/blogs.fu-berlin.de\/reseda\/files\/2018\/07\/valid_006-1024x478.png 1024w, https:\/\/blogs.fu-berlin.de\/reseda\/files\/2018\/07\/valid_006-1200x560.png 1200w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><\/a><\/p>\n<div style=\"margin: -30px 0 20px 0;text-align: center\"><span style=\"color: #686868;font-size: small\">Validate random stratified points by low resolution Landsat 8 data (initial dataset)<\/span><\/div>\n<p><a href=\"https:\/\/blogs.fu-berlin.de\/reseda\/files\/2018\/07\/valid_007.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/blogs.fu-berlin.de\/reseda\/files\/2018\/07\/valid_007.png\" alt=\"\" width=\"1366\" height=\"637\" class=\"aligncenter size-full wp-image-2242\" srcset=\"https:\/\/blogs.fu-berlin.de\/reseda\/files\/2018\/07\/valid_007.png 1366w, https:\/\/blogs.fu-berlin.de\/reseda\/files\/2018\/07\/valid_007-300x140.png 300w, https:\/\/blogs.fu-berlin.de\/reseda\/files\/2018\/07\/valid_007-768x358.png 768w, https:\/\/blogs.fu-berlin.de\/reseda\/files\/2018\/07\/valid_007-1024x478.png 1024w, https:\/\/blogs.fu-berlin.de\/reseda\/files\/2018\/07\/valid_007-1200x560.png 1200w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><\/a><\/p>\n<div style=\"margin: -30px 0 20px 0;text-align: center\"><span style=\"color: #686868;font-size: small\">Validate random stratified points by high resolution Google Maps imagery<\/span><\/div>\n<p><\/br><\/br><\/p>\n<hr style=\"height:4px;background-color:#6b9e1f\">\n<a href=\"https:\/\/blogs.fu-berlin.de\/reseda\/accuracy-statistics-in-R\/\"><br \/>\n<button style=\"width:100%;text-align:right;padding: 10 0;background-color:white;margin:-55px 0 0 0\"><\/p>\n<div style=\"font-family: 'Noto Sans',sans-serif;line-height: 1.2\">\n<span style=\"font-size: 12px;color:#bfbfbf\"><strong><em>NEXT<\/em><\/strong><\/span><br \/>\n<span style=\"font-size: 30px;color:#6b9e1f\"><strong><em>Accuracy Statistics in R<\/em><\/strong><\/span>\n<\/div>\n<p><\/button><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Open QGIS and import your initial image dataset (Landsat 8 scene) and the newly created point shapefile validation_RF.shp containing the test samples from the previous section. Display the image data using a RGB composite of your choice (see section Visualization in QGIS). A good, high-contrast presentation makes it easier to interpret the scene during validation: &hellip; <a href=\"https:\/\/blogs.fu-berlin.de\/reseda\/label-samples-in-qgis\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Label Samples in QGIS&#8221;<\/span><\/a><\/p>\n","protected":false},"author":3237,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-2184","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/blogs.fu-berlin.de\/reseda\/wp-json\/wp\/v2\/pages\/2184","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.fu-berlin.de\/reseda\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/blogs.fu-berlin.de\/reseda\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.fu-berlin.de\/reseda\/wp-json\/wp\/v2\/users\/3237"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.fu-berlin.de\/reseda\/wp-json\/wp\/v2\/comments?post=2184"}],"version-history":[{"count":25,"href":"https:\/\/blogs.fu-berlin.de\/reseda\/wp-json\/wp\/v2\/pages\/2184\/revisions"}],"predecessor-version":[{"id":2532,"href":"https:\/\/blogs.fu-berlin.de\/reseda\/wp-json\/wp\/v2\/pages\/2184\/revisions\/2532"}],"wp:attachment":[{"href":"https:\/\/blogs.fu-berlin.de\/reseda\/wp-json\/wp\/v2\/media?parent=2184"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}