cs_projectXY: Project Data

Description Usage Arguments Value Examples

View source: R/spatial.R

Description

cs_projectXY converts STLMPD data into a simple features object using the XCoord and YCoord columns.

Usage

1
cs_projectXY(.data, varX, varY, crs)

Arguments

.data

A tibble or data frame

varX

Name of column containing x coordinate data

varY

Name of column containing y coordinate data

crs

integer with the EPSG code, or character with proj4string representing the coordinate reference system

Value

A sf object with the crime data projected for mapping.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
# load example data
testData <- january2018

# identify missing x and y coordinates
testData <- cs_missingXY(testData, varX = x_coord, varY = y_coord, newVar = missingXY)

# subset to remove missing data
testData <- dplyr::filter(testData, missingXY == FALSE)

# project data
testData_sf <- cs_projectXY(testData, varX = x_coord, varY = y_coord)

# project data and transform to new CRS
testData_sf <- cs_projectXY(testData, varX = x_coord, varY = y_coord, crs = 4269)

compstatr documentation built on July 8, 2020, 7:34 p.m.