Skip to content

Commit

Permalink
Merge pull request #9 from gabrieletijunaityte/master
Browse files Browse the repository at this point in the history
Minor fixes
  • Loading branch information
GreatEmerald authored Sep 5, 2024
2 parents 9eaabfa + 80a1a15 commit 465d253
Show file tree
Hide file tree
Showing 2 changed files with 383 additions and 377 deletions.
31 changes: 18 additions & 13 deletions index.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ with open('data/AHN3_05m_DTM.tif', 'wb') as file:
file.write(response.read())
```

Before continuing, please check if this step was successful.
Before continuing, please check if this step was successful (*Hint: you can check if files have been written into corresponding directory*).

## From a file with GDAL
[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.
Expand All @@ -156,6 +156,7 @@ Before continuing, please check if this step was successful.
</center>
</figure>


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.

```{python, eval=FALSE}
Expand All @@ -177,12 +178,12 @@ ds = None

```{block, type="alert alert-success"}
> **Question 1**: Why do we set ds to None at the end of your script? What may happen if you do not do that?
```
<details>
<summary>**Click for answer**</summary>
<summary>*Click for answer*</summary>
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 ...`
</details>
```



The GDAL Python API is not the best documented Python module. Therefore, Rasterio is explained as an alternative raster data handling module.
Expand Down Expand Up @@ -217,11 +218,12 @@ show(dsm, title='Digital Surface Model', cmap='gist_ncar')

```{block, type="alert alert-success"}
> **Question 2**: Adjust the code above to take a look at the DTM. Note the gaps that appear. What are these gaps?
```
<details>
<summary>**Click for answer**</summary>
<summary>*Click for answer*</summary>
These are buildings.
</details>
```



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.
Expand Down Expand Up @@ -289,11 +291,12 @@ with rasterio.open('data/AHN3_05m_CHM.tif', 'w', **kwargs) as file:

```{block, type="alert alert-success"}
> **Question 3**: Where is the CHM the highest in the study area? Is it what you expected?
```
<details>
<summary>**Click for answer**</summary>
<summary>*Click for answer*</summary>
Think about where you have the most forests on campus.
</details>
```



We have now applied the basic concepts of creating a Canopy Height Model!
Expand Down Expand Up @@ -368,11 +371,12 @@ plt.show()

```{block, type="alert alert-success"}
> **Question 4**: Why do we want an equal scale in the x and y direction for this figure?
```
<details>
<summary>**Click for answer**</summary>
<summary>*Click for answer*</summary>
To visualize the buildings properly, otherwise their geometries will be skewed.
</details>
```



## Other functionality
Expand Down Expand Up @@ -471,11 +475,12 @@ plt.show()

```{block, type="alert alert-success"}
> **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?
```
<details>
<summary>**Click for answer**</summary>
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
<summary>*Click for answer*</summary>
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
</details>
```



# More info
Expand Down
729 changes: 365 additions & 364 deletions index.html

Large diffs are not rendered by default.

0 comments on commit 465d253

Please sign in to comment.