The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.
library(slopes)
library(bench)
library(raster)
#> Loading required package: sp
A benchmark can reveal how many route gradients can be calculated per second:
dem_lisbon_raster
e = lisbon_road_network
r = terra::rast(e)
et = bench::mark(check = FALSE,
res =slope_raster = slope_raster(r, e),
slope_terra = slope_raster(r, et)
)
res#> # A tibble: 2 × 6
#> expression min median `itr/sec` mem_alloc `gc/sec`
#> <bch:expr> <bch:tm> <bch:tm> <dbl> <bch:byt> <dbl>
#> 1 slope_raster 18.5ms 18.7ms 52.0 16.2MB 24.5
#> 2 slope_terra 17.5ms 18.4ms 54.2 1.96MB 13.5
That is approximately
round(res$`itr/sec` * nrow(r))
#> [1] 14104 14680
routes per second using the raster
and terra
(the default if installed, using RasterLayer
and native SpatRaster
objects) packages to extract elevation estimates from the raster datasets, respectively.
The message: use the terra
package to read-in DEM data for slope extraction if speed is important.
To go faster, you can chose the simple
method to gain some speed at the expense of accuracy:
dem_lisbon_raster
e = lisbon_road_network
r = bench::mark(check = FALSE,
res =bilinear1 = slope_raster(r, e),
bilinear2 = slope_raster(r, et),
simple1 = slope_raster(r, e, method = "simple"),
simple2 = slope_raster(r, et, method = "simple")
)
res#> # A tibble: 4 × 6
#> expression min median `itr/sec` mem_alloc `gc/sec`
#> <bch:expr> <bch:tm> <bch:tm> <dbl> <bch:byt> <dbl>
#> 1 bilinear1 18.4ms 18.7ms 53.0 5.28MB 9.64
#> 2 bilinear2 18ms 18.5ms 53.7 1.86MB 12.8
#> 3 simple1 15ms 15.2ms 65.7 1.97MB 12.2
#> 4 simple2 15.2ms 15.4ms 64.7 1.92MB 12.0
round(res$`itr/sec` * nrow(r))
#> [1] 14364 14541 17791 17544
These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.