ship detection

This commit is contained in:
Ollie Ballinger
2022-12-27 11:59:44 +00:00
parent 7082872429
commit ad74d1fef0
106 changed files with 7423 additions and 5642 deletions

View File

@@ -290,38 +290,24 @@ gtag('config', 'G-RK9ZLZQ6GL', { 'anonymize_ip': true});
<h2 id="toc-title">Table of contents</h2>
<ul>
<li><a href="#image-manipulation-bands-arithmetic-thresholds-and-masks" id="toc-image-manipulation-bands-arithmetic-thresholds-and-masks" class="nav-link active" data-scroll-target="#image-manipulation-bands-arithmetic-thresholds-and-masks"><span class="toc-section-number">5</span> Image Manipulation: Bands, Arithmetic, Thresholds, and Masks</a>
<li><a href="#image-manipulation-bands-arithmetic-thresholds-and-masks" id="toc-image-manipulation-bands-arithmetic-thresholds-and-masks" class="nav-link active" data-scroll-target="#image-manipulation-bands-arithmetic-thresholds-and-masks"><span class="toc-section-number">4.1</span> Image Manipulation: Bands, Arithmetic, Thresholds, and Masks</a>
<ul class="collapse">
<li><a href="#band-arithmetic-in-earth-engine" id="toc-band-arithmetic-in-earth-engine" class="nav-link" data-scroll-target="#band-arithmetic-in-earth-engine"><span class="toc-section-number">5.1</span> Band Arithmetic in Earth Engine</a>
<ul class="collapse">
<li><a href="#arithmetic-calculation-of-ndvi" id="toc-arithmetic-calculation-of-ndvi" class="nav-link" data-scroll-target="#arithmetic-calculation-of-ndvi"><span class="toc-section-number">5.1.1</span> Arithmetic Calculation of NDVI</a></li>
<li><a href="#single-operation-computation-of-normalized-difference-for-ndvi" id="toc-single-operation-computation-of-normalized-difference-for-ndvi" class="nav-link" data-scroll-target="#single-operation-computation-of-normalized-difference-for-ndvi"><span class="toc-section-number">5.1.2</span> Single-Operation Computation of Normalized Difference for NDVI</a></li>
<li><a href="#using-normalized-difference-for-ndwi" id="toc-using-normalized-difference-for-ndwi" class="nav-link" data-scroll-target="#using-normalized-difference-for-ndwi"><span class="toc-section-number">5.1.3</span> Using Normalized Difference for NDWI</a></li>
</ul></li>
<li><a href="#thresholding-masking-and-remapping-images" id="toc-thresholding-masking-and-remapping-images" class="nav-link" data-scroll-target="#thresholding-masking-and-remapping-images"><span class="toc-section-number">5.2</span> Thresholding, Masking, and Remapping Images</a>
<ul class="collapse">
<li><a href="#implementing-a-threshold" id="toc-implementing-a-threshold" class="nav-link" data-scroll-target="#implementing-a-threshold"><span class="toc-section-number">5.2.1</span> Implementing a Threshold</a></li>
<li><a href="#building-complex-categorizations-with-.where" id="toc-building-complex-categorizations-with-.where" class="nav-link" data-scroll-target="#building-complex-categorizations-with-.where"><span class="toc-section-number">5.2.2</span> Building Complex Categorizations with .where</a></li>
<li><a href="#masking-specific-values-in-an-image" id="toc-masking-specific-values-in-an-image" class="nav-link" data-scroll-target="#masking-specific-values-in-an-image"><span class="toc-section-number">5.2.3</span> Masking Specific Values in an Image</a></li>
<li><a href="#remapping-values-in-an-image" id="toc-remapping-values-in-an-image" class="nav-link" data-scroll-target="#remapping-values-in-an-image"><span class="toc-section-number">5.2.4</span> Remapping Values in an Image</a></li>
</ul></li>
<li><a href="#synthesis" id="toc-synthesis" class="nav-link" data-scroll-target="#synthesis">Synthesis</a></li>
<li><a href="#band-arithmetic-in-earth-engine" id="toc-band-arithmetic-in-earth-engine" class="nav-link" data-scroll-target="#band-arithmetic-in-earth-engine"><span class="toc-section-number">4.1.1</span> Band Arithmetic in Earth Engine</a></li>
<li><a href="#thresholding-masking-and-remapping-images" id="toc-thresholding-masking-and-remapping-images" class="nav-link" data-scroll-target="#thresholding-masking-and-remapping-images"><span class="toc-section-number">4.1.2</span> Thresholding, Masking, and Remapping Images</a></li>
<li><a href="#conclusion" id="toc-conclusion" class="nav-link" data-scroll-target="#conclusion">Conclusion</a></li>
<li><a href="#references" id="toc-references" class="nav-link" data-scroll-target="#references">References</a></li>
</ul></li>
<li><a href="#interpreting-an-image-classification" id="toc-interpreting-an-image-classification" class="nav-link" data-scroll-target="#interpreting-an-image-classification"><span class="toc-section-number">6</span> Interpreting an Image: Classification</a>
<li><a href="#interpreting-an-image-classification" id="toc-interpreting-an-image-classification" class="nav-link" data-scroll-target="#interpreting-an-image-classification"><span class="toc-section-number">4.2</span> Interpreting an Image: Classification</a>
<ul class="collapse">
<li><a href="#supervised-classification" id="toc-supervised-classification" class="nav-link" data-scroll-target="#supervised-classification"><span class="toc-section-number">6.1</span> Supervised Classification</a></li>
<li><a href="#unsupervised-classification" id="toc-unsupervised-classification" class="nav-link" data-scroll-target="#unsupervised-classification"><span class="toc-section-number">6.2</span> Unsupervised Classification</a></li>
<li><a href="#synthesis-1" id="toc-synthesis-1" class="nav-link" data-scroll-target="#synthesis-1">Synthesis</a></li>
<li><a href="#supervised-classification" id="toc-supervised-classification" class="nav-link" data-scroll-target="#supervised-classification"><span class="toc-section-number">4.2.1</span> Supervised Classification</a></li>
<li><a href="#unsupervised-classification" id="toc-unsupervised-classification" class="nav-link" data-scroll-target="#unsupervised-classification"><span class="toc-section-number">4.2.2</span> Unsupervised Classification</a></li>
<li><a href="#conclusion-1" id="toc-conclusion-1" class="nav-link" data-scroll-target="#conclusion-1">Conclusion</a></li>
<li><a href="#references-1" id="toc-references-1" class="nav-link" data-scroll-target="#references-1">References</a></li>
</ul></li>
<li><a href="#accuracy-assessment-quantifying-classification-quality" id="toc-accuracy-assessment-quantifying-classification-quality" class="nav-link" data-scroll-target="#accuracy-assessment-quantifying-classification-quality"><span class="toc-section-number">7</span> Accuracy Assessment: Quantifying Classification Quality</a>
<li><a href="#accuracy-assessment-quantifying-classification-quality" id="toc-accuracy-assessment-quantifying-classification-quality" class="nav-link" data-scroll-target="#accuracy-assessment-quantifying-classification-quality"><span class="toc-section-number">4.3</span> Accuracy Assessment: Quantifying Classification Quality</a>
<ul class="collapse">
<li><a href="#quantifying-classification-accuracy-through-a-confusion-matrix" id="toc-quantifying-classification-accuracy-through-a-confusion-matrix" class="nav-link" data-scroll-target="#quantifying-classification-accuracy-through-a-confusion-matrix"><span class="toc-section-number">7.1</span> Quantifying Classification Accuracy Through a Confusion Matrix</a></li>
<li><a href="#hyperparameter-tuning" id="toc-hyperparameter-tuning" class="nav-link" data-scroll-target="#hyperparameter-tuning"><span class="toc-section-number">7.2</span> Hyperparameter tuning</a></li>
<li><a href="#synthesis-2" id="toc-synthesis-2" class="nav-link" data-scroll-target="#synthesis-2">Synthesis</a></li>
<li><a href="#quantifying-classification-accuracy-through-a-confusion-matrix" id="toc-quantifying-classification-accuracy-through-a-confusion-matrix" class="nav-link" data-scroll-target="#quantifying-classification-accuracy-through-a-confusion-matrix"><span class="toc-section-number">4.3.1</span> Quantifying Classification Accuracy Through a Confusion Matrix</a></li>
<li><a href="#hyperparameter-tuning" id="toc-hyperparameter-tuning" class="nav-link" data-scroll-target="#hyperparameter-tuning"><span class="toc-section-number">4.3.2</span> Hyperparameter tuning</a></li>
<li><a href="#conclusion-2" id="toc-conclusion-2" class="nav-link" data-scroll-target="#conclusion-2">Conclusion</a></li>
</ul></li>
</ul>
@@ -348,8 +334,8 @@ gtag('config', 'G-RK9ZLZQ6GL', { 'anonymize_ip': true});
</header>
<p>Now that you know how images are viewed and what kinds of images exist in Earth Engine, how do we manipulate them? To gain the skills of interpreting images, youll work with bands, combining values to form indices and masking unwanted pixels. Then, youll learn some of the techniques available in Earth Engine for classifying images and interpreting the results.</p>
<section id="image-manipulation-bands-arithmetic-thresholds-and-masks" class="level1" data-number="5">
<h1 data-number="5"><span class="header-section-number">5</span> Image Manipulation: Bands, Arithmetic, Thresholds, and Masks</h1>
<section id="image-manipulation-bands-arithmetic-thresholds-and-masks" class="level2" data-number="4.1">
<h2 data-number="4.1" class="anchored" data-anchor-id="image-manipulation-bands-arithmetic-thresholds-and-masks"><span class="header-section-number">4.1</span> Image Manipulation: Bands, Arithmetic, Thresholds, and Masks</h2>
<div class="callout-tip callout callout-style-default callout-captioned">
<div class="callout-header d-flex align-content-center">
<div class="callout-icon-container">
@@ -360,31 +346,31 @@ Chapter Information
</div>
</div>
<div class="callout-body-container callout-body">
<section id="author" class="level2 unlisted unnumbered">
<h2 class="unlisted unnumbered anchored" data-anchor-id="author">Author</h2>
<section id="author" class="level4 unlisted unnumbered">
<h4 class="unlisted unnumbered anchored" data-anchor-id="author">Author</h4>
<p>Karen Dyson, Andréa Puzzi Nicolau, David Saah, and Nicholas Clinton</p>
</section>
<section id="overview" class="level2 unlisted unnumbered">
<h2 class="unlisted unnumbered anchored" data-anchor-id="overview">Overview</h2>
<section id="overview" class="level4 unlisted unnumbered">
<h4 class="unlisted unnumbered anchored" data-anchor-id="overview">Overview</h4>
<p>Once images have been identified in Earth Engine, they can be viewed in a wide array of band combinations for targeted purposes. For users who are already versed in remote sensing concepts, this chapter shows how to do familiar tasks on this platform; for those who are entirely new to such concepts, it introduces the idea of band combinations.</p>
</section>
<section id="learning-outcomes" class="level2 unlisted unnumbered">
<h2 class="unlisted unnumbered anchored" data-anchor-id="learning-outcomes">Learning Outcomes</h2>
<section id="learning-outcomes" class="level4 unlisted unnumbered">
<h4 class="unlisted unnumbered anchored" data-anchor-id="learning-outcomes">Learning Outcomes</h4>
<ul>
<li>Understanding what spectral indices are and why they are useful.</li>
<li>Being introduced to a range of example spectral indices used for a variety of purposes.</li>
</ul>
</section>
<section id="assumes-you-know-how-to" class="level2 unlisted unnumbered">
<h2 class="unlisted unnumbered anchored" data-anchor-id="assumes-you-know-how-to">Assumes you know how to:</h2>
<section id="assumes-you-know-how-to" class="level4 unlisted unnumbered">
<h4 class="unlisted unnumbered anchored" data-anchor-id="assumes-you-know-how-to">Assumes you know how to:</h4>
<ul>
<li>Import images and image collections, filter, and visualize (Part F1).</li>
</ul>
</section>
</div>
</div>
<section id="introduction" class="level2 unlisted unnumbered">
<h2 class="unlisted unnumbered anchored" data-anchor-id="introduction">Introduction</h2>
<section id="introduction" class="level3 unlisted unnumbered">
<h3 class="unlisted unnumbered anchored" data-anchor-id="introduction">Introduction</h3>
<p>Spectral indices are based on the fact that different objects and land covers on the Earths surface reflect different amounts of light from the Sun at different wavelengths. In the visible part of the spectrum, for example, a healthy green plant reflects a large amount of green light while absorbing blue and red light—which is why it appears green to our eyes. Light also arrives from the Sun at wavelengths outside what the human eye can see, and there are large differences in reflectances between living and nonliving land covers, and between different types of vegetation, both in the visible and outside the visible wavelengths. We visualized this earlier, in Chaps. F1.1 and F1.3 when we mapped color-infrared images (Fig. F2.0.1).</p>
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
@@ -402,12 +388,12 @@ Chapter Information
<p>Spectral indices use math to express how objects reflect light across multiple portions of the spectrum as a single number. Indices combine multiple bands, often with simple operations of subtraction and division, to create a single value across an image that is intended to help to distinguish particular land uses or land covers of interest. Using Fig. F2.0.2, you can imagine which wavelengths might be the most informative for distinguishing among a variety of land covers. We will explore a variety of calculations made from combinations of bands in the following sections.</p>
<p>Indices derived from satellite imagery are used as the basis of many remote-sensing analyses. Indices have been used in thousands of applications, from detecting anthropogenic deforestation to examining crop health. For example, the growth of economically important crops such as wheat and cotton can be monitored throughout the growing season: Bare soil reflects more red wavelengths, whereas growing crops reflect more of the near-infrared (NIR) wavelengths. Thus, calculating a ratio of these two bands can help monitor how well crops are growing (Jackson and Huete 1991).</p>
</section>
<section id="band-arithmetic-in-earth-engine" class="level2" data-number="5.1">
<h2 data-number="5.1" class="anchored" data-anchor-id="band-arithmetic-in-earth-engine"><span class="header-section-number">5.1</span> Band Arithmetic in Earth Engine</h2>
<section id="band-arithmetic-in-earth-engine" class="level3" data-number="4.1.1">
<h3 data-number="4.1.1" class="anchored" data-anchor-id="band-arithmetic-in-earth-engine"><span class="header-section-number">4.1.1</span> Band Arithmetic in Earth Engine</h3>
<p>If you have not already done so, be sure to add the books code repository to the Code Editor by entering <a href="https://www.google.com/url?q=https://code.earthengine.google.com/?accept_repo%3Dprojects/gee-edu/book&amp;sa=D&amp;source=editors&amp;ust=1671458829783542&amp;usg=AOvVaw2f8xfEZP6c0zP_Ke8jL26U"></a><a href="https://www.google.com/url?q=https://code.earthengine.google.com/?accept_repo%3Dprojects/gee-edu/book&amp;sa=D&amp;source=editors&amp;ust=1671458829783919&amp;usg=AOvVaw2i09J44MzpMZkjV_JLEnNR">https://code.earthengine.google.com/?accept_repo=projects/gee-edu/book</a> into your browser. The books scripts will then be available in the script manager panel. If you have trouble finding the repo, you can visit <a href="https://www.google.com/url?q=https://docs.google.com/presentation/d/1Kt6wGNoesYm__Cu3k3bnlbbyPN6m9SF4hQHK-pIDHfc/edit%23slide%3Did.g18a7b4b055d_0_624&amp;sa=D&amp;source=editors&amp;ust=1671458829784270&amp;usg=AOvVaw1Kr82KG60ZeFLYC8cOZ67A">this link</a> for help.</p>
<p>Many indices can be calculated using band arithmetic in Earth Engine. Band arithmetic is the process of adding, subtracting, multiplying, or dividing two or more bands from an image. Here well first do this manually, and then show you some more efficient ways to perform band arithmetic in Earth Engine.</p>
<section id="arithmetic-calculation-of-ndvi" class="level3" data-number="5.1.1">
<h3 data-number="5.1.1" class="anchored" data-anchor-id="arithmetic-calculation-of-ndvi"><span class="header-section-number">5.1.1</span> Arithmetic Calculation of NDVI</h3>
<section id="arithmetic-calculation-of-ndvi" class="level4" data-number="4.1.1.1">
<h4 data-number="4.1.1.1" class="anchored" data-anchor-id="arithmetic-calculation-of-ndvi"><span class="header-section-number">4.1.1.1</span> Arithmetic Calculation of NDVI</h4>
<p>The red and near-infrared bands provide a lot of information about vegetation due to vegetations high reflectance in these wavelengths. Take a look at Fig. F2.0.2 and note, in particular, that vegetation curves (graphed in green) have relatively high reflectance in the NIR range (approximately 750900 nm). Also note that vegetation has low reflectance in the red range (approximately 630690 nm), where sunlight is absorbed by chlorophyll. This suggests that if the red and near-infrared bands could be combined, they would provide substantial information about vegetation.</p>
<p>Soon after the launch of Landsat 1 in 1972, analysts worked to devise a robust single value that would convey the health of vegetation along a scale of 1 to 1. This yielded the NDVI, using the formula:</p>
<p><img src="F2/image1.png" class="img-fluid"> (F2.0.1)</p>
@@ -467,8 +453,8 @@ Chapter Information
</div>
<p>Using these simple arithmetic tools, you can build almost any index, or develop and visualize your own. Earth Engine allows you to quickly and easily calculate and display the index across a large area.</p>
</section>
<section id="single-operation-computation-of-normalized-difference-for-ndvi" class="level3" data-number="5.1.2">
<h3 data-number="5.1.2" class="anchored" data-anchor-id="single-operation-computation-of-normalized-difference-for-ndvi"><span class="header-section-number">5.1.2</span> Single-Operation Computation of Normalized Difference for NDVI</h3>
<section id="single-operation-computation-of-normalized-difference-for-ndvi" class="level4" data-number="4.1.1.2">
<h4 data-number="4.1.1.2" class="anchored" data-anchor-id="single-operation-computation-of-normalized-difference-for-ndvi"><span class="header-section-number">4.1.1.2</span> Single-Operation Computation of Normalized Difference for NDVI</h4>
<p>Normalized differences like NDVI are so common in remote sensing that Earth Engine provides the ability to do that particular sequence of subtraction, addition, and division in a single step, using the normalizedDifference method. This method takes an input image, along with bands you specify, and creates a normalized difference of those two bands. The NDVI computation previously created with band arithmetic can be replaced with one line of code:</p>
<div class="sourceCode" id="cb3"><pre class="sourceCode js code-with-copy"><code class="sourceCode javascript"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a><span class="co">// Now use the built-in normalizedDifference function to achieve the same outcome. </span></span>
<span id="cb3-2"><a href="#cb3-2" aria-hidden="true" tabindex="-1"></a><span class="kw">var</span> ndviND <span class="op">=</span> sfoImage<span class="op">.</span><span class="fu">normalizedDifference</span>([<span class="st">'B8'</span><span class="op">,</span> <span class="st">'B4'</span>])<span class="op">;</span> </span>
@@ -479,8 +465,8 @@ Chapter Information
<span id="cb3-7"><a href="#cb3-7" aria-hidden="true" tabindex="-1"></a>}<span class="op">,</span> <span class="st">'NDVI normalizedDiff'</span>)<span class="op">;</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<p>Note that the order in which you provide the two bands to normalizedDifference is important. We use B8, the near-infrared band, as the first parameter, and the red band B4 as the second. If your two computations of NDVI do not look identical when drawn to the screen, check to make sure that the order you have for the NIR and red bands is correct.</p>
</section>
<section id="using-normalized-difference-for-ndwi" class="level3" data-number="5.1.3">
<h3 data-number="5.1.3" class="anchored" data-anchor-id="using-normalized-difference-for-ndwi"><span class="header-section-number">5.1.3</span> Using Normalized Difference for NDWI</h3>
<section id="using-normalized-difference-for-ndwi" class="level4" data-number="4.1.1.3">
<h4 data-number="4.1.1.3" class="anchored" data-anchor-id="using-normalized-difference-for-ndwi"><span class="header-section-number">4.1.1.3</span> Using Normalized Difference for NDWI</h4>
<p>As mentioned, the normalized difference approach is used for many different indices. Lets apply the same normalizedDifference method to another index.</p>
<p>The Normalized Difference Water Index (NDWI) was developed by Gao (1996) as an index of vegetation water content. The index is sensitive to changes in the liquid content of vegetation canopies. This means that the index can be used, for example, to detect vegetation experiencing drought conditions or differentiate crop irrigation levels. In dry areas, crops that are irrigated can be differentiated from natural vegetation. It is also sometimes called the Normalized Difference Moisture Index (NDMI). NDWI is formulated as follows:</p>
<div class="quarto-figure quarto-figure-center">
@@ -521,11 +507,11 @@ Note
</div>
</section>
</section>
<section id="thresholding-masking-and-remapping-images" class="level2" data-number="5.2">
<h2 data-number="5.2" class="anchored" data-anchor-id="thresholding-masking-and-remapping-images"><span class="header-section-number">5.2</span> Thresholding, Masking, and Remapping Images</h2>
<section id="thresholding-masking-and-remapping-images" class="level3" data-number="4.1.2">
<h3 data-number="4.1.2" class="anchored" data-anchor-id="thresholding-masking-and-remapping-images"><span class="header-section-number">4.1.2</span> Thresholding, Masking, and Remapping Images</h3>
<p>The previous section in this chapter discussed how to use band arithmetic to manipulate images. Those methods created new continuous values by combining bands within an image. This section uses logical operators to categorize band or index values to create a categorized image.</p>
<section id="implementing-a-threshold" class="level3" data-number="5.2.1">
<h3 data-number="5.2.1" class="anchored" data-anchor-id="implementing-a-threshold"><span class="header-section-number">5.2.1</span> Implementing a Threshold</h3>
<section id="implementing-a-threshold" class="level4" data-number="4.1.2.1">
<h4 data-number="4.1.2.1" class="anchored" data-anchor-id="implementing-a-threshold"><span class="header-section-number">4.1.2.1</span> Implementing a Threshold</h4>
<p>Implementing a threshold uses a number (the threshold value) and logical operators to help us partition the variability of images into categories. For example, recall our map of NDVI. High amounts of vegetation have NDVI values near 1 and non-vegetated areas are near 0. If we want to see what areas of the map have vegetation, we can use a threshold to generalize the NDVI value in each pixel as being either “no vegetation” or “vegetation”. That is a substantial simplification, to be sure, but can help us to better comprehend the rich variation on the Earths surface. This type of categorization may be useful if, for example, we want to look at the proportion of a city that is vegetated. Lets create a Sentinel-2 map of NDVI near Seattle, Washington, USA. Enter the code below in a new script.</p>
<div class="sourceCode" id="cb5"><pre class="sourceCode js code-with-copy"><code class="sourceCode javascript"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a><span class="co">// Create an NDVI image using Sentinel 2. </span></span>
<span id="cb5-2"><a href="#cb5-2" aria-hidden="true" tabindex="-1"></a><span class="kw">var</span> seaPoint <span class="op">=</span> ee<span class="op">.</span><span class="at">Geometry</span><span class="op">.</span><span class="fu">Point</span>(<span class="op">-</span><span class="fl">122.2040</span><span class="op">,</span> <span class="fl">47.6221</span>)<span class="op">;</span> </span>
@@ -573,8 +559,8 @@ Note
<p>Use the Inspector tool to explore this new layer. If you click on a green location, that NDVI should be greater than 0.5. If you click on a white pixel, the NDVI value should be equal to or less than 0.5.</p>
<p>Other operators in this Boolean family include less than (lt), less than or equal to (lte), equal to (eq), not equal to (neq), and greater than or equal to (gte) and more.</p>
</section>
<section id="building-complex-categorizations-with-.where" class="level3" data-number="5.2.2">
<h3 data-number="5.2.2" class="anchored" data-anchor-id="building-complex-categorizations-with-.where"><span class="header-section-number">5.2.2</span> Building Complex Categorizations with .where</h3>
<section id="building-complex-categorizations-with-.where" class="level4" data-number="4.1.2.2">
<h4 data-number="4.1.2.2" class="anchored" data-anchor-id="building-complex-categorizations-with-.where"><span class="header-section-number">4.1.2.2</span> Building Complex Categorizations with .where</h4>
<p>A binary map classifying NDVI is very useful. However, there are situations where you may want to split your image into more than two bins. Earth Engine provides a tool, the where method, that conditionally evaluates to true or false within each pixel depending on the outcome of a test. This is analogous to an if statement seen commonly in other languages. However, to perform this logic when programming for Earth Engine, we avoid using the JavaScript if statement. Importantly, JavaScript if commands are not calculated on Googles servers, and can create serious problems when running your code—in effect, the servers try to ship all of the information to be executed to your own computers browser, which is very underequipped for such enormous tasks. Instead, we use the where clause for conditional logic.</p>
<p>Suppose instead of just splitting the forested areas from the non-forested areas in our NDVI, we want to split the image into likely water, non-forested, and forested areas. We can use where and thresholds of -0.1 and 0.5. We will start by creating an image using ee.Image. We then clip the new image so that it covers the same area as our seaNDVI layer.</p>
<div class="sourceCode" id="cb7"><pre class="sourceCode js code-with-copy"><code class="sourceCode javascript"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a><span class="co">// Implement .where. </span></span>
@@ -602,8 +588,8 @@ Note
</figure>
</div>
</section>
<section id="masking-specific-values-in-an-image" class="level3" data-number="5.2.3">
<h3 data-number="5.2.3" class="anchored" data-anchor-id="masking-specific-values-in-an-image"><span class="header-section-number">5.2.3</span> Masking Specific Values in an Image</h3>
<section id="masking-specific-values-in-an-image" class="level4" data-number="4.1.2.3">
<h4 data-number="4.1.2.3" class="anchored" data-anchor-id="masking-specific-values-in-an-image"><span class="header-section-number">4.1.2.3</span> Masking Specific Values in an Image</h4>
<p>Masking an image is a technique that removes specific areas of an image—those covered by the mask—from being displayed or analyzed. Earth Engine allows you to both view the current mask and update the mask.</p>
<div class="sourceCode" id="cb8"><pre class="sourceCode js code-with-copy"><code class="sourceCode javascript"><span id="cb8-1"><a href="#cb8-1" aria-hidden="true" tabindex="-1"></a><span class="co">// Implement masking. </span></span>
<span id="cb8-2"><a href="#cb8-2" aria-hidden="true" tabindex="-1"></a><span class="co">// View the seaVeg layer's current mask. </span></span>
@@ -647,8 +633,8 @@ Note
</figure>
</div>
</section>
<section id="remapping-values-in-an-image" class="level3" data-number="5.2.4">
<h3 data-number="5.2.4" class="anchored" data-anchor-id="remapping-values-in-an-image"><span class="header-section-number">5.2.4</span> Remapping Values in an Image</h3>
<section id="remapping-values-in-an-image" class="level4" data-number="4.1.2.4">
<h4 data-number="4.1.2.4" class="anchored" data-anchor-id="remapping-values-in-an-image"><span class="header-section-number">4.1.2.4</span> Remapping Values in an Image</h4>
<p>Remapping takes specific values in an image and assigns them a different value. This is particularly useful for categorical datasets, including those you read about in Chap. F1.2 and those we have created earlier in this chapter.</p>
<p>Lets use the remap method to change the values for our seaWhere layer. Note that since were changing the middle value to be the largest, well need to adjust our palette as well.</p>
<div class="sourceCode" id="cb12"><pre class="sourceCode js code-with-copy"><code class="sourceCode javascript"><span id="cb12-1"><a href="#cb12-1" aria-hidden="true" tabindex="-1"></a><span class="co">// Implement remapping. </span></span>
@@ -683,30 +669,12 @@ Note
</div>
</section>
</section>
<section id="synthesis" class="level2 unnumbered">
<h2 class="unnumbered anchored" data-anchor-id="synthesis">Synthesis</h2>
<p>Assignment 1. In addition to vegetation indices and other land cover indices, you can use properties of different soil types to create geological indices. The Clay Minerals Ratio (CMR) is one of these. This index highlights soils containing clay and alunite, which absorb radiation in the SWIR portion (2.02.3 μm) of the spectrum.</p>
<p><img src="F2/image3.png" class="img-fluid"></p>
<p>SWIR 1 should be in the 1.551.75 µm range, and SWIR 2 should be in the 2.082.35 µm range. Calculate and display CMR at the following point: ee.Geometry.Point(-100.543, 33.456). Dont forget to use Map.centerObject.</p>
<p>Weve selected an area of Texas known for its clay soils. Compare this with an area without clay soils (for example, try an area around Seattle or Tacoma, Washington, USA). Note that this index will also pick up roads and other paved areas.</p>
<p>Assignment 2. Calculate the Iron Oxide Ratio, which can be used to detect hydrothermally altered rocks (e.g., from volcanoes) that contain iron-bearing sulfides which have been oxidized (Segal, 1982).</p>
<p>Heres the formula:</p>
<p><img src="F2/image4.png" class="img-fluid"></p>
<p>Red should be the 0.630.69 µm spectral range and Blue the 0.450.52 µm. Using Landsat 8, you can also find an interesting area to map by considering where these types of rocks might occur.</p>
<p>Assignment 3. Calculate the Normalized Difference Built-Up Index (NDBI) for the sfoImage used in this chapter.</p>
<p>The NDBI was developed by Zha et al.&nbsp;(2003) to aid in differentiating urban areas (e.g., densely clustered buildings and roads) from other land cover types. The index exploits the fact that urban areas, which generally have a great deal of impervious surface cover, reflect SWIR very strongly. If you like, refer back to Fig. F2.0.2.</p>
<p>The formula is:</p>
<p><img src="F2/image5.png" class="img-fluid"></p>
<p>Using what we know about Sentinel-2 bands, compute NDBI and display it.</p>
<p>Bonus: Note that NDBI is the negative of NDWI computed earlier. We can prove this by using the JavaScript reverse method to reverse the palette used for NDWI in Earth Engine. This method reverses the order of items in the JavaScript list. Create a new palette for NDBI using the reverse method and display the map. As a hint, here is code to use the reverse method.</p>
<p>var barePalette = waterPalette.reverse();</p>
</section>
<section id="conclusion" class="level2 unnumbered">
<h2 class="unnumbered anchored" data-anchor-id="conclusion">Conclusion</h2>
<section id="conclusion" class="level3 unnumbered">
<h3 class="unnumbered anchored" data-anchor-id="conclusion">Conclusion</h3>
<p>In this chapter, you learned how to select multiple bands from an image and calculate indices. You also learned about thresholding values in an image, slicing them into multiple categories using thresholds. It is also possible to work with one set of class numbers and remap them quickly to another set. Using these techniques, you have some of the basic tools of image manipulation. In subsequent chapters you will encounter more complex and specialized image manipulation techniques, including pixel-based image transformations (Chap. F3.1), neighborhood-based image transformations (Chap. F3.2), and object-based image analysis (Chap. F3.3).</p>
</section>
<section id="references" class="level2 unnumbered">
<h2 class="unnumbered anchored" data-anchor-id="references">References</h2>
<section id="references" class="level3 unnumbered">
<h3 class="unnumbered anchored" data-anchor-id="references">References</h3>
<p>Baig MHA, Zhang L, Shuai T, Tong Q (2014) Derivation of a tasselled cap transformation based on Landsat 8 at-satellite reflectance. Remote Sens Lett 5:423431. https://doi.org/10.1080/2150704X.2014.915434</p>
<p>Crist EP (1985) A TM tasseled cap equivalent transformation for reflectance factor data. Remote Sens Environ 17:301306. https://doi.org/10.1016/0034-4257(85)90102-6</p>
<p>Drury SA (1987) Image interpretation in geology. Geocarto Int 2:48. https://doi.org/10.1080/10106048709354098</p>
@@ -722,8 +690,8 @@ Note
<p>Souza Jr CM, Siqueira JV, Sales MH, et al (2013) Ten-year Landsat classification of deforestation and forest degradation in the Brazilian Amazon. Remote Sens 5:54935513. https://doi.org/10.3390/rs5115493</p>
</section>
</section>
<section id="interpreting-an-image-classification" class="level1" data-number="6">
<h1 data-number="6"><span class="header-section-number">6</span> Interpreting an Image: Classification</h1>
<section id="interpreting-an-image-classification" class="level2" data-number="4.2">
<h2 data-number="4.2" class="anchored" data-anchor-id="interpreting-an-image-classification"><span class="header-section-number">4.2</span> Interpreting an Image: Classification</h2>
<div class="callout-tip callout callout-style-default callout-captioned">
<div class="callout-header d-flex align-content-center">
<div class="callout-icon-container">
@@ -734,16 +702,16 @@ Chapter Information
</div>
</div>
<div class="callout-body-container callout-body">
<section id="author-1" class="level2 unlisted unnumbered">
<h2 class="unlisted unnumbered anchored" data-anchor-id="author-1">Author</h2>
<section id="author-1" class="level4 unlisted unnumbered">
<h4 class="unlisted unnumbered anchored" data-anchor-id="author-1">Author</h4>
<p>Andréa Puzzi Nicolau, Karen Dyson, David Saah, Nicholas Clinton</p>
</section>
<section id="overview-1" class="level2 unlisted unnumbered">
<h2 class="unlisted unnumbered anchored" data-anchor-id="overview-1">Overview</h2>
<section id="overview-1" class="level4 unlisted unnumbered">
<h4 class="unlisted unnumbered anchored" data-anchor-id="overview-1">Overview</h4>
<p>Image classification is a fundamental goal of remote sensing. It takes the user from viewing an image to labeling its contents. This chapter introduces readers to the concept of classification and walks users through the many options for image classification in Earth Engine. You will explore the processes of training data collection, classifier selection, classifier training, and image classification.</p>
</section>
<section id="learning-outcomes-1" class="level2 unlisted unnumbered">
<h2 class="unlisted unnumbered anchored" data-anchor-id="learning-outcomes-1">Learning Outcomes</h2>
<section id="learning-outcomes-1" class="level4 unlisted unnumbered">
<h4 class="unlisted unnumbered anchored" data-anchor-id="learning-outcomes-1">Learning Outcomes</h4>
<ul>
<li>Running a classification in Earth Engine.</li>
<li>Understanding the difference between supervised and unsupervised classification.</li>
@@ -752,8 +720,8 @@ Chapter Information
<li>Learning the basics of the hexadecimal numbering system.</li>
</ul>
</section>
<section id="assumes-you-know-how-to-1" class="level2 unlisted unnumbered">
<h2 class="unlisted unnumbered anchored" data-anchor-id="assumes-you-know-how-to-1">Assumes you know how to:</h2>
<section id="assumes-you-know-how-to-1" class="level4 unlisted unnumbered">
<h4 class="unlisted unnumbered anchored" data-anchor-id="assumes-you-know-how-to-1">Assumes you know how to:</h4>
<ul>
<li>Import images and image collections, filter, and visualize (Part F1).</li>
<li>Understand bands and how to select them (Chap. F1.2, Chap. F2.0).</li>
@@ -761,8 +729,8 @@ Chapter Information
</section>
</div>
</div>
<section id="introduction-1" class="level2 unlisted unnumbered">
<h2 class="unlisted unnumbered anchored" data-anchor-id="introduction-1">Introduction</h2>
<section id="introduction-1" class="level3 unlisted unnumbered">
<h3 class="unlisted unnumbered anchored" data-anchor-id="introduction-1">Introduction</h3>
<p>Classification is addressed in a broad range of fields, including mathematics, statistics, data mining, machine learning, and more. For a deeper treatment of classification, interested readers may see some of the following suggestions: Witten et al.&nbsp;(2011), Hastie et al.&nbsp;(2009), Goodfellow et al.&nbsp;(2016), Gareth et al.&nbsp;(2013), Géron (2019), Müller et al.&nbsp;(2016), or Witten et al.&nbsp;(2005). Unlike regression, which predicts continuous variables, classification predicts categorical, or discrete, variables—variables with a finite number of categories (e.g., age range).</p>
<p>In remote sensing, image classification is an attempt to categorize all pixels in an image into a finite number of labeled land cover and/or land use classes. The resulting classified image is a simplified thematic map derived from the original image (Fig. F2.1.1). Land cover and land use information is essential for many environmental and socioeconomic applications, including natural resource management, urban planning, biodiversity conservation, agricultural monitoring, and carbon accounting.</p>
<div class="quarto-figure quarto-figure-center">
@@ -774,8 +742,8 @@ Chapter Information
<p>Image classification techniques for generating land cover and land use information have been in use since the 1980s (Li et al.&nbsp;2014). Here, we will cover the concepts of pixel-based supervised and unsupervised classifications, testing out different classifiers. Chapter F3.3 covers the concept and application of object-based classification.</p>
<p>It is important to define land use and land cover. Land cover relates to the physical characteristics of the surface: simply put, it documents whether an area of the Earths surface is covered by forests, water, impervious surfaces, etc. Land use refers to how this land is being used by people. For example, herbaceous vegetation is considered a land cover but can indicate different land uses: the grass in a pasture is an agricultural land use, whereas the grass in an urban area can be classified as a park.</p>
</section>
<section id="supervised-classification" class="level2" data-number="6.1">
<h2 data-number="6.1" class="anchored" data-anchor-id="supervised-classification"><span class="header-section-number">6.1</span> Supervised Classification</h2>
<section id="supervised-classification" class="level3" data-number="4.2.1">
<h3 data-number="4.2.1" class="anchored" data-anchor-id="supervised-classification"><span class="header-section-number">4.2.1</span> Supervised Classification</h3>
<p>If you have not already done so, be sure to add the books code repository to the Code Editor by entering <a href="https://www.google.com/url?q=https://code.earthengine.google.com/?accept_repo%3Dprojects/gee-edu/book&amp;sa=D&amp;source=editors&amp;ust=1671458829866098&amp;usg=AOvVaw16x5swm9HlorS5Mbw7E42X"></a><a href="https://www.google.com/url?q=https://code.earthengine.google.com/?accept_repo%3Dprojects/gee-edu/book&amp;sa=D&amp;source=editors&amp;ust=1671458829866485&amp;usg=AOvVaw0-N-JCWWgnM493BKa7Ichm">https://code.earthengine.google.com/?accept_repo=projects/gee-edu/book</a> into your browser. The books scripts will then be available in the script manager panel. If you have trouble finding the repo, you can visit <a href="https://www.google.com/url?q=https://docs.google.com/presentation/d/1Kt6wGNoesYm__Cu3k3bnlbbyPN6m9SF4hQHK-pIDHfc/edit%23slide%3Did.g18a7b4b055d_0_624&amp;sa=D&amp;source=editors&amp;ust=1671458829866823&amp;usg=AOvVaw0ytMyRvutssBcVr2GdcBHA">this link</a> for help.</p>
<p>Supervised classification uses a training dataset with known labels and representing the spectral characteristics of each land cover class of interest to “supervise” the classification. The overall approach of a supervised classification in Earth Engine is summarized as follows:</p>
<ol type="1">
@@ -996,8 +964,8 @@ Note
</div>
</div>
</section>
<section id="unsupervised-classification" class="level2" data-number="6.2">
<h2 data-number="6.2" class="anchored" data-anchor-id="unsupervised-classification"><span class="header-section-number">6.2</span> Unsupervised Classification</h2>
<section id="unsupervised-classification" class="level3" data-number="4.2.2">
<h3 data-number="4.2.2" class="anchored" data-anchor-id="unsupervised-classification"><span class="header-section-number">4.2.2</span> Unsupervised Classification</h3>
<p>In an unsupervised classification, we have the opposite process of supervised classification. Spectral classes are grouped first and then categorized into clusters. Therefore, in Earth Engine, these classifiers are ee.Clusterer objects. They are “self-taught” algorithms that do not use a set of labeled training data (i.e., they are “unsupervised”). You can think of it as performing a task that you have not experienced before, starting by gathering as much information as possible. For example, imagine learning a new language without knowing the basic grammar, learning only by watching a TV series in that language, listening to examples, and finding patterns.</p>
<p>Similar to the supervised classification, unsupervised classification in Earth Engine has this workflow:</p>
<ol type="1">
@@ -1055,22 +1023,12 @@ Note
</div>
</div>
</section>
<section id="synthesis-1" class="level2 unnumbered">
<h2 class="unnumbered anchored" data-anchor-id="synthesis-1">Synthesis</h2>
<p>Test if you can improve the classifications by completing the following assignments.</p>
<p>Assignment 1. For the supervised classification, try collecting more points for each class. The more points you have, the more spectrally represented the classes are. It is good practice to collect points across the entire composite and not just focus on one location. Also look for pixels of the same class that show variability. For example, for the water class, collect pixels in parts of rivers that vary in color. For the developed class, collect pixels from different rooftops.</p>
<p>Assignment 2. Add more predictors. Usually, the more spectral information you feed the classifier, the easier it is to separate classes. Try calculating and incorporating a band of NDVI or the Normalized Difference Water Index (Chap. F2.0) as a predictor band. Does this help the classification? Check for developed areas that were being classified as herbaceous or vice versa.</p>
<p>Assignment 3. Use more trees in the Random Forest classifier. Do you see any improvements compared to 50 trees? Note that the more trees you have, the longer it will take to compute the results, and that more trees might not always mean better results.</p>
<p>Assignment 4. Increase the number of samples that are extracted from the composite in the unsupervised classification. Does that improve the result?</p>
<p>Assignment 5. Increase the number k of clusters for the k-means algorithm. What would happen if you tried 10 classes? Does the classified map result in meaningful classes?</p>
<p>Assignment 6. Test other clustering algorithms. We only used k-means; try other options under the ee.Clusterer object.</p>
</section>
<section id="conclusion-1" class="level2 unnumbered">
<h2 class="unnumbered anchored" data-anchor-id="conclusion-1">Conclusion</h2>
<section id="conclusion-1" class="level3 unnumbered">
<h3 class="unnumbered anchored" data-anchor-id="conclusion-1">Conclusion</h3>
<p>Classification algorithms are key for many different applications because they allow you to predict categorical variables. You should now understand the difference between supervised and unsupervised classification and have the basic knowledge on how to handle misclassifications. By being able to map the landscape for land use and land cover, we will also be able to monitor how it changes (Part F4).</p>
</section>
<section id="references-1" class="level2 unnumbered">
<h2 class="unnumbered anchored" data-anchor-id="references-1">References</h2>
<section id="references-1" class="level3 unnumbered">
<h3 class="unnumbered anchored" data-anchor-id="references-1">References</h3>
<p>Breiman L (2001) Random forests. Mach Learn 45:532. https://doi.org/10.1023/A:1010933404324</p>
<p>Gareth J, Witten D, Hastie T, Tibshirani R (2013) An Introduction to Statistical Learning. Springer</p>
<p>Géron A (2019) Hands-on Machine Learning with Scikit-Learn, Keras and TensorFlow: Concepts, Tools, and Techniques to Build Intelligent Systems. OReilly Media, Inc.</p>
@@ -1082,8 +1040,8 @@ Note
<p>Witten IH, Frank E, Hall MA, et al (2005) Practical machine learning tools and techniques. In: Data Mining. pp 4</p>
</section>
</section>
<section id="accuracy-assessment-quantifying-classification-quality" class="level1" data-number="7">
<h1 data-number="7"><span class="header-section-number">7</span> Accuracy Assessment: Quantifying Classification Quality</h1>
<section id="accuracy-assessment-quantifying-classification-quality" class="level2" data-number="4.3">
<h2 data-number="4.3" class="anchored" data-anchor-id="accuracy-assessment-quantifying-classification-quality"><span class="header-section-number">4.3</span> Accuracy Assessment: Quantifying Classification Quality</h2>
<div class="callout-tip callout callout-style-default callout-captioned">
<div class="callout-header d-flex align-content-center">
<div class="callout-icon-container">
@@ -1094,16 +1052,16 @@ Chapter Information
</div>
</div>
<div class="callout-body-container callout-body">
<section id="author-2" class="level2 unlisted unnumbered">
<h2 class="unlisted unnumbered anchored" data-anchor-id="author-2">Author</h2>
<section id="author-2" class="level4 unlisted unnumbered">
<h4 class="unlisted unnumbered anchored" data-anchor-id="author-2">Author</h4>
<p>Andréa Puzzi Nicolau, Karen Dyson, David Saah, Nicholas Clinton</p>
</section>
<section id="overview-2" class="level2 unlisted unnumbered">
<h2 class="unlisted unnumbered anchored" data-anchor-id="overview-2">Overview</h2>
<section id="overview-2" class="level4 unlisted unnumbered">
<h4 class="unlisted unnumbered anchored" data-anchor-id="overview-2">Overview</h4>
<p>This chapter will enable you to assess the accuracy of an image classification. You will learn about different metrics and ways to quantify classification quality in Earth Engine. Upon completion, you should be able to evaluate whether your classification needs improvement and know how to proceed when it does.</p>
</section>
<section id="learning-outcomes-2" class="level2 unlisted unnumbered">
<h2 class="unlisted unnumbered anchored" data-anchor-id="learning-outcomes-2">Learning Outcomes</h2>
<section id="learning-outcomes-2" class="level4 unlisted unnumbered">
<h4 class="unlisted unnumbered anchored" data-anchor-id="learning-outcomes-2">Learning Outcomes</h4>
<ul>
<li>Learning how to perform accuracy assessment in Earth Engine.</li>
<li>Understanding how to generate and read a confusion matrix.</li>
@@ -1111,8 +1069,8 @@ Chapter Information
<li>Understanding the difference between users and producers accuracy, and the difference between omission and commission errors.</li>
</ul>
</section>
<section id="assumes-you-know-how-to-2" class="level2 unlisted unnumbered">
<h2 class="unlisted unnumbered anchored" data-anchor-id="assumes-you-know-how-to-2">Assumes you know how to:</h2>
<section id="assumes-you-know-how-to-2" class="level4 unlisted unnumbered">
<h4 class="unlisted unnumbered anchored" data-anchor-id="assumes-you-know-how-to-2">Assumes you know how to:</h4>
<ul>
<li>Create a graph using ui.Chart (Chap. F1.3).</li>
<li>Perform a supervised Random Forest image classification (Chap. F2.1).</li>
@@ -1120,15 +1078,15 @@ Chapter Information
</section>
</div>
</div>
<section id="introduction-2" class="level2 unlisted unnumbered">
<h2 class="unlisted unnumbered anchored" data-anchor-id="introduction-2">Introduction</h2>
<section id="introduction-2" class="level3 unlisted unnumbered">
<h3 class="unlisted unnumbered anchored" data-anchor-id="introduction-2">Introduction</h3>
<p>Any map or remotely sensed product is a generalization or model that will have inherent errors. Products derived from remotely sensed data used for scientific purposes and policymaking require a quantitative measure of accuracy to strengthen the confidence in the information generated (Foody 2002, Strahler et al.&nbsp;2006, Olofsson et al.&nbsp;2014). Accuracy assessment is a crucial part of any classification project, as it measures the degree to which the classification agrees with another data source that is considered to be accurate, ground-truth data (i.e., “reality”).</p>
<p>The history of accuracy assessment reveals increasing detail and rigor in the analysis, moving from a basic visual appraisal of the derived map (Congalton 1994, Foody 2002) to the definition of best practices for sampling and response designs and the calculation of accuracy metrics (Foody 2002, Stehman 2013, Olofsson et al.&nbsp;2014, Stehman and Foody 2019). The confusion matrix (also called the “error matrix”) (Stehman 1997) summarizes key accuracy metrics used to assess products derived from remotely sensed data.</p>
<p>In Chap. F2.1, we asked whether the classification results were satisfactory. In remote sensing, the quantification of the answer to that question is called accuracy assessment. In the classification context, accuracy measurements are often derived from a confusion matrix.</p>
<p>In a thorough accuracy assessment, we think carefully about the sampling design, the response design, and the analysis (Olofsson et al.&nbsp;2014). Fundamental protocols are taken into account to produce scientifically rigorous and transparent estimates of accuracy and area, which requires robust planning and time. In a standard setting, we would calculate the number of samples needed for measuring accuracy (sampling design). Here, we will focus mainly on the last step, analysis, by examining the confusion matrix and learning how to calculate the accuracy metrics. This will be done by partitioning the existing data into training and testing sets.</p>
</section>
<section id="quantifying-classification-accuracy-through-a-confusion-matrix" class="level2" data-number="7.1">
<h2 data-number="7.1" class="anchored" data-anchor-id="quantifying-classification-accuracy-through-a-confusion-matrix"><span class="header-section-number">7.1</span> Quantifying Classification Accuracy Through a Confusion Matrix</h2>
<section id="quantifying-classification-accuracy-through-a-confusion-matrix" class="level3" data-number="4.3.1">
<h3 data-number="4.3.1" class="anchored" data-anchor-id="quantifying-classification-accuracy-through-a-confusion-matrix"><span class="header-section-number">4.3.1</span> Quantifying Classification Accuracy Through a Confusion Matrix</h3>
<p>If you have not already done so, be sure to add the books code repository to the Code Editor by entering <a href="https://www.google.com/url?q=https://code.earthengine.google.com/?accept_repo%3Dprojects/gee-edu/book&amp;sa=D&amp;source=editors&amp;ust=1671458829937499&amp;usg=AOvVaw3qqOwSX_A-Pllh6X3X31q4"></a><a href="https://www.google.com/url?q=https://code.earthengine.google.com/?accept_repo%3Dprojects/gee-edu/book&amp;sa=D&amp;source=editors&amp;ust=1671458829937976&amp;usg=AOvVaw0WioXIhzue8-WoaX4UtabH">https://code.earthengine.google.com/?accept_repo=projects/gee-edu/book</a> into your browser. The books scripts will then be available in the script manager panel. If you have trouble finding the repo, you can visit <a href="https://www.google.com/url?q=https://docs.google.com/presentation/d/1Kt6wGNoesYm__Cu3k3bnlbbyPN6m9SF4hQHK-pIDHfc/edit%23slide%3Did.g18a7b4b055d_0_624&amp;sa=D&amp;source=editors&amp;ust=1671458829938470&amp;usg=AOvVaw2CH8V3-_qV99EcgMxUAaSO">this link</a> for help.</p>
<p>To illustrate some of the basic ideas about classification accuracy, we will revisit the data and location of part of Chap. F2.1, where we tested different classifiers and classified a Landsat image of the area around Milan, Italy. We will name this dataset data. This variable is a FeatureCollection with features containing the “class” values (Table F2.2.1) and spectral information of four land cover / land use classes: forest, developed, water, and herbaceous (see Fig. F2.1.8 and Fig. F2.1.9 for a refresher). We will also define a variable, predictionBands, which is a list of bands that will be used for prediction (classification)—the spectral information in the data variable.</p>
<p>Table F2.2.1 Land cover classes</p>
@@ -1253,8 +1211,8 @@ Note
</div>
</div>
</section>
<section id="hyperparameter-tuning" class="level2" data-number="7.2">
<h2 data-number="7.2" class="anchored" data-anchor-id="hyperparameter-tuning"><span class="header-section-number">7.2</span> Hyperparameter tuning</h2>
<section id="hyperparameter-tuning" class="level3" data-number="4.3.2">
<h3 data-number="4.3.2" class="anchored" data-anchor-id="hyperparameter-tuning"><span class="header-section-number">4.3.2</span> Hyperparameter tuning</h3>
<p>We can also assess how the number of trees in the Random Forest classifier affects the classification accuracy. Copy and paste the code below to create a function that charts the overall accuracy versus the number of trees used. The code tests from 5 to 100 trees at increments of 5, producing Fig. F2.2.2. (Do not worry too much about fully understanding each item at this stage of your learning. If you want to find out how these operations work, you can see more in Chaps. F4.0 and F4.1.)</p>
<div class="sourceCode" id="cb26"><pre class="sourceCode js code-with-copy"><code class="sourceCode javascript"><span id="cb26-1"><a href="#cb26-1" aria-hidden="true" tabindex="-1"></a><span class="co">// Hyperparameter tuning. </span></span>
<span id="cb26-2"><a href="#cb26-2" aria-hidden="true" tabindex="-1"></a><span class="kw">var</span> numTrees <span class="op">=</span> ee<span class="op">.</span><span class="at">List</span><span class="op">.</span><span class="fu">sequence</span>(<span class="dv">5</span><span class="op">,</span> <span class="dv">100</span><span class="op">,</span> <span class="dv">5</span>)<span class="op">;</span> </span>
@@ -1316,13 +1274,8 @@ Note
</div>
</div>
</section>
<section id="synthesis-2" class="level2 unnumbered">
<h2 class="unnumbered anchored" data-anchor-id="synthesis-2">Synthesis</h2>
<p>Assignment 1. Based on Sect. 1, test other classifiers (e.g., a Classification and Regression Tree or Support Vector Machine classifier) and compare the accuracy results with the Random Forest results. Which model performs better?</p>
<p>Assignment 2. Try setting a different seed in the randomColumn method and see how that affects the accuracy results. You can also change the split between the training and testing sets (e.g., 70/30 or 60/40).</p>
</section>
<section id="conclusion-2" class="level2 unnumbered">
<h2 class="unnumbered anchored" data-anchor-id="conclusion-2">Conclusion</h2>
<section id="conclusion-2" class="level3 unnumbered">
<h3 class="unnumbered anchored" data-anchor-id="conclusion-2">Conclusion</h3>
<p>You should now understand how to calculate how well your classifier is performing on the data used to build the model. This is a useful way to understand how a classifier is performing, because it can help indicate which classes are performing better than others. A poorly modeled class can sometimes be improved by, for example, collecting more training points for that class.</p>
<p>Nevertheless, a model may work well on training data but work poorly in locations randomly chosen in the study area. To understand a models behavior on testing data, analysts employ protocols required to produce scientifically rigorous and transparent estimates of the accuracy and area of each class in the study region. We will not explore those practices in this chapter, but if you are interested, there are tutorials and papers available online that can guide you through the process. Links to some of those tutorials can be found in the “For Further Reading” section of this book.</p>
<p>References</p>