You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: index.Rmd
+18-13Lines changed: 18 additions & 13 deletions
Original file line number
Diff line number
Diff line change
@@ -144,7 +144,7 @@ with open('data/AHN3_05m_DTM.tif', 'wb') as file:
144
144
file.write(response.read())
145
145
```
146
146
147
-
Before continuing, please check if this step was successful.
147
+
Before continuing, please check if this step was successful (*Hint: you can check if files have been written into corresponding directory*).
148
148
149
149
## From a file with GDAL
150
150
[GDAL](https://gdal.org/) handles raster and vector geospatial data formats with Python, Java, R and C APIs. When opening a raster file in gdal, the object has a hierarchical structure starting at the Dataset level. A Dataset has a Geotransform (metadata) and can contain one or more Bands. Each Band has a Data array and potentially Overviews.
@@ -156,6 +156,7 @@ Before continuing, please check if this step was successful.
156
156
</center>
157
157
</figure>
158
158
159
+
159
160
Let us open the file we just saved. You will see you first get the dataset, and need to access the band (even though there is only one), before the data array can be accessed.
160
161
161
162
```{python, eval=FALSE}
@@ -177,12 +178,12 @@ ds = None
177
178
178
179
```{block, type="alert alert-success"}
179
180
> **Question 1**: Why do we set ds to None at the end of your script? What may happen if you do not do that?
180
-
181
-
```
182
181
<details>
183
-
<summary>**Click for answer**</summary>
182
+
<summary>*Click for answer*</summary>
184
183
Keeping files open may leave you vulnerable to losing data, (Geo)Pandas manage resources under the hood so you don't explicitly need to close files, but for the case of GDAL, and as you will later see, Rasterio, it's important to close your files or open them with a context manager `with open ...`
185
184
</details>
185
+
```
186
+
186
187
187
188
188
189
The GDAL Python API is not the best documented Python module. Therefore, Rasterio is explained as an alternative raster data handling module.
> **Question 2**: Adjust the code above to take a look at the DTM. Note the gaps that appear. What are these gaps?
220
-
```
221
221
<details>
222
-
<summary>**Click for answer**</summary>
222
+
<summary>*Click for answer*</summary>
223
223
These are buildings.
224
224
</details>
225
+
```
226
+
225
227
226
228
227
229
The metadata shows the driver (GDAL's way of knowing how to function with a specific file format), datatype, nodata value, width of raster in number of cells, height of raster in number of cells, number of raster bands in the dataset, coordinate reference system, and transformation values.
@@ -289,11 +291,12 @@ with rasterio.open('data/AHN3_05m_CHM.tif', 'w', **kwargs) as file:
289
291
290
292
```{block, type="alert alert-success"}
291
293
> **Question 3**: Where is the CHM the highest in the study area? Is it what you expected?
292
-
```
293
294
<details>
294
-
<summary>**Click for answer**</summary>
295
+
<summary>*Click for answer*</summary>
295
296
Think about where you have the most forests on campus.
296
297
</details>
298
+
```
299
+
297
300
298
301
299
302
We have now applied the basic concepts of creating a Canopy Height Model!
@@ -368,11 +371,12 @@ plt.show()
368
371
369
372
```{block, type="alert alert-success"}
370
373
> **Question 4**: Why do we want an equal scale in the x and y direction for this figure?
371
-
```
372
374
<details>
373
-
<summary>**Click for answer**</summary>
375
+
<summary>*Click for answer*</summary>
374
376
To visualize the buildings properly, otherwise their geometries will be skewed.
375
377
</details>
378
+
```
379
+
376
380
377
381
378
382
## Other functionality
@@ -471,11 +475,12 @@ plt.show()
471
475
472
476
```{block, type="alert alert-success"}
473
477
> **Question 5**: What is represented on the x and y axis? The default axis labels are DN (x) and Frequency (y); if you were to change them, what labels would you pick to better reflect the content of the plots?
474
-
```
475
478
<details>
476
-
<summary>**Click for answer**</summary>
477
-
The y axis represents the count of pixels. Meanwhile the x axis represents the pixel's DN(digital value), in this tutorial since we are looking at elevation this value is actually meters. For example, in the first plot (DSM) you can see that most pixel values are in the 10 to 15 meter range
479
+
<summary>*Click for answer*</summary>
480
+
The y axis represents the count of pixels. Meanwhile the x axis represents the pixel's DN(digital value), in this tutorial since we are looking at elevation this value is actually meters. For example, in the first plot (DSM) you can see that most pixel values are in the 10 to 15 meter range
0 commit comments