Skip to contents

Rounding of geometry coordinates

Usage

st_round(x, digits = 0)

Arguments

x

An object of class sf or sfc.

digits

Integer indicating the number of decimal places to be used.

Value

An object of class sf or sfc with rounded coordinates.

See also

Examples

library(sf, quietly = TRUE)

p1 = st_sfc(st_point(c(1.123, 1.123)))
p2 = st_sfc(st_point(c(0.789, 0.789)))
p3 = st_sfc(st_point(c(1.123, 0.789)))

st_round(st_as_sf(c(p1, p2, p2, p3, p1)), digits = 1)
#> Simple feature collection with 5 features and 0 fields
#> Geometry type: POINT
#> Dimension:     XY
#> Bounding box:  xmin: 0.8 ymin: 0.8 xmax: 1.1 ymax: 1.1
#> CRS:           NA
#>                 x
#> 1 POINT (1.1 1.1)
#> 2 POINT (0.8 0.8)
#> 3 POINT (0.8 0.8)
#> 4 POINT (1.1 0.8)
#> 5 POINT (1.1 1.1)