mirror of
https://github.com/bellingcat/RS4OSINT.git
synced 2026-06-11 13:08:36 +03:00
full draft
This commit is contained in:
267
docs/F2.html
267
docs/F2.html
@@ -7,7 +7,7 @@
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
|
||||
|
||||
|
||||
<title>Google Earth Engine for OSINT - 4 Interpreting Images</title>
|
||||
<title>Remote Sensing for OSINT - 2 Interpreting Images</title>
|
||||
<style>
|
||||
code{white-space: pre-wrap;}
|
||||
span.smallcaps{font-variant: small-caps;}
|
||||
@@ -146,7 +146,7 @@ gtag('config', 'G-RK9ZLZQ6GL', { 'anonymize_ip': true});
|
||||
<header id="quarto-header" class="headroom fixed-top">
|
||||
<nav class="quarto-secondary-nav" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar" aria-controls="quarto-sidebar" aria-expanded="false" aria-label="Toggle sidebar navigation" onclick="if (window.quartoToggleHeadroom) { window.quartoToggleHeadroom(); }">
|
||||
<div class="container-fluid d-flex justify-content-between">
|
||||
<h1 class="quarto-secondary-nav-title"><span class="chapter-number">4</span> <span class="chapter-title">Interpreting Images</span></h1>
|
||||
<h1 class="quarto-secondary-nav-title"><span class="chapter-number">2</span> <span class="chapter-title">Interpreting Images</span></h1>
|
||||
<button type="button" class="quarto-btn-toggle btn" aria-label="Show secondary navigation">
|
||||
<i class="bi bi-chevron-right"></i>
|
||||
</button>
|
||||
@@ -162,19 +162,21 @@ gtag('config', 'G-RK9ZLZQ6GL', { 'anonymize_ip': true});
|
||||
<img src="./logo_white.png" alt="" class="sidebar-logo py-0 d-lg-inline d-none">
|
||||
</a>
|
||||
<div class="sidebar-title mb-0 py-0">
|
||||
<a href="./">Google Earth Engine for OSINT</a>
|
||||
<a href="./">Remote Sensing for OSINT</a>
|
||||
<div class="sidebar-tools-main tools-wide">
|
||||
<a href="https://github.com/oballinger/GEE_OSINT/" title="Source Code" class="sidebar-tool px-1"><i class="bi bi-github"></i></a>
|
||||
<a href="" title="Download" id="sidebar-tool-dropdown-0" class="sidebar-tool dropdown-toggle px-1" data-bs-toggle="dropdown" aria-expanded="false"><i class="bi bi-download"></i></a>
|
||||
<ul class="dropdown-menu" aria-labelledby="sidebar-tool-dropdown-0">
|
||||
<li>
|
||||
<a class="dropdown-item sidebar-tools-main-item" href="./Google-Earth-Engine-for-OSINT.pdf">
|
||||
<a class="dropdown-item sidebar-tools-main-item" href="./Remote-Sensing-
|
||||
-for-OSINT.pdf">
|
||||
<i class="bi bi-bi-file-pdf pe-1"></i>
|
||||
Download PDF
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="dropdown-item sidebar-tools-main-item" href="./Google-Earth-Engine-for-OSINT.epub">
|
||||
<a class="dropdown-item sidebar-tools-main-item" href="./Remote-Sensing-
|
||||
-for-OSINT.epub">
|
||||
<i class="bi bi-bi-journal pe-1"></i>
|
||||
Download ePub
|
||||
</a>
|
||||
@@ -210,10 +212,20 @@ gtag('config', 'G-RK9ZLZQ6GL', { 'anonymize_ip': true});
|
||||
<div class="sidebar-item-container">
|
||||
<a href="./index.html" class="sidebar-item-text sidebar-link">Introduction</a>
|
||||
</div>
|
||||
</li>
|
||||
<li class="sidebar-item">
|
||||
<div class="sidebar-item-container">
|
||||
<a href="./ch1.html" class="sidebar-item-text sidebar-link">Remote Sensing</a>
|
||||
</div>
|
||||
</li>
|
||||
<li class="sidebar-item">
|
||||
<div class="sidebar-item-container">
|
||||
<a href="./ch2.html" class="sidebar-item-text sidebar-link">Data Acquisition</a>
|
||||
</div>
|
||||
</li>
|
||||
<li class="sidebar-item sidebar-item-section">
|
||||
<div class="sidebar-item-container">
|
||||
<a class="sidebar-item-text sidebar-link text-start" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar-section-1" aria-expanded="true">Learning</a>
|
||||
<a class="sidebar-item-text sidebar-link text-start" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar-section-1" aria-expanded="true">A. Google Earth Engine</a>
|
||||
<a class="sidebar-item-toggle text-start" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar-section-1" aria-expanded="true">
|
||||
<i class="bi bi-chevron-right ms-2"></i>
|
||||
</a>
|
||||
@@ -221,44 +233,29 @@ gtag('config', 'G-RK9ZLZQ6GL', { 'anonymize_ip': true});
|
||||
<ul id="quarto-sidebar-section-1" class="collapse list-unstyled sidebar-section depth1 show">
|
||||
<li class="sidebar-item">
|
||||
<div class="sidebar-item-container">
|
||||
<a href="./ch1.html" class="sidebar-item-text sidebar-link"><span class="chapter-number">1</span> <span class="chapter-title">Remote Sensing</span></a>
|
||||
<a href="./F1.html" class="sidebar-item-text sidebar-link"><span class="chapter-number">1</span> <span class="chapter-title">Getting Started</span></a>
|
||||
</div>
|
||||
</li>
|
||||
<li class="sidebar-item">
|
||||
<div class="sidebar-item-container">
|
||||
<a href="./ch2.html" class="sidebar-item-text sidebar-link"><span class="chapter-number">2</span> <span class="chapter-title">Data Acquisition</span></a>
|
||||
<a href="./F2.html" class="sidebar-item-text sidebar-link active"><span class="chapter-number">2</span> <span class="chapter-title">Interpreting Images</span></a>
|
||||
</div>
|
||||
</li>
|
||||
<li class="sidebar-item">
|
||||
<div class="sidebar-item-container">
|
||||
<a href="./F1.html" class="sidebar-item-text sidebar-link"><span class="chapter-number">3</span> <span class="chapter-title">Getting Started</span></a>
|
||||
<a href="./F4.html" class="sidebar-item-text sidebar-link"><span class="chapter-number">3</span> <span class="chapter-title">Image Series</span></a>
|
||||
</div>
|
||||
</li>
|
||||
<li class="sidebar-item">
|
||||
<div class="sidebar-item-container">
|
||||
<a href="./F2.html" class="sidebar-item-text sidebar-link active"><span class="chapter-number">4</span> <span class="chapter-title">Interpreting Images</span></a>
|
||||
</div>
|
||||
</li>
|
||||
<li class="sidebar-item">
|
||||
<div class="sidebar-item-container">
|
||||
<a href="./F4.html" class="sidebar-item-text sidebar-link"><span class="chapter-number">5</span> <span class="chapter-title">Interpreting Image Series</span></a>
|
||||
</div>
|
||||
</li>
|
||||
<li class="sidebar-item">
|
||||
<div class="sidebar-item-container">
|
||||
<a href="./F5.html" class="sidebar-item-text sidebar-link"><span class="chapter-number">6</span> <span class="chapter-title">Vectors and Tables</span></a>
|
||||
</div>
|
||||
</li>
|
||||
<li class="sidebar-item">
|
||||
<div class="sidebar-item-container">
|
||||
<a href="./F6.html" class="sidebar-item-text sidebar-link"><span class="chapter-number">7</span> <span class="chapter-title">Advanced Topics</span></a>
|
||||
<a href="./F5.html" class="sidebar-item-text sidebar-link"><span class="chapter-number">4</span> <span class="chapter-title">Vectors and Tables</span></a>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="sidebar-item sidebar-item-section">
|
||||
<div class="sidebar-item-container">
|
||||
<a class="sidebar-item-text sidebar-link text-start" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar-section-2" aria-expanded="true">Case Studies</a>
|
||||
<a class="sidebar-item-text sidebar-link text-start" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar-section-2" aria-expanded="true">B. Case Studies</a>
|
||||
<a class="sidebar-item-toggle text-start" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar-section-2" aria-expanded="true">
|
||||
<i class="bi bi-chevron-right ms-2"></i>
|
||||
</a>
|
||||
@@ -283,6 +280,11 @@ gtag('config', 'G-RK9ZLZQ6GL', { 'anonymize_ip': true});
|
||||
<div class="sidebar-item-container">
|
||||
<a href="./blast.html" class="sidebar-item-text sidebar-link">Blast Damage Assessment</a>
|
||||
</div>
|
||||
</li>
|
||||
<li class="sidebar-item">
|
||||
<div class="sidebar-item-container">
|
||||
<a href="./object_detection.html" class="sidebar-item-text sidebar-link">Object Detection</a>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
@@ -295,24 +297,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">4.1</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">2.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">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="#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">2.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">2.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">4.2</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">2.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">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="#supervised-classification" id="toc-supervised-classification" class="nav-link" data-scroll-target="#supervised-classification"><span class="toc-section-number">2.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">2.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">4.3</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">2.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">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="#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">2.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">2.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>
|
||||
@@ -323,7 +325,7 @@ gtag('config', 'G-RK9ZLZQ6GL', { 'anonymize_ip': true});
|
||||
|
||||
<header id="title-block-header" class="quarto-title-block default">
|
||||
<div class="quarto-title">
|
||||
<h1 class="title d-none d-lg-block"><span class="chapter-number">4</span> <span class="chapter-title">Interpreting Images</span></h1>
|
||||
<h1 class="title d-none d-lg-block"><span class="chapter-number">2</span> <span class="chapter-title">Interpreting Images</span></h1>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -339,8 +341,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, you’ll work with bands, combining values to form indices and masking unwanted pixels. Then, you’ll 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="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>
|
||||
<section id="image-manipulation-bands-arithmetic-thresholds-and-masks" class="level2" data-number="2.1">
|
||||
<h2 data-number="2.1" class="anchored" data-anchor-id="image-manipulation-bands-arithmetic-thresholds-and-masks"><span class="header-section-number">2.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">
|
||||
@@ -393,12 +395,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="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>
|
||||
<section id="band-arithmetic-in-earth-engine" class="level3" data-number="2.1.1">
|
||||
<h3 data-number="2.1.1" class="anchored" data-anchor-id="band-arithmetic-in-earth-engine"><span class="header-section-number">2.1.1</span> Band Arithmetic in Earth Engine</h3>
|
||||
<p>If you have not already done so, be sure to add the book’s 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&sa=D&source=editors&ust=1671458829783542&usg=AOvVaw2f8xfEZP6c0zP_Ke8jL26U"></a><a href="https://www.google.com/url?q=https://code.earthengine.google.com/?accept_repo%3Dprojects/gee-edu/book&sa=D&source=editors&ust=1671458829783919&usg=AOvVaw2i09J44MzpMZkjV_JLEnNR">https://code.earthengine.google.com/?accept_repo=projects/gee-edu/book</a> into your browser. The book’s 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&sa=D&source=editors&ust=1671458829784270&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 we’ll 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="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>
|
||||
<section id="arithmetic-calculation-of-ndvi" class="level4" data-number="2.1.1.1">
|
||||
<h4 data-number="2.1.1.1" class="anchored" data-anchor-id="arithmetic-calculation-of-ndvi"><span class="header-section-number">2.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 vegetation’s 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 750–900 nm). Also note that vegetation has low reflectance in the red range (approximately 630–690 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>
|
||||
@@ -458,8 +460,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="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>
|
||||
<section id="single-operation-computation-of-normalized-difference-for-ndvi" class="level4" data-number="2.1.1.2">
|
||||
<h4 data-number="2.1.1.2" class="anchored" data-anchor-id="single-operation-computation-of-normalized-difference-for-ndvi"><span class="header-section-number">2.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>
|
||||
@@ -470,8 +472,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="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>
|
||||
<section id="using-normalized-difference-for-ndwi" class="level4" data-number="2.1.1.3">
|
||||
<h4 data-number="2.1.1.3" class="anchored" data-anchor-id="using-normalized-difference-for-ndwi"><span class="header-section-number">2.1.1.3</span> Using Normalized Difference for NDWI</h4>
|
||||
<p>As mentioned, the normalized difference approach is used for many different indices. Let’s 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">
|
||||
@@ -512,11 +514,11 @@ Note
|
||||
</div>
|
||||
</section>
|
||||
</section>
|
||||
<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>
|
||||
<section id="thresholding-masking-and-remapping-images" class="level3" data-number="2.1.2">
|
||||
<h3 data-number="2.1.2" class="anchored" data-anchor-id="thresholding-masking-and-remapping-images"><span class="header-section-number">2.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="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>
|
||||
<section id="implementing-a-threshold" class="level4" data-number="2.1.2.1">
|
||||
<h4 data-number="2.1.2.1" class="anchored" data-anchor-id="implementing-a-threshold"><span class="header-section-number">2.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 Earth’s surface. This type of categorization may be useful if, for example, we want to look at the proportion of a city that is vegetated. Let’s 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>
|
||||
@@ -564,8 +566,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="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>
|
||||
<section id="building-complex-categorizations-with-.where" class="level4" data-number="2.1.2.2">
|
||||
<h4 data-number="2.1.2.2" class="anchored" data-anchor-id="building-complex-categorizations-with-.where"><span class="header-section-number">2.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 Google’s 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 computer’s 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>
|
||||
@@ -593,8 +595,8 @@ Note
|
||||
</figure>
|
||||
</div>
|
||||
</section>
|
||||
<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>
|
||||
<section id="masking-specific-values-in-an-image" class="level4" data-number="2.1.2.3">
|
||||
<h4 data-number="2.1.2.3" class="anchored" data-anchor-id="masking-specific-values-in-an-image"><span class="header-section-number">2.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>
|
||||
@@ -638,8 +640,8 @@ Note
|
||||
</figure>
|
||||
</div>
|
||||
</section>
|
||||
<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>
|
||||
<section id="remapping-values-in-an-image" class="level4" data-number="2.1.2.4">
|
||||
<h4 data-number="2.1.2.4" class="anchored" data-anchor-id="remapping-values-in-an-image"><span class="header-section-number">2.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>Let’s use the remap method to change the values for our seaWhere layer. Note that since we’re changing the middle value to be the largest, we’ll 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>
|
||||
@@ -695,8 +697,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:5493–5513. https://doi.org/10.3390/rs5115493</p>
|
||||
</section>
|
||||
</section>
|
||||
<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>
|
||||
<section id="interpreting-an-image-classification" class="level2" data-number="2.2">
|
||||
<h2 data-number="2.2" class="anchored" data-anchor-id="interpreting-an-image-classification"><span class="header-section-number">2.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">
|
||||
@@ -747,8 +749,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. 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 Earth’s 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="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>
|
||||
<section id="supervised-classification" class="level3" data-number="2.2.1">
|
||||
<h3 data-number="2.2.1" class="anchored" data-anchor-id="supervised-classification"><span class="header-section-number">2.2.1</span> Supervised Classification</h3>
|
||||
<p>If you have not already done so, be sure to add the book’s 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&sa=D&source=editors&ust=1671458829866098&usg=AOvVaw16x5swm9HlorS5Mbw7E42X"></a><a href="https://www.google.com/url?q=https://code.earthengine.google.com/?accept_repo%3Dprojects/gee-edu/book&sa=D&source=editors&ust=1671458829866485&usg=AOvVaw0-N-JCWWgnM493BKa7Ichm">https://code.earthengine.google.com/?accept_repo=projects/gee-edu/book</a> into your browser. The book’s 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&sa=D&source=editors&ust=1671458829866823&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">
|
||||
@@ -784,18 +786,13 @@ Chapter Information
|
||||
<p></p><figcaption class="figure-caption">Fig. F2.1.2 Landsat image</figcaption><p></p>
|
||||
</figure>
|
||||
</div>
|
||||
<p>Using the Geometry Tools, we will create points on the Landsat image that represent land cover classes of interest to use as our training data. We’ll need to do two things: (1) identify where each land cover occurs on the ground, and (2) label the points with the proper class number. For this exercise, we will use the classes and codes shown in Table 2.1.1.</p>
|
||||
<p>Table 2.1.1 Land cover classes</p>
|
||||
<p>Class</p>
|
||||
<p>Class code</p>
|
||||
<p>Forest</p>
|
||||
<p>0</p>
|
||||
<p>Developed</p>
|
||||
<p>1</p>
|
||||
<p>Water</p>
|
||||
<p>2</p>
|
||||
<p>Herbaceous</p>
|
||||
<p>3</p>
|
||||
<p>Using the Geometry Tools, we will create points on the Landsat image that represent land cover classes of interest to use as our training data. We’ll need to do two things: (1) identify where each land cover occurs on the ground, and (2) label the points with the proper class number. For this exercise, we will use the classes and codes shown below:</p>
|
||||
<ul>
|
||||
<li>Forest: 0</li>
|
||||
<li>Developed: 1</li>
|
||||
<li>Water: 2</li>
|
||||
<li>Herbaceous: 3</li>
|
||||
</ul>
|
||||
<p>In the Geometry Tools, click on the marker option (Fig. F2.1.3). This will create a point geometry which will show up as an import named “geometry”. Click on the gear icon to configure this import.</p>
|
||||
<div class="quarto-figure quarto-figure-center">
|
||||
<figure class="figure">
|
||||
@@ -969,8 +966,8 @@ Note
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<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>
|
||||
<section id="unsupervised-classification" class="level3" data-number="2.2.2">
|
||||
<h3 data-number="2.2.2" class="anchored" data-anchor-id="unsupervised-classification"><span class="header-section-number">2.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">
|
||||
@@ -1045,8 +1042,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="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>
|
||||
<section id="accuracy-assessment-quantifying-classification-quality" class="level2" data-number="2.3">
|
||||
<h2 data-number="2.3" class="anchored" data-anchor-id="accuracy-assessment-quantifying-classification-quality"><span class="header-section-number">2.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">
|
||||
@@ -1090,21 +1087,17 @@ Chapter Information
|
||||
<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. 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="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>
|
||||
<section id="quantifying-classification-accuracy-through-a-confusion-matrix" class="level3" data-number="2.3.1">
|
||||
<h3 data-number="2.3.1" class="anchored" data-anchor-id="quantifying-classification-accuracy-through-a-confusion-matrix"><span class="header-section-number">2.3.1</span> Quantifying Classification Accuracy Through a Confusion Matrix</h3>
|
||||
<p>If you have not already done so, be sure to add the book’s 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&sa=D&source=editors&ust=1671458829937499&usg=AOvVaw3qqOwSX_A-Pllh6X3X31q4"></a><a href="https://www.google.com/url?q=https://code.earthengine.google.com/?accept_repo%3Dprojects/gee-edu/book&sa=D&source=editors&ust=1671458829937976&usg=AOvVaw0WioXIhzue8-WoaX4UtabH">https://code.earthengine.google.com/?accept_repo=projects/gee-edu/book</a> into your browser. The book’s 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&sa=D&source=editors&ust=1671458829938470&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>
|
||||
<p>Class</p>
|
||||
<p>Class value</p>
|
||||
<p>Forest</p>
|
||||
<p>0</p>
|
||||
<p>Developed</p>
|
||||
<p>1</p>
|
||||
<p>Water</p>
|
||||
<p>2</p>
|
||||
<p>Herbaceous</p>
|
||||
<p>3</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 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>Class Values:</p>
|
||||
<ul>
|
||||
<li>Forest: 0</li>
|
||||
<li>Developed: 1</li>
|
||||
<li>Water: 2</li>
|
||||
<li>Herbaceous: 3</li>
|
||||
</ul>
|
||||
<p>The first step is to partition the set of known values into training and testing sets in order to have something for the classifier to predict over that it has not been shown before (the testing set), mimicking unseen data that the model might see in the future. We add a column of random numbers to our FeatureCollection using the randomColumn method. Then, we filter the features into about 80% for training and 20% for testing using ee.Filter. Copy and paste the code below to partition the data and filter features based on the random number.</p>
|
||||
<div class="sourceCode" id="cb22"><pre class="sourceCode js code-with-copy"><code class="sourceCode javascript"><span id="cb22-1"><a href="#cb22-1" aria-hidden="true" tabindex="-1"></a><span class="co">// Import the reference dataset. </span></span>
|
||||
<span id="cb22-2"><a href="#cb22-2" aria-hidden="true" tabindex="-1"></a><span class="kw">var</span> data <span class="op">=</span> ee<span class="op">.</span><span class="fu">FeatureCollection</span>( <span class="st">'projects/gee-book/assets/F2-2/milan_data'</span>)<span class="op">;</span> </span>
|
||||
@@ -1129,16 +1122,42 @@ Chapter Information
|
||||
<span id="cb23-6"><a href="#cb23-6" aria-hidden="true" tabindex="-1"></a>})<span class="op">;</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
||||
<p>Now, let’s discuss what a confusion matrix is. A confusion matrix describes the quality of a classification by comparing the predicted values to the actual values. A simple example is a confusion matrix for a binary classification into the classes “positive” and “negative,” as shown in Table F2.2.1.</p>
|
||||
<p>Table F2.2.1 Confusion matrix for a binary classification where the classes are “positive” and “negative”</p>
|
||||
<p>Actual values</p>
|
||||
<p>Positive</p>
|
||||
<p>Negative</p>
|
||||
<p>Predicted values</p>
|
||||
<p>Positive</p>
|
||||
<p>TP (true positive)</p>
|
||||
<p>FP (false positive)</p>
|
||||
<p>Negative</p>
|
||||
<p>FN (false negative)</p>
|
||||
<p>TN (true negative)</p>
|
||||
<table class="table">
|
||||
<colgroup>
|
||||
<col style="width: 25%">
|
||||
<col style="width: 14%">
|
||||
<col style="width: 30%">
|
||||
<col style="width: 30%">
|
||||
</colgroup>
|
||||
<thead>
|
||||
<tr class="header">
|
||||
<th></th>
|
||||
<th></th>
|
||||
<th style="text-align: center;">Actual values</th>
|
||||
<th style="text-align: center;"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr class="odd">
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td style="text-align: center;">Positive</td>
|
||||
<td style="text-align: center;">Negative</td>
|
||||
</tr>
|
||||
<tr class="even">
|
||||
<td>Predicted values</td>
|
||||
<td>Positive</td>
|
||||
<td style="text-align: center;">TP (true positive)</td>
|
||||
<td style="text-align: center;">FP (false positive)</td>
|
||||
</tr>
|
||||
<tr class="odd">
|
||||
<td></td>
|
||||
<td>Negative</td>
|
||||
<td style="text-align: center;">FN (false negative)</td>
|
||||
<td style="text-align: center;">TN (true negative)</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<p>In Table F2.2.1, the columns represent the actual values (the truth), while the rows represent the predictions (the classification). “True positive” (TP) and “true negative” (TN) mean that the classification of a pixel matches the truth (e.g., a water pixel correctly classified as water). “False positive” (FP) and “false negative” (FN) mean that the classification of a pixel does not match the truth (e.g., a non-water pixel incorrectly classified as water).</p>
|
||||
<ul>
|
||||
<li>TP: classified as positive and the actual class is positive</li>
|
||||
@@ -1148,16 +1167,36 @@ Chapter Information
|
||||
</ul>
|
||||
<p>We can extract some statistical information from a confusion matrix.. Let’s look at an example to make this clearer. Table F2.2.2 is a confusion matrix for a sample of 1,000 pixels for a classifier that identifies whether a pixel is forest (positive) or non-forest (negative), a binary classification.</p>
|
||||
<p>Table F2.2.2 Confusion matrix for a binary classification where the classes are “positive” (forest) and “negative” (non-forest)</p>
|
||||
<p>Actual values</p>
|
||||
<p>Positive</p>
|
||||
<p>Negative</p>
|
||||
<p>Predicted values</p>
|
||||
<p>Positive</p>
|
||||
<p>307</p>
|
||||
<p>18</p>
|
||||
<p>Negative</p>
|
||||
<p>14</p>
|
||||
<p>661</p>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr class="header">
|
||||
<th></th>
|
||||
<th></th>
|
||||
<th style="text-align: center;">Actual values</th>
|
||||
<th style="text-align: center;"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr class="odd">
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td style="text-align: center;">Positive</td>
|
||||
<td style="text-align: center;">Negative</td>
|
||||
</tr>
|
||||
<tr class="even">
|
||||
<td>Predicted values</td>
|
||||
<td>Positive</td>
|
||||
<td style="text-align: center;">307</td>
|
||||
<td style="text-align: center;">18</td>
|
||||
</tr>
|
||||
<tr class="odd">
|
||||
<td></td>
|
||||
<td>Negative</td>
|
||||
<td style="text-align: center;">14</td>
|
||||
<td style="text-align: center;">661</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<p>In this case, the classifier correctly identified 307 forest pixels, wrongly classified 18 non-forest pixels as forest, correctly identified 661 non-forest pixels, and wrongly classified 14 forest pixels as non-forest. Therefore, the classifier was correct 968 times and wrong 32 times. Let’s calculate the main accuracy metrics for this example.</p>
|
||||
<p>The overall accuracy tells us what proportion of the reference data was classified correctly, and is calculated as the total number of correctly identified pixels divided by the total number of pixels in the sample.</p>
|
||||
<p><img src="F2/image6.png" class="img-fluid"></p>
|
||||
@@ -1216,8 +1255,8 @@ Note
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<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>
|
||||
<section id="hyperparameter-tuning" class="level3" data-number="2.3.2">
|
||||
<h3 data-number="2.3.2" class="anchored" data-anchor-id="hyperparameter-tuning"><span class="header-section-number">2.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>
|
||||
@@ -1548,12 +1587,12 @@ window.document.addEventListener("DOMContentLoaded", function (event) {
|
||||
<nav class="page-navigation">
|
||||
<div class="nav-page nav-page-previous">
|
||||
<a href="./F1.html" class="pagination-link">
|
||||
<i class="bi bi-arrow-left-short"></i> <span class="nav-page-text"><span class="chapter-number">3</span> <span class="chapter-title">Getting Started</span></span>
|
||||
<i class="bi bi-arrow-left-short"></i> <span class="nav-page-text"><span class="chapter-number">1</span> <span class="chapter-title">Getting Started</span></span>
|
||||
</a>
|
||||
</div>
|
||||
<div class="nav-page nav-page-next">
|
||||
<a href="./F4.html" class="pagination-link">
|
||||
<span class="nav-page-text"><span class="chapter-number">5</span> <span class="chapter-title">Interpreting Image Series</span></span> <i class="bi bi-arrow-right-short"></i>
|
||||
<span class="nav-page-text"><span class="chapter-number">3</span> <span class="chapter-title">Image Series</span></span> <i class="bi bi-arrow-right-short"></i>
|
||||
</a>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
Reference in New Issue
Block a user