Skip to content

Commit

Permalink
rerenders website
Browse files Browse the repository at this point in the history
  • Loading branch information
Nowosad committed Sep 2, 2024
1 parent 0c19323 commit 055da7a
Show file tree
Hide file tree
Showing 12 changed files with 43 additions and 10 deletions.
16 changes: 8 additions & 8 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ jobs:
- name: Set up Quarto
uses: quarto-dev/quarto-actions/setup@v2

- name: Install R
uses: r-lib/actions/setup-r@v2
# - name: Install R
# uses: r-lib/actions/setup-r@v2

- name: Install R Dependencies
uses: r-lib/actions/setup-r-dependencies@v2
with:
packages:
any::knitr
any::rmarkdown
# - name: Install R Dependencies
# uses: r-lib/actions/setup-r-dependencies@v2
# with:
# packages:
# any::knitr
# any::rmarkdown

- name: Render and Publish
uses: quarto-dev/quarto-actions/publish@v2
Expand Down
15 changes: 15 additions & 0 deletions _freeze/R_session/Compare_BI_plots/execute-results/html.json
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 _freeze/R_session/Tree_detection/execute-results/html.json
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
}
}
7 changes: 5 additions & 2 deletions _freeze/site_libs/revealjs/dist/theme/quarto.css

Large diffs are not rendered by default.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 055da7a

Please sign in to comment.