{"id":1580,"date":"2018-06-25T13:25:46","date_gmt":"2018-06-25T11:25:46","guid":{"rendered":"https:\/\/blogs.fu-berlin.de\/reseda\/?page_id=1580"},"modified":"2019-10-30T09:31:33","modified_gmt":"2019-10-30T08:31:33","slug":"sentinel-2-preprocessing","status":"publish","type":"page","link":"https:\/\/blogs.fu-berlin.de\/reseda\/sentinel-2-preprocessing\/","title":{"rendered":"Sentinel 2 Preprocessing"},"content":{"rendered":"<p>Sentinel 2 data is delivered as zip-compressed files in Sentinel&#8217;s own SAFE format. The spectral bands are stored as jpg-files in this SAFE container in three different geometric resolutions (10 m, 20 m &amp; 60 m as shown in <a href=\"https:\/\/blogs.fu-berlin.de\/reseda\/sentinel-2\/\">Section Sentinel 2<\/a>). We want to stack these jpg-files into a single geotiff-file of an uniform pixelsize of 10 m, i.e., into a so-called raster stack (because it is much easier to work with such a raster stack).<br \/>\nDue to the size of the data, we need to subset the important data from the SAFE container during preprocessing in order to minimize the computational time and the data volume. Otherwise, a single Sentinel 2 image can quickly grow to 8 GB in size! For this, we will use only <a href=\"https:\/\/blogs.fu-berlin.de\/reseda\/snap\/\">desktop app SNAP<\/a> and its commando-line based counterpart, the <a href=\"https:\/\/senbox.atlassian.net\/wiki\/spaces\/SNAP\/pages\/70503475\/Bulk+Processing+with+GPT\" target=\"_blank\" rel=\"noopener\">Graph Processing Tool (GPT)<\/a>. This results in the following intermediate steps:<\/p>\n<ol>\n<li>resample all bands to 10 m<\/li>\n<li>spatial and bands subset<\/li>\n<li>save image as geotiff\/ bigtiff to hard drive<\/li>\n<\/ol>\n<p>We want to perform the preprocessing step by step on the basis of an Sentinel 2 Level-1 scene in SNAP. Based on that we will develop a graph file that will process an arbitrary number of scenes for you!<\/p>\n<p>&nbsp;<\/p>\n<h1>Prerequisite<\/h1>\n<p>The following content requires that you have either successfully downloaded some Sentinel 2 scenes as part of the <a href=\"https:\/\/blogs.fu-berlin.de\/reseda\/esa-scihub\/\">Download Section Exercise<\/a>, or that you have acquired some datasets from the ESA SciHUB by your own. If this is not the case, look into the <a href=\"https:\/\/blogs.fu-berlin.de\/reseda\/esa-scihub\/\">chapter Sentinel \/ SciHUB<\/a>!<\/p>\n<p><a href=\"https:\/\/box.fu-berlin.de\/s\/ztHcGQtXMKJbcXN\/download?path=%2FSentinel_Data&amp;files=S2A_MSIL2A_20180731T102021_N0208_R065_T32UQD_20180731T132903.zip\">Here <\/a>you can download Sentinel-2 <a href=\"https:\/\/earth.esa.int\/web\/sentinel\/user-guides\/sentinel-2-msi\/product-types\/level-2a\" target=\"_blank\" rel=\"noopener\">level 2<\/a> data (from 31th of July 2018) for execute this exercise.<\/p>\n<p>Done? &#8211; Then start <a href=\"https:\/\/blogs.fu-berlin.de\/reseda\/snap\/\">SNAP<\/a> now!<\/p>\n<p><a name=\"1\"><\/a><\/p>\n<h1>Preprocess a single dataset<\/h1>\n<p>If SNAP is started, you can open the zip file of an image directly by <em>File<\/em> &gt; <em>Open Product<\/em>.<\/p>\n<p><a href=\"https:\/\/blogs.fu-berlin.de\/reseda\/files\/2019\/07\/Product_RGB_KF_2-1.png\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-1709\" src=\"https:\/\/blogs.fu-berlin.de\/reseda\/files\/2019\/07\/Product_RGB_KF_2-1.png\" \/><\/a><\/p>\n<div style=\"margin: -30px 0 20px 0;text-align: center\"><span style=\"color: #686868;font-size: small\">Open File SNAP<\/span><\/div>\n<p>&nbsp;<\/p>\n<p>Use SNAP&#8217;s toolbar to navigate to <em>Raster <\/em>&gt; <em>Geometric Operations<\/em> and open the <em>Resample <\/em>operation:<\/p>\n<p><a href=\"https:\/\/blogs.fu-berlin.de\/reseda\/files\/2018\/06\/preproc_02.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1709\" src=\"https:\/\/blogs.fu-berlin.de\/reseda\/files\/2018\/06\/preproc_02.png\" alt=\"\" width=\"599\" height=\"307\" srcset=\"https:\/\/blogs.fu-berlin.de\/reseda\/files\/2018\/06\/preproc_02.png 599w, https:\/\/blogs.fu-berlin.de\/reseda\/files\/2018\/06\/preproc_02-300x154.png 300w\" sizes=\"auto, (max-width: 599px) 85vw, 599px\" \/><\/a><\/p>\n<div style=\"margin: -30px 0 20px 0;text-align: center\"><span style=\"color: #686868;font-size: small\">Navigation to Resample<\/span><\/div>\n<p>A window will pop up with two tabs. In the first tab, define a downloaded, zipped Sentinel 2 file as the source product. You do NOT need to unzip it in advance! In the example shown below, the file is located in the exchange folder of our VM.<\/p>\n<p><a href=\"https:\/\/blogs.fu-berlin.de\/reseda\/files\/2019\/07\/Resamplin_KF.png\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-1710\" src=\"https:\/\/blogs.fu-berlin.de\/reseda\/files\/2019\/07\/Resamplin_KF.png\" \/><\/a><\/p>\n<div style=\"margin: -30px 0 20px 0;text-align: center\"><span style=\"color: #686868;font-size: small\">Resampling settings tab 1<\/span><\/div>\n<p>Click on the second tab &#8220;Resampling Parameters&#8221;. Select spectral band 2 here to define the geometric resolution of the final product (band 2 has a resolution of 10 m) and press <img loading=\"lazy\" decoding=\"async\" width=\"55\" height=\"24\" class=\"alignnone size-full wp-image-1716\" src=\"https:\/\/blogs.fu-berlin.de\/reseda\/files\/2018\/06\/preproc_06.png\" \/>:<\/p>\n<p><a href=\"https:\/\/blogs.fu-berlin.de\/reseda\/files\/2018\/06\/preproc_04.png\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-1710\" src=\"https:\/\/blogs.fu-berlin.de\/reseda\/files\/2018\/06\/preproc_04.png\" \/><\/a><\/p>\n<div style=\"margin: -30px 0 20px 0;text-align: center\"><span style=\"color: #686868;font-size: small\">Resampling settings tab 2<\/span><\/div>\n<p>This should create a &#8220;virtual file&#8221; with the suffix &#8220;_resampled&#8221;, which is not stored physically on your hard drive. The advantage is that no computationally intensive processes have taken place here and we can continue to calculate with the intermediate product, which should be listed in the Product Explorer in SNAP. You will also get a notification about this. Confirm this with OK:<\/p>\n<p><a href=\"https:\/\/blogs.fu-berlin.de\/reseda\/files\/2018\/06\/preproc_07.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1717\" src=\"https:\/\/blogs.fu-berlin.de\/reseda\/files\/2018\/06\/preproc_07.png\" alt=\"\" width=\"513\" height=\"184\" srcset=\"https:\/\/blogs.fu-berlin.de\/reseda\/files\/2018\/06\/preproc_07.png 513w, https:\/\/blogs.fu-berlin.de\/reseda\/files\/2018\/06\/preproc_07-300x108.png 300w\" sizes=\"auto, (max-width: 513px) 85vw, 513px\" \/><\/a><\/p>\n<div style=\"margin: -30px 0 20px 0;text-align: center\"><span style=\"color: #686868;font-size: small\">Virtual product notification<\/span><\/div>\n<p>Close the Resampling tool.<\/p>\n<p>With a right click on the processed image (product) &gt;<em> Open RGB Image <\/em>Window you can open differnet band combinations:<\/p>\n<p><a href=\"https:\/\/blogs.fu-berlin.de\/reseda\/files\/2019\/07\/Opern_RGB_SNAP_KF.png\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-1709\" src=\"https:\/\/blogs.fu-berlin.de\/reseda\/files\/2019\/07\/Opern_RGB_SNAP_KF.png\" \/><\/a><\/p>\n<div style=\"margin: -30px 0 20px 0;text-align: center\"><span style=\"color: #686868;font-size: small\">Open as RGB Image<\/span><\/div>\n<p>&nbsp;<\/p>\n<p>Navigate to the Subset function:<\/p>\n<p><a href=\"https:\/\/blogs.fu-berlin.de\/reseda\/files\/2018\/06\/preproc_08.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1720\" src=\"https:\/\/blogs.fu-berlin.de\/reseda\/files\/2018\/06\/preproc_08.png\" alt=\"\" width=\"599\" height=\"307\" srcset=\"https:\/\/blogs.fu-berlin.de\/reseda\/files\/2018\/06\/preproc_08.png 599w, https:\/\/blogs.fu-berlin.de\/reseda\/files\/2018\/06\/preproc_08-300x154.png 300w\" sizes=\"auto, (max-width: 599px) 85vw, 599px\" \/><\/a><\/p>\n<div style=\"margin: -30px 0 20px 0;text-align: center\"><span style=\"color: #bfbfbf;font-size: small\">Subset function in Toolbar<\/span><\/div>\n<p>The subset function allows you to perform both spatial and spectral resampling. By excluding irrelevant data, you can reduce the volume of data by several orders of magnitude. In the example shown below, we do a spatial subset based on geographic coordinates and only select specific bands:<\/p>\n<p><a href=\"https:\/\/blogs.fu-berlin.de\/reseda\/files\/2018\/06\/preproc_09.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-1722\" src=\"https:\/\/blogs.fu-berlin.de\/reseda\/files\/2018\/06\/preproc_09.png\" width=\"448\" height=\"404\" srcset=\"https:\/\/blogs.fu-berlin.de\/reseda\/files\/2018\/06\/preproc_09.png 526w, https:\/\/blogs.fu-berlin.de\/reseda\/files\/2018\/06\/preproc_09-300x270.png 300w\" sizes=\"auto, (max-width: 448px) 85vw, 448px\" \/><\/a><\/p>\n<p><a href=\"https:\/\/blogs.fu-berlin.de\/reseda\/files\/2019\/07\/Band_selection_KF.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-1722\" src=\"https:\/\/blogs.fu-berlin.de\/reseda\/files\/2019\/07\/Band_selection_KF.png\" width=\"448\" height=\"399\" \/><\/a><\/p>\n<div style=\"margin: -30px 0 20px 0;text-align: center\"><span style=\"color: #686868;font-size: small\">Subset function settings<\/span><\/div>\n<p>By pressing OK, another data product with the prefix &#8220;subset&#8221; is generated within a second and should be visible in the Product Explorer in SNAP. Select the newly created data product in the Product Explorer by a simple left-click on it and navigate through the toolbar to <em>File<\/em> &gt; <em>Export<\/em> &gt; GeoTIFF, as shown in the next screenshot. If you notice that your file is larger than 4 GB, you can also choose BIGTIFF as the target file format. BigTIFF describes a GeoTIFF file that is over 4 GB in size. However, saving a BiTIFF file in SNAP is very slow, especially for machines with only 8 GB of RAM. Therefore try to use the GeoTIFF file format first:<\/p>\n<p><a href=\"https:\/\/blogs.fu-berlin.de\/reseda\/files\/2019\/07\/export_2.png\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-1725\" src=\"https:\/\/blogs.fu-berlin.de\/reseda\/files\/2019\/07\/export_2.png\" \/><\/a><\/p>\n<div style=\"margin: -30px 0 20px 0;text-align: center\"><span style=\"color: #686868;font-size: small\">Export function <\/span><\/div>\n<p>In the window of the export function you can then define the file path and the name of the exported file. Then press <strong>Export Product<\/strong> to start the processing:<\/p>\n<p><a href=\"https:\/\/blogs.fu-berlin.de\/reseda\/files\/2019\/07\/export_3.png\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-1727\" src=\"https:\/\/blogs.fu-berlin.de\/reseda\/files\/2019\/08\/export_3.png\" \/><\/a><\/p>\n<div style=\"margin: -30px 0 20px 0;text-align: center\"><span style=\"color: #686868;font-size: small\">Export function settings<\/span><\/div>\n<p>The processing will take some time from now on, based on the spatial subset and the number of bands you selected.<\/p>\n<p><strong>Here you can watch all presented pre-processing steps of Sentinel-2 data:<\/strong><\/p>\n<div class=\"lyte-wrapper\" style=\"width:640px;max-width:100%;margin:5px;\"><div class=\"lyMe\" id=\"WYL_cXbXHgELbjQ\"><div id=\"lyte_cXbXHgELbjQ\" data-src=\"https:\/\/blogs.fu-berlin.de\/reseda\/wp-content\/plugins\/wp-youtube-lyte\/lyteCache.php?origThumbUrl=%2F%2Fi.ytimg.com%2Fvi%2FcXbXHgELbjQ%2Fhqdefault.jpg\" class=\"pL\"><div class=\"tC\"><div class=\"tT\"><\/div><\/div><div class=\"play\"><\/div><div class=\"ctrl\"><div class=\"Lctrl\"><\/div><div class=\"Rctrl\"><\/div><\/div><\/div><noscript><a href=\"https:\/\/youtu.be\/cXbXHgELbjQ\" rel=\"nofollow\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/blogs.fu-berlin.de\/reseda\/wp-content\/plugins\/wp-youtube-lyte\/lyteCache.php?origThumbUrl=https%3A%2F%2Fi.ytimg.com%2Fvi%2FcXbXHgELbjQ%2F0.jpg\" alt=\"YouTube video thumbnail\" width=\"640\" height=\"340\" \/><br \/>Watch this video on YouTube<\/a><\/noscript><\/div><\/div><div class=\"lL\" style=\"max-width:100%;width:640px;margin:5px;\"><br\/><span class=\"lyte_disclaimer\">ACHTUNG: Daten nach YouTube werden erst beim Abspielen des Videos \u00fcbertragen.<\/span><\/div><\/p>\n<hr style=\"height: 4px;background-color: #6b9e1f\" \/>\n<div style=\"font-family: 'Noto Sans', sans-serif;line-height: 1.2;text-align: right\"><span style=\"font-size: 12px;color: #bfbfbf\"><strong><em>NEXT<\/em><\/strong><\/span><br \/>\n<a style=\"text-decoration: none\" href=\"https:\/\/blogs.fu-berlin.de\/reseda\/s2-bulk-preprocessing\/\"><span style=\"font-size: 30px;color: #6b9e1f\"><strong><em>SENTINEL 2 BULK PREPROCESSING<\/em><\/strong><\/span><\/a><\/div>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Sentinel 2 data is delivered as zip-compressed files in Sentinel&#8217;s own SAFE format. The spectral bands are stored as jpg-files in this SAFE container in three different geometric resolutions (10 m, 20 m &amp; 60 m as shown in Section Sentinel 2). We want to stack these jpg-files into a single geotiff-file of an uniform &hellip; <a href=\"https:\/\/blogs.fu-berlin.de\/reseda\/sentinel-2-preprocessing\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Sentinel 2 Preprocessing&#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-1580","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/blogs.fu-berlin.de\/reseda\/wp-json\/wp\/v2\/pages\/1580","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=1580"}],"version-history":[{"count":72,"href":"https:\/\/blogs.fu-berlin.de\/reseda\/wp-json\/wp\/v2\/pages\/1580\/revisions"}],"predecessor-version":[{"id":3102,"href":"https:\/\/blogs.fu-berlin.de\/reseda\/wp-json\/wp\/v2\/pages\/1580\/revisions\/3102"}],"wp:attachment":[{"href":"https:\/\/blogs.fu-berlin.de\/reseda\/wp-json\/wp\/v2\/media?parent=1580"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}