ubc-geomatics-textbook / geomatics-textbook

https://www.opengeomatics.ca
10 stars 16 forks source link

reconfigure `baseurl` usage for interactive figures #157

Open ect123 opened 2 years ago

ect123 commented 2 years ago

non-gif interactive figures use code chunks that do not render urls in LaTex output. Each one should be reset to use the the following syntax:

{r 9-sink-fill, fig.cap = fig_cap, out.width= "75%", echo = FALSE}
    if (knitr:::is_latex_output()) { fig_cap <- paste0("Animated process of filling sinks in a DEM. Pickell, CC-BY-SA-4.0. Animated figure can be viewed in the web browser version of the textbook: https://ubc-geomatics-textbook.github.io/geomatics-textbook/raster-analysis-and-terrain-modelling.html")
  knitr::include_graphics("images/09-sink-fill.png")
} else { fig_cap <- paste0("Animated process of filling sinks in a DEM. Pickell, CC-BY-SA-4.0.")
  knitr::include_graphics("images/09-sink-fill.gif")
}
ect123 commented 2 years ago

Specifically, these figures:

ect123 commented 2 years ago

Several Leaflet maps will need the addition of a variable (example below using m) at the end of the code chunk (in the else condition) to build the interactive content:

if (knitr:::is_latex_output()) { fig_cap <- paste0("The difference (in meters) between the Canadian Geodetic Vertical Datum of 2013 (CGVD2013) and the Canadian Geodetic Vertical Datum of 1928 (CGVD28). Data from Natural Resources Canada and licensed under the Open Government Licence - Canada. Pickell, CC-BY-SA-4.0. Animated figure can be viewed in the web browser version of the textbook: https://ubc-geomatics-textbook.github.io/geomatics-textbook/mapping-data.html")
  knitr::include_graphics("images/02-CGVD-leaflet.PNG")
} else { fig_cap <- paste0("The difference (in meters) between the Canadian Geodetic Vertical Datum of 2013 (CGVD2013) and the Canadian Geodetic Vertical Datum of 1928 (CGVD28). Data from Natural Resources Canada and licensed under the Open Government Licence - Canada. Pickell, CC-BY-SA-4.0.")
m
}

Variable used can be found in the respective chunk of Leaflet code.

ect123 commented 2 years ago

The second Leaflet map chunk in chapter 9 (line 514) does not run - stops with the following error:

Error in leaflet() %>% addProviderTiles("Esri.WorldImagery") %>% addScaleBar(position = c("topleft")) %>%  : 
  could not find function "%>%"

Depending in the severity of the above error, I may close this issue and open a new one for this problem specifically.