Creates a vector with 0's and 1's to determine on which side of the cut-off each observation is. For this it is useful to have a polygon that fully describes the "treated area". If you do not have such a polygon there is a (preliminary and patchy) way implemented in the package via points2line and cutoff2polygon that lets you go from points to line to "treated polygon" in a very crude way.

assign_treated(data, polygon, id = NA)

Arguments

data

sf data frame containing point data (if you have polygons, convert first with sf::st_centroid())

polygon

sf object with polygon geometry that fully describes the area(s) that contain the treated points

id

string that represents the name of the column in the data that represents the unique identifier for each observation

Value

A vector of type factor with 0's and 1's. Convert with as.numeric() if you want real numbers/integers.

Note

This is essentially a wrapper of sf::st_intersection.

Examples

points_samp.sf <- sf::st_sample(polygon_full, 100) # create points
# make it an sf object bc st_sample only created the geometry list-column (sfc):
points_samp.sf <- sf::st_sf(points_samp.sf)
# add a unique ID to each observation:
points_samp.sf$id <- 1:nrow(points_samp.sf)
points_samp.sf$treated <- assign_treated(points_samp.sf, polygon_treated, id = "id")
#> Warning: attribute variables are assumed to be spatially constant throughout all geometries