-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
43 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
_freeze/R_session/Compare_BI_plots/execute-results/html.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"hash": "af8ab40fba1549a2c88d02c1dff88fb9", | ||
"result": { | ||
"engine": "knitr", | ||
"markdown": "---\ntitle: \"Number_Trees_BI_nDOM\"\nformat: html\nknitr:\n opts_chunk: \n eval: false\neditor: visual\n---\n\n\n\n\n## Compare number of trees in BI plots: detected with remote sensing vs measured in field\n\n\n\n\n::: {.cell}\n\n```{.r .cell-code}\nlibrary(here)\nlibrary(sf)\nlibrary(dplyr)\nlibrary(terra)\nlibrary(ggplot2)\nlibrary(foreign)\n```\n:::\n\n\n\n\nLoad BI plots, BI trees and trees detected in ndom (created in previous script).\n\n\n\n\n::: {.cell}\n\n```{.r .cell-code}\nplots_bi <- st_read(here(\"R_session\", \"data\", \"buffer13_bi_mittelpunkt_solling_2023.gpkg\"))\n\ntrees_bi <- st_read(here(\"R_session\", \"data\", \"bi_baeume_vorrat_solling_2023.gpkg\"))\n\ntrees_ndom <- st_read(here(\"R_session\", \"data\", \"ttops_bi_ndom.gpkg\"))\n```\n:::\n\n\n\n\nLoad table with median slope in the BI plot and bind with plots BI table\n\n\n\n\n::: {.cell}\n\n```{.r .cell-code}\nslope_bi_plot <- read.dbf(here(\"R_session\", \"data\", \"bi_plot_median_slope.dbf\"))\nplots_bi <- bind_cols(plots_bi, slope_bi_plot %>% select(X_median))\nrm(slope_bi_plot)\n```\n:::\n\n\n\n\nCount how many bi trees inside plot\n\n\n\n\n::: {.cell}\n\n```{.r .cell-code}\nintersection_bi_trees_plots <- st_intersection(x = plots_bi, y = trees_bi)\n\ncount_bi_trees_plot <- intersection_bi_trees_plots %>% \n add_count(KSPNR, name = \"n_trees_bi\") %>% \n group_by(KSPNR) %>% \n slice(n()) %>% \n ungroup() \n```\n:::\n\n\n\n\nOptional: Trees_bi 2638 observations, intersection_bi_trees_plots 2606 observations, check reason from this difference\n\n\n\n\n::: {.cell}\n\n```{.r .cell-code}\n#st_erase = function(x, y) st_difference(x, st_union(st_combine(y)))\n\n#difference <- st_erase(trees_bi , intersection_bi_trees_plots)\n\n#writeVector(vect(difference), here(\"output\", \"trees_not_bi.gpkg\"), overwrite=TRUE)\n```\n:::\n\n\n\n\nCount how many ndom trees inside plot\n\n\n\n\n::: {.cell}\n\n```{.r .cell-code}\nintersection_ndom_trees_plots <- st_intersection(x = plots_bi, y = trees_ndom)\n\ncount_ndom_trees_plot <- intersection_ndom_trees_plots %>% \n add_count(KSPNR, name = \"n_trees_ndom\") %>% \n group_by(KSPNR) %>% \n slice(n()) %>% \n ungroup() \n```\n:::\n\n\n\n\nMerge table with number trees from ndom and table with number trees from BI\n\n\n\n\n::: {.cell}\n\n```{.r .cell-code}\ncount_trees_bi_ndom <- merge(as.data.frame(count_ndom_trees_plot), as.data.frame(count_bi_trees_plot), by = \"KSPNR\")\n```\n:::\n\n\n\n\nPlot to compare the number of trees in each plot taking slope of plot into account\n\n\n\n\n::: {.cell}\n\n```{.r .cell-code}\nx <- ggplot(count_trees_bi_ndom, aes(x=n_trees_bi, y=n_trees_ndom, colour=X_median.x)) + \n xlim(0,30) + ylim(0,30) +\n geom_abline(slope=1) +\n geom_point() +\n scale_colour_gradientn(colours=rainbow(4)) +\n labs(title = \"Number of trees in each plot measured in BI vs detected with nDOM\", \n x = \"Number of trees measured in BI\",\n y = \"Number of trees detected in nDOM\",\n color = \"Terrain slope [degree]\") +\n theme(plot.title = element_text(hjust = 0.5))\n```\n:::\n\n\n\n\nWhat could be the reasons for the difference?\n", | ||
"supporting": [], | ||
"filters": [ | ||
"rmarkdown/pagebreak.lua" | ||
], | ||
"includes": {}, | ||
"engineDependencies": {}, | ||
"preserve": {}, | ||
"postProcess": true | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
_freeze/R_session/Tree_detection/execute-results/html.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"hash": "3502f2b1e75cc6ba690310fe54e2858c", | ||
"result": { | ||
"engine": "knitr", | ||
"markdown": "---\ntitle: \"Tree detection\"\nformat: html\nknitr:\n opts_chunk: \n eval: false\neditor: visual\n---\n\n\n\n\n## Tree detection\n\nGoal is to detect tree tops using a variable window size and using the ndom raster in the BI plots in Solling 2023.\n\n\n\n\n::: {.cell}\n\n```{.r .cell-code}\nlibrary(lidR)\nlibrary(terra)\nlibrary(here)\n```\n:::\n\n\n\n\nLoad ndom previously clipped to BI plots in Solling (BI 2023)\n\n\n\n\n::: {.cell}\n\n```{.r .cell-code}\nndom_bi <- rast(here(\"R_session\", \"data\", \"ndom_bi_plots_solling_2023.tif\"))\nmapview(ndom_bi)\n```\n:::\n\n\n\n\nMake tiles because data too big for R\n\n\n\n\n::: {.cell}\n\n```{.r .cell-code}\ntiles <- makeTiles(x=ndom_bi, \n y=c(3000,3000),\n filename=\n here(\"R_session\", \"output\",\"tiles\",\"ndom_bi_.tif\"), \n na.rm=TRUE)\n\n# In case the tiles are already there\ntiles <-list.files(here(\"R_session\", \"output\",\"tiles\"), pattern='*\\\\.tif', recursive=TRUE, full.names=TRUE)\n```\n:::\n\n\n\n\nTree detection function with variable window size. Any points below 2 m will equate to a window size of 3 m, while points above 20 meters equate to a window size of 5 m. Anything between 2 and 20 meter will have a non-linear relationship.\n\n\n\n\n::: {.cell}\n\n```{.r .cell-code}\nf <- function(x) {\n y <- 2.6 * (-(exp(-0.08*(x-2)) - 1)) + 3 \n # from https://r-lidar.github.io/lidRbook/itd.html\n y[x < 2] <- 3\n y[x > 20] <- 5\n return(y)\n}\n\nheights <- seq(-5,30,0.5)\nws <- f(heights)\nplot(heights, ws, type = \"l\", ylim = c(0,5))\n```\n:::\n\n\n\n\nTree detection using function for variable window size\n\n\n\n\n::: {.cell}\n\n```{.r .cell-code}\nout <- sapply(tiles, \\(tile) {\n x <- rast(tile)\n ttops <- lidR::locate_trees(x, lidR::lmf(f))\n vect(ttops)\n })\n\nout <- vect(out)\n```\n:::\n\n\n\n\nSave tree tops\n\n\n\n\n::: {.cell}\n\n```{.r .cell-code}\nwriteVector(out, here(\"R_session\", \"output\",\"ttops_ndom_.gpkg\"), overwrite=TRUE)\n```\n:::\n", | ||
"supporting": [], | ||
"filters": [ | ||
"rmarkdown/pagebreak.lua" | ||
], | ||
"includes": {}, | ||
"engineDependencies": {}, | ||
"preserve": {}, | ||
"postProcess": true | ||
} | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file added
BIN
+21.2 KB
tdv_session/02_ValidationDataCollection_files/figure-html/Collect Values-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+36.2 KB
tdv_session/02_ValidationDataCollection_files/figure-html/Model-Performance-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+24.4 KB
tdv_session/02_ValidationDataCollection_files/figure-html/RMSEest-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+23.4 KB
tdv_session/02_ValidationDataCollection_files/figure-html/Sample-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+21.7 KB
tdv_session/02_ValidationDataCollection_files/figure-html/Simulation2-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+28.4 KB
...session/02_ValidationDataCollection_files/figure-html/SystematicSimlation-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+20.6 KB
tdv_session/02_ValidationDataCollection_files/figure-html/simulation-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+23.4 KB
tdv_session/02_ValidationDataCollection_files/figure-html/systematicSample-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.