tests/testthat/test_SVF.R

library(shadow)

context("SVF")

test_that("SVF calculation is correct", {
  expect_equal({
    data(build)
    location0 = rgeos::gCentroid(build)
    SVF(
      location = location0,
      obstacles = build,
      obstacles_height_field = "BLDG_HT"
      )
  },
  0.39597205126485
)
  expect_equal({
    data(build)
    location0 = rgeos::gCentroid(build)
    location1 = raster::shift(location0, 0, -15)
    SVF(
      location = location1,
      obstacles = build,
      obstacles_height_field = "BLDG_HT"
    )
  },
  0.139491688314422
  )
  expect_equal({
    data(build)
    location0 = rgeos::gCentroid(build)
    location2 = raster::shift(location0, -10, 20)
    SVF(
      location = location2,
      obstacles = build,
      obstacles_height_field = "BLDG_HT"
    )
  },
  0.770505253636759
  )
}
)

Try the shadow package in your browser

Any scripts or data that you put into this service are public.

shadow documentation built on March 15, 2021, 1:07 a.m.