as_points: Convert a dataframe with X and Y coordinates to a geospatial...

View source: R/sf.R

as_pointsR Documentation

Convert a dataframe with X and Y coordinates to a geospatial points object

Description

as_points is a convenience function which accepts as input a dataframe with X/Y coordinates (in meters), assumed to come from the coordinate reference system (CRS) 'Belge 1972 / Belgian Lambert 72' (EPSG 31370). It converts the dataframe into an sf points object in the same CRS.

Usage

as_points(df, xvar = "x", yvar = "y", remove = FALSE, warn_dupl = TRUE)

Arguments

df

A dataframe with X and Y coordinates in meters, assumed to be in the Belgian Lambert 72 CRS (EPSG-code 31370).

xvar

String. The X coordinate variable name. Defaults to "x".

yvar

String. The Y coordinate variable name. Defaults to "y".

remove

Logical. Should the X and Y coordinates be removed from the dataframe after conversion to a spatial object?

warn_dupl

Logical. Defaults to TRUE. Should the user be warned when duplicated coordinates are present in the result?

Details

As locations in Watina are typically defined by their X/Y coordinates, this function eases the conversion to spatial data. To later remove all spatial information from the result, you can use sf::st_drop_geometry().

Value

An sf object of geometry type POINT with EPSG-code 31370 as coordinate reference system.

Examples

library(tibble)
mydata <-
  tibble(
    a = runif(5),
    x = rnorm(5, 155763, 5),
    y = rnorm(5, 132693, 5)
  )
as_points(mydata)


inbo/watina documentation built on Dec. 2, 2024, 4:02 a.m.