Hello. The code in examples runs error on my computer, it reports 'no slot of name "ptr" for this object of class "SpatRaster"'
#For this example, we first need to download the DSM, DTM and Green space layer from the following url (where we already uploaded the data)
#create a temp diractory to get the zip file
temp <- tempfile(fileext = "zip")
download.file("https://a35b3ff7-2e06-4a4f-a669-8681322e59a7.usrfiles.com/archives/a35b3f_c9ec6cb349d043f4b3b055d6dc984ed3.zip", temp)
#extract the zip file
out <- unzip(temp, exdir = tempdir())
#load the DSM, DTM, and GreenSpace (GS)
DSM <- terra::rast(out[1])
DTM <- terra::rast(out[2])
GS <- terra::rast(out[3])
#let us fix an obersver location
obersver_mp <- sf::st_sf(sfheaders::sf_point(c(4.882752, 52.358029)), crs = st_crs(4326))
#make sure the oberver location has same projection as the DSM/DTM/GS file. They all need to be in same projection
obersver_mp <- sf::st_transform(obersver_mp, sf::st_crs(DSM))
singleview <- GreenExp::viewshed(observer = obersver_mp, dsm_rast = DSM, dtm_rast = DTM,
max_distance = 200, observer_height = 1.7, plot = TRUE)
trying URL 'https://a35b3ff7-2e06-4a4f-a669-8681322e59a7.usrfiles.com/archives/a35b3f_c9ec6cb349d043f4b3b055d6dc984ed3.zip'
Content type 'application/zip' length 7365204 bytes (7.0 MB)
downloaded 7.0 MB
Error in GreenExp::viewshed(observer = obersver_mp, dsm_rast = DSM, dtm_rast = DTM, :
no slot of name "ptr" for this object of class "SpatRaster"
r$> getSlots("SpatRaster")
pnt
"C++Object"
I'm not sure if the slot in terra SpatRaster was renamed from ptr to pnt. Thank you very much for your help.