convert geometry from a .shp file into a new df with the id column from the .shp file and x and y coordinates in r in r
main.r
# Load necessary librarieslibrary(sf)
# Read the .shp fileshapefile <- st_read("your_shapefile.shp")
# Extract the coordinatescoordinates <- st_coordinates(shapefile)
# Create a new data frame with id and x y coordinatesdata_df <- data.frame(id = shapefile$id, x = coordinates[, 1], y = coordinates[, 2])