In this repo, I'll guide you through the process of downloading the latest tree canopy height data from Meta and the World Resources Institute, with a detailed resolution of 1 meter. You'll learn how to create clear static maps using ggplot2 in both light and dark themes, as well as interactive maps with leaflet
11
stars
2
forks
source link
Error in main.r code: object 'city_chm_new' not found before plotting #1
I encountered an error when running the example code provided for plotting tree height data. The error message was:
"Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'plot': object 'city_chm_new' not found"
This occurs because
city_chm_new
is being used interra::plot()
before it is defined.Suggested Fix:
Reorder the operations in the script to define
city_chm_new
before it is used in theterra::plot()
function. Here is the corrected sequence:3. GET TREE HEIGHT DATA
------------------------
city_chm <- chmloader::download_chm( city_coords, filename = "oslo-chm.tif" )
Handle zero values
city_chm_new <- terra::ifel( city_chm == 0, NA, city_chm )
Now plot city_chm_new
terra::plot( city_chm_new, col = hcl.colors( 64, "viridis" ) )