|
7 | 7 | <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes"> |
8 | 8 |
|
9 | 9 | <meta name="author" content="Jan Verbesselt, Jorge Mendes de Jesus, Aldo Bergsma, Dainius Masiliunas, David Swinkels, Judith Verstegen, Corné Vreugdenhil, Arno Timmer"> |
10 | | -<meta name="dcterms.date" content="2026-09-23"> |
| 10 | +<meta name="dcterms.date" content="2026-09-28"> |
11 | 11 |
|
12 | 12 | <title>Raster data handling with Python – Python Raster</title> |
13 | 13 | <style> |
@@ -174,7 +174,7 @@ <h2 id="toc-title">On this page</h2> |
174 | 174 | <div> |
175 | 175 | <div class="quarto-title-meta-heading">Published</div> |
176 | 176 | <div class="quarto-title-meta-contents"> |
177 | | - <p class="date">September 23, 2026</p> |
| 177 | + <p class="date">September 28, 2026</p> |
178 | 178 | </div> |
179 | 179 | </div> |
180 | 180 |
|
@@ -236,7 +236,7 @@ <h2 class="anchored" data-anchor-id="setting-up-the-python-environment">Setting |
236 | 236 | <div class="cell"> |
237 | 237 | <div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb2"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="im">from</span> pathlib <span class="im">import</span> Path</span> |
238 | 238 | <span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a></span> |
239 | | -<span id="cb2-3"><a href="#cb2-3" aria-hidden="true" tabindex="-1"></a>base <span class="op">=</span> Path.home() <span class="co"># This references the location of your script</span></span> |
| 239 | +<span id="cb2-3"><a href="#cb2-3" aria-hidden="true" tabindex="-1"></a>base <span class="op">=</span> Path(<span class="st">'.'</span>) <span class="co"># This references the root of your current directory</span></span> |
240 | 240 | <span id="cb2-4"><a href="#cb2-4" aria-hidden="true" tabindex="-1"></a>(base <span class="op">/</span> <span class="st">"data"</span>).mkdir(exist_ok<span class="op">=</span><span class="va">True</span>)</span></code></pre></div><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></div> |
241 | 241 | </div> |
242 | 242 | <p>From now on, if you see the format combining strings and variables together with <code>/</code>’s like: <code>base / 'some_dir_name'</code>, it is Pathlib based path handling.</p> |
@@ -393,7 +393,7 @@ <h2 class="anchored" data-anchor-id="from-a-file-with-rasterio">From a file with |
393 | 393 | </div> |
394 | 394 | <div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb21"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb21-1"><a href="#cb21-1" aria-hidden="true" tabindex="-1"></a>show(dsm, title<span class="op">=</span><span class="st">'Digital Surface Model'</span>, cmap<span class="op">=</span><span class="st">'gist_ncar'</span>)</span></code></pre></div><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></div> |
395 | 395 | <div class="cell-output cell-output-stdout"> |
396 | | -<pre><code>C:\Users\timme073\AppData\Local\R\cache\R\RETICU~1\uv\cache\ARCHIV~1\C3WQR0~1\Lib\site-packages\matplotlib\colors.py:824: RuntimeWarning: overflow encountered in multiply |
| 396 | +<pre><code>C:\Users\timme073\AppData\Local\R\cache\R\RETICU~1\uv\cache\ARCHIV~1\WI1EAJ~1\Lib\site-packages\matplotlib\colors.py:824: RuntimeWarning: overflow encountered in multiply |
397 | 397 | xa *= self.N |
398 | 398 | <Axes: title={'center': 'Digital Surface Model'}></code></pre> |
399 | 399 | </div> |
@@ -591,11 +591,11 @@ <h2 class="anchored" data-anchor-id="computing-heights-of-buildings">Computing h |
591 | 591 | 3 13.348260 |
592 | 592 | 4 8.365085 |
593 | 593 | ... |
594 | | -189 0.921717 |
595 | | -190 4.211526 |
596 | | -191 4.733384 |
597 | | -192 2.511573 |
598 | | -193 3.897702 |
| 594 | +189 5.660699 |
| 595 | +190 0.847196 |
| 596 | +191 19.819857 |
| 597 | +192 4.211526 |
| 598 | +193 4.733384 |
599 | 599 | Name: CHM_mean, Length: 194, dtype: float64</code></pre> |
600 | 600 | </div> |
601 | 601 | </div> |
@@ -791,15 +791,15 @@ <h2 class="anchored" data-anchor-id="stac">STAC</h2> |
791 | 791 | <span id="cb58-18"><a href="#cb58-18" aria-hidden="true" tabindex="-1"></a><span class="co"># plot the cropped raster</span></span> |
792 | 792 | <span id="cb58-19"><a href="#cb58-19" aria-hidden="true" tabindex="-1"></a>plt.imshow(out_image[<span class="dv">0</span>], cmap<span class="op">=</span><span class="st">"viridis"</span>)</span></code></pre></div><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></div> |
793 | 793 | <div class="cell-output cell-output-stdout"> |
794 | | -<pre><code><matplotlib.image.AxesImage object at 0x000001AD8827C410></code></pre> |
| 794 | +<pre><code><matplotlib.image.AxesImage object at 0x000002DFAB2904D0></code></pre> |
795 | 795 | </div> |
796 | 796 | <div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb60"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb60-1"><a href="#cb60-1" aria-hidden="true" tabindex="-1"></a>plt.title(<span class="st">"Cropped raster over Wageningen"</span>)</span></code></pre></div><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></div> |
797 | 797 | <div class="cell-output cell-output-stdout"> |
798 | 798 | <pre><code>Text(0.5, 1.0, 'Cropped raster over Wageningen')</code></pre> |
799 | 799 | </div> |
800 | 800 | <div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb62"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb62-1"><a href="#cb62-1" aria-hidden="true" tabindex="-1"></a>plt.colorbar(label<span class="op">=</span><span class="st">"Value"</span>)</span></code></pre></div><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></div> |
801 | 801 | <div class="cell-output cell-output-stdout"> |
802 | | -<pre><code><matplotlib.colorbar.Colorbar object at 0x000001AD85F34A90></code></pre> |
| 802 | +<pre><code><matplotlib.colorbar.Colorbar object at 0x000002DFA8BA13D0></code></pre> |
803 | 803 | </div> |
804 | 804 | <div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb64"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb64-1"><a href="#cb64-1" aria-hidden="true" tabindex="-1"></a>plt.show()</span></code></pre></div><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></div> |
805 | 805 | <div class="cell-output-display"> |
|
0 commit comments