Pointmover: Move points within a shapefile

View source: R/Pointmover.R

PointmoverR Documentation

Move points within a shapefile

Description

Move points to closest location within shapefile

Usage

Pointmover(Data, Attribute, Shapefile)

Arguments

Data

Dataframe of points with sf geometry column and an attribute column with NAs for points that need to be moved.

Attribute

Name of the column in Data that indicates points that need to be moved (by the presence of NAs)

Shapefile

Object of class sf representing the shapefile you want all points to fall within.

See Also

Waterdist

Examples

## Not run: 
library(tibble)
library(dplyr)
library(sf)
Points <- tibble(Latitude = c(38.23333, 38.04813, 38.05920,
                              37.94900, 38.23615, 38.47387),
                 Longitude = c(-121.4889, -121.9149, -121.8684,
                               -121.5591, -121.6735, -121.5844),
                 ID = c("EMP NZP02", "FMWT 508", "FMWT 513",
                        "FMWT 915", "FMWT 723", "FMWT 796"))%>%
st_as_sf(coords=c("Longitude", "Latitude"), crs=4326)%>%
  st_transform(crs=32610)

Map <- st_union(spacetools::Delta)%>%
st_as_sf()%>%
  mutate(Inside=TRUE)%>%
  rename(geometry = x)%>%
  st_transform(crs=32610)

Points_joined <- st_join(Points, Map, join = st_intersects)

Points_fixed<-Pointmover(Points_joined, Inside, Map)

## End(Not run)

sbashevkin/spacetools documentation built on Feb. 2, 2024, 9:15 p.m.