Skip to content

Commit

Permalink
empirische berekening winFun voor vwf functie
Browse files Browse the repository at this point in the history
  • Loading branch information
stienheremans committed Jan 20, 2025
1 parent 1deaa5b commit 5a16619
Show file tree
Hide file tree
Showing 5 changed files with 128 additions and 2 deletions.
1 change: 1 addition & 0 deletions data/Kruinen referentie/kruinen_Dilsen1.cpg
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
UTF-8
1 change: 1 addition & 0 deletions data/Kruinen referentie/kruinen_Dilsen1.prj
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
PROJCS["Belge_Lambert_1972",GEOGCS["GCS_Belge_1972",DATUM["D_Belge_1972",SPHEROID["International_1924",6378388.0,297.0]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Lambert_Conformal_Conic"],PARAMETER["False_Easting",150000.013],PARAMETER["False_Northing",5400088.438],PARAMETER["Central_Meridian",4.36748666666667],PARAMETER["Standard_Parallel_1",51.1666672333333],PARAMETER["Standard_Parallel_2",49.8333339],PARAMETER["Latitude_Of_Origin",90.0],UNIT["Meter",1.0]]
Binary file added data/Kruinen referentie/kruinen_Dilsen1.qix
Binary file not shown.
124 changes: 124 additions & 0 deletions source/Calibration winFun.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
---
title: "calibration winFun"
author: "Stien Heremans"
date: "2025-01-20"
output: html_document
---

```{r}
library(sf) # For spatial vector data
library(raster) # For CHM (raster data)
crowns <- st_read("../data/Kruinen referentie/kruinen_Dilsen1.shp")
chm <- raster("../output/CHM/chm_rescaled Dilsen 1.tif")
crowns <- st_transform(crowns, crs = crs(chm))
```

```{r}
library(exactextractr) # For extracting raster values by polygons
crowns$area <- st_area(crowns)
crowns$radius <- sqrt(as.numeric(crowns$area) / pi)
crowns$height_75 <- exact_extract(chm, crowns, function(values, coverage_fraction) {

Check warning on line 23 in source/Calibration winFun.Rmd

View workflow job for this annotation

GitHub Actions / check project with checklist

file=source/Calibration winFun.Rmd,line=23,col=81,[line_length_linter] Lines should not be more than 80 characters. This line is 84 characters.
quantile(values, probs = 0.75, na.rm = TRUE)
})
crowns$max_height <- exact_extract(chm, crowns, function(values, coverage_fraction) {

Check warning on line 26 in source/Calibration winFun.Rmd

View workflow job for this annotation

GitHub Actions / check project with checklist

file=source/Calibration winFun.Rmd,line=26,col=81,[line_length_linter] Lines should not be more than 80 characters. This line is 85 characters.
max(values, na.rm = TRUE)
})
crowns$average_height <- exact_extract(chm, crowns, function(values, coverage_fraction) {

Check warning on line 29 in source/Calibration winFun.Rmd

View workflow job for this annotation

GitHub Actions / check project with checklist

file=source/Calibration winFun.Rmd,line=29,col=81,[line_length_linter] Lines should not be more than 80 characters. This line is 89 characters.
mean(values, na.rm = TRUE)
})
```


```{r}
head(crowns)
```
```{r}
# Remove rows with missing values
crowns <- crowns[!is.na(crowns$radius) & !is.na(crowns$height_75), ]
```


```{r}
library(ggplot2)
p1 <- ggplot(crowns, aes(x = height_75, y = radius)) +
geom_point() +
geom_smooth(method = "lm", se = FALSE, color = "blue") +
theme_minimal() +
labs(title = "Radius vs Height",
x = "Crown Height (75th Percentile)",
y = "Crown Radius (m)")
p1
```

```{r}
# Fit the model
model_75height <- lm(radius ~ height_75, data = crowns)
# Summarize the model
summary(model_75height)
```


```{r}
# Remove rows with missing values
crowns <- crowns[!is.na(crowns$radius) & !is.na(crowns$max_height), ]
```


```{r}
library(ggplot2)
p1 <- ggplot(crowns, aes(x = max_height, y = radius)) +
geom_point() +
geom_smooth(method = "lm", se = FALSE, color = "blue") +
theme_minimal() +
labs(title = "Radius vs Height",
x = "Crown Height (max)",
y = "Crown Radius (m)")
p1
```

```{r}
# Fit the model
model_maxheight <- lm(radius ~ max_height, data = crowns)
# Summarize the model
summary(model_maxheight)
```



```{r}
# Remove rows with missing values
crowns <- crowns[!is.na(crowns$radius) & !is.na(crowns$average_height), ]
```


```{r}
library(ggplot2)
p1 <- ggplot(crowns, aes(x = average_height, y = radius)) +
geom_point() +
geom_smooth(method = "lm", se = FALSE, color = "blue") +
theme_minimal() +
labs(title = "Radius vs Height",
x = "Crown Height (average)",
y = "Crown Radius (m)")
p1
```

```{r}
# Fit the model
model_75height <- lm(radius ~ average_height, data = crowns)
# Summarize the model
summary(model_75height)
```
4 changes: 2 additions & 2 deletions source/TreeDelineation.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ if (!dir.exists(file.path(output_dir, "tree_crowns"))) {
# Load DSM and DTM
dsm_drone <- rast("D:/Thesis Thomas/DHT/DEM update/m_geclipt_DEM Dilsen 1.tif")
dtm <- rast("S:/Vlaanderen/Hoogte/DHMVII/DHMVIIDTMRAS1m.tif")
dsm_drone <- rast("E:/Thesis Thomas/DHT/DEM update/m_geclipt_DEM Dilsen 1.tif")

Check warning on line 33 in source/TreeDelineation.Rmd

View workflow job for this annotation

GitHub Actions / check project with checklist

file=source/TreeDelineation.Rmd,line=33,col=20,[absolute_path_linter] Do not use absolute paths.
dtm <- rast("Z:/Vlaanderen/Hoogte/DHMVII/DHMVIIDTMRAS1m.tif")

Check warning on line 34 in source/TreeDelineation.Rmd

View workflow job for this annotation

GitHub Actions / check project with checklist

file=source/TreeDelineation.Rmd,line=34,col=14,[absolute_path_linter] Do not use absolute paths.
```

Expand Down

0 comments on commit 5a16619

Please sign in to comment.