Generate contour lines (isolines) and contour polygons (isobands) from
regularly spaced grids containing elevation data. Package originally
written by Claus Wilke and donated to r-lib in 2022.
Installation
Install the latest official release from CRAN via:
The two main workhorses of the package are the functions isolines()
and isobands(), respectively. They return a list of isolines/isobands
for each isolevel specified. Each isoline/isoband consists of vectors of
x and y coordinates, as well as a vector of ids specifying which sets of
coordinates should be connected. This format can be handed directly to
grid.polyline()/grid.path() for drawing. However, we can also
convert the output to spatial features and draw with ggplot2 (see
below).
The function plot_iso() is a convenience function for debugging and
testing.
plot_iso(m, 0.5, 1.5)
The isolining and isobanding algorithms have no problem with larger
datasets. Let’s calculate isolines and isobands for the volcano dataset,
convert to sf, and plot with ggplot2.
library(ggplot2)
suppressWarnings(library(sf))
#> Linking to GEOS 3.13.0, GDAL 3.8.5, PROJ 9.5.1; sf_use_s2() is TRUE
m <- volcano
b <- isobands((1:ncol(m))/(ncol(m)+1), (nrow(m):1)/(nrow(m)+1), m, 10*(9:19), 10*(10:20))
l <- isolines((1:ncol(m))/(ncol(m)+1), (nrow(m):1)/(nrow(m)+1), m, 10*(10:19))
bands <- iso_to_sfg(b)
data_bands <- st_sf(
level = 1:length(bands),
geometry = st_sfc(bands)
)
lines <- iso_to_sfg(l)
data_lines <- st_sf(
level = 2:(length(lines)+1),
geometry = st_sfc(lines)
)
ggplot() +
geom_sf(data = data_bands, aes(fill = level), color = NA, alpha = 0.7) +
geom_sf(data = data_lines, color = "black") +
scale_fill_viridis_c(guide = "none") +
coord_sf(expand = FALSE)
关于
ISA-RWVAL 是一个用于验证和转换 ISA-Tab 格式元数据文件的软件工具,确保其符合 ISA 框架规范。
isoband
Generate contour lines (isolines) and contour polygons (isobands) from regularly spaced grids containing elevation data. Package originally written by Claus Wilke and donated to r-lib in 2022.
Installation
Install the latest official release from CRAN via:
Install the current development from github via:
Examples
The two main workhorses of the package are the functions
isolines()andisobands(), respectively. They return a list of isolines/isobands for each isolevel specified. Each isoline/isoband consists of vectors of x and y coordinates, as well as a vector of ids specifying which sets of coordinates should be connected. This format can be handed directly togrid.polyline()/grid.path()for drawing. However, we can also convert the output to spatial features and draw with ggplot2 (see below).The function
plot_iso()is a convenience function for debugging and testing.The isolining and isobanding algorithms have no problem with larger datasets. Let’s calculate isolines and isobands for the volcano dataset, convert to sf, and plot with ggplot2.