1

I am calculating shadow cast using Shadow Package in R studio. I have successfully generated shadow cast by the three objects with specific heights for one whole day for every hour. The output I get is a separate shadow for every hour in a separate frame. I wanted to get all shadows in one frame along with the time stamp.enter image description here


time_seq = seq(from = as.POSIXct("2021-07-19 05:15:00", tz = "Europe/Berlin"), to = as.POSIXct("2021-07-19 21:20:00", tz = "Europe/Berlin"), by = "1 hour")
time_seq
# 
solar_pos_seq = solarpos2(location = location_geo, time = time_seq)
solar_pos_seq
# 
# 
shadow_props = rep(NA, nrow(solar_pos_seq))
shadow_props
# 
for(i in 1:nrow(solar_pos_seq)){
 if(solar_pos_seq[i, 2] < 0) shadow_props[i] = 1 else {
      footprint = shadowFootprint(obstacles = shapefile, obstacles_height_field = "Height", solar_pos = solar_pos_seq[i, , drop = FALSE])
      #plot(footprint)
      footprint
      
      combine_footprint = union(footprint, shapefile)
      complete = union(combine_footprint,settlements)
      plot(complete)

1 Answer 1

0

If you put each object in a list element, like this skeleton code:

fList = list()
for(i in 1:10){
  fList[[i]] = sfobject(...i...)
}

Then you need to use rbind to collect the elements together row-wise.

To do this on elements in a list, you can use Reduce:

f123 = Reduce(rbind, fList)

or do.call:

f123 = do.call(rbind, fList)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.