Get tabular information of the point coordinates.

getPoints(x)

# S4 method for ANY
getPoints(x)

# S4 method for geom
getPoints(x)

# S4 method for Spatial
getPoints(x)

# S4 method for sf
getPoints(x)

# S4 method for Raster
getPoints(x)

# S4 method for SpatRaster
getPoints(x)

# S4 method for matrix
getPoints(x)

Arguments

x

the object from which to derive the point coordinates.

Value

A tibble of the point coordinates of x.

Details

This table contains three columns (x, y and fid) and as many rows as there are points. In case x is a polygon, the last point of each distinct feature is a duplicate of its first point. In case x has the type 'grid', all layers are summarised into one tibble, as several layers must have the same extent and resolution, so that each point occurrs in each layer, merely with a different, layer-specific value.

See also

Examples


getPoints(x = gtGeoms$point)
#> # A tibble: 9 × 3
#>       x     y   fid
#>   <dbl> <dbl> <int>
#> 1   0     -40     1
#> 2  34.6   -20     2
#> 3  34.6    20     3
#> 4   0      40     4
#> 5 -34.6    20     5
#> 6 -34.6   -20     6
#> 7 -34.6    20     7
#> 8 -34.6   -20     8
#> 9   0       0     9
getPoints(x = gtGeoms$polygon)
#> # A tibble: 11 × 3
#>        x     y   fid
#>    <dbl> <dbl> <dbl>
#>  1   0     -40     1
#>  2  34.6   -20     1
#>  3  34.6    20     1
#>  4   0      40     1
#>  5 -34.6    20     1
#>  6 -34.6   -20     1
#>  7   0     -40     1
#>  8 -34.6    20     2
#>  9 -34.6   -20     2
#> 10   0       0     2
#> 11 -34.6    20     2

# for raster objects, the @point slot is extracted from its compact form
gtGeoms$grid$continuous@point
#> # A tibble: 3 × 2
#>       x     y
#>   <dbl> <dbl>
#> 1     0     0
#> 2    60    56
#> 3     1     1

getPoints(x = gtGeoms$grid$continuous)
#> # A tibble: 3,360 × 3
#>        x     y   fid
#>    <dbl> <dbl> <int>
#>  1   0.5   0.5     1
#>  2   1.5   0.5     2
#>  3   2.5   0.5     3
#>  4   3.5   0.5     4
#>  5   4.5   0.5     5
#>  6   5.5   0.5     6
#>  7   6.5   0.5     7
#>  8   7.5   0.5     8
#>  9   8.5   0.5     9
#> 10   9.5   0.5    10
#> # … with 3,350 more rows

gc_sp(gtGeoms$line) %>%
  getPoints()
#> # A tibble: 9 × 3
#>       x     y   fid
#>   <dbl> <dbl> <dbl>
#> 1   0     -40     1
#> 2  34.6   -20     1
#> 3  34.6    20     1
#> 4   0      40     1
#> 5 -34.6    20     1
#> 6 -34.6   -20     1
#> 7 -34.6    20     2
#> 8 -34.6   -20     2
#> 9   0       0     2

gc_sf(gtGeoms$line) %>%
  getPoints()
#> # A tibble: 9 × 3
#>       x     y   fid
#>   <dbl> <dbl> <dbl>
#> 1   0     -40     1
#> 2  34.6   -20     1
#> 3  34.6    20     1
#> 4   0      40     1
#> 5 -34.6    20     1
#> 6 -34.6   -20     1
#> 7 -34.6    20     2
#> 8 -34.6   -20     2
#> 9   0       0     2

gc_raster(gtGeoms$grid$categorical) %>%
  getPoints()
#> # A tibble: 3,360 × 3
#>        x     y   fid
#>    <dbl> <dbl> <int>
#>  1   0.5   0.5     1
#>  2   1.5   0.5     2
#>  3   2.5   0.5     3
#>  4   3.5   0.5     4
#>  5   4.5   0.5     5
#>  6   5.5   0.5     6
#>  7   6.5   0.5     7
#>  8   7.5   0.5     8
#>  9   8.5   0.5     9
#> 10   9.5   0.5    10
#> # … with 3,350 more rows

gc_terra(gtGeoms$grid$categorical) %>%
  getPoints()
#> # A tibble: 3,360 × 3
#>        x     y   fid
#>    <dbl> <dbl> <int>
#>  1   0.5   0.5     1
#>  2   1.5   0.5     2
#>  3   2.5   0.5     3
#>  4   3.5   0.5     4
#>  5   4.5   0.5     5
#>  6   5.5   0.5     6
#>  7   6.5   0.5     7
#>  8   7.5   0.5     8
#>  9   8.5   0.5     9
#> 10   9.5   0.5    10
#> # … with 3,350 more rows

getPoints(x = matrix(0, 3, 5))
#> # A tibble: 15 × 3
#>        x     y   fid
#>    <dbl> <dbl> <int>
#>  1   0.5   0.5     1
#>  2   1.5   0.5     2
#>  3   2.5   0.5     3
#>  4   3.5   0.5     4
#>  5   4.5   0.5     5
#>  6   0.5   1.5     6
#>  7   1.5   1.5     7
#>  8   2.5   1.5     8
#>  9   3.5   1.5     9
#> 10   4.5   1.5    10
#> 11   0.5   2.5    11
#> 12   1.5   2.5    12
#> 13   2.5   2.5    13
#> 14   3.5   2.5    14
#> 15   4.5   2.5    15