csb_projectXY converts srx and sry data into a simple features object. You can write a shapefile directly from the output of this function using sf::st_write.

csb_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

Optional; coordinate reference system for the data to be projected into

Value

Returns a sf object of the input data projected as point data.

Examples

# remove missing coordinates prior to projecting csb <- csb_missingXY(january_2018, srx, sry, newVar = missing) csb <- dplyr::filter(csb, missing == FALSE) # project data csb_projectXY(csb, srx, sry)
#> Simple feature collection with 1506 features and 16 fields #> geometry type: POINT #> dimension: XY #> bbox: xmin: 872868.1 ymin: 985130.7 xmax: 910286.8 ymax: 1061922 #> epsg (SRID): NA #> proj4string: +proj=tmerc +lat_0=35.83333333333334 +lon_0=-90.5 +k=0.9999333333333333 +x_0=250000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=us-ft +no_defs #> # A tibble: 1,506 x 17 #> requestid datetimeinit probaddress probaddtype callertype neighborhood #> <dbl> <dttm> <chr> <chr> <chr> <dbl> #> 1 1049265 2018-01-01 00:48:30 75 WILLMOR… A WEB 8 #> 2 1049265 2018-01-01 00:48:30 75 WILLMOR… A WEB 8 #> 3 1049266 2018-01-01 05:29:06 6739 VERMO… A WEB 1 #> 4 1049267 2018-01-01 08:53:07 5444 ITASK… A WEB 7 #> 5 1049268 2018-01-01 09:13:22 CASS AVE &… B PHONE 60 #> 6 1049269 2018-01-01 10:12:26 6441 LLOYD… A WEB 42 #> 7 1049270 2018-01-01 10:52:32 3100 WINNE… B PHONE 19 #> 8 1049271 2018-01-01 10:54:43 S GRAND AV… B PHONE 25 #> 9 1049272 2018-01-01 11:07:02 SIDNEY ST … B WEB 25 #> 10 1049273 2018-01-01 12:05:40 5400 N BRO… B PHONE 79 #> # … with 1,496 more rows, and 11 more variables: ward <dbl>, problemcode <chr>, #> # description <chr>, submitto <chr>, status <chr>, dateinvtdone <dttm>, #> # datetimeclosed <dttm>, prjcompletedate <dttm>, datecancelled <dttm>, #> # missing <lgl>, geometry <POINT [US_survey_foot]>
# project with a custom crs csb_projectXY(csb, srx, sry, crs = 4269)
#> Simple feature collection with 1506 features and 16 fields #> geometry type: POINT #> dimension: XY #> bbox: xmin: -90.31572 ymin: 38.53886 xmax: -90.1846 ymax: 38.74956 #> epsg (SRID): 4269 #> proj4string: +proj=longlat +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +no_defs #> # A tibble: 1,506 x 17 #> requestid datetimeinit probaddress probaddtype callertype neighborhood #> <dbl> <dttm> <chr> <chr> <chr> <dbl> #> 1 1049265 2018-01-01 00:48:30 75 WILLMOR… A WEB 8 #> 2 1049265 2018-01-01 00:48:30 75 WILLMOR… A WEB 8 #> 3 1049266 2018-01-01 05:29:06 6739 VERMO… A WEB 1 #> 4 1049267 2018-01-01 08:53:07 5444 ITASK… A WEB 7 #> 5 1049268 2018-01-01 09:13:22 CASS AVE &… B PHONE 60 #> 6 1049269 2018-01-01 10:12:26 6441 LLOYD… A WEB 42 #> 7 1049270 2018-01-01 10:52:32 3100 WINNE… B PHONE 19 #> 8 1049271 2018-01-01 10:54:43 S GRAND AV… B PHONE 25 #> 9 1049272 2018-01-01 11:07:02 SIDNEY ST … B WEB 25 #> 10 1049273 2018-01-01 12:05:40 5400 N BRO… B PHONE 79 #> # … with 1,496 more rows, and 11 more variables: ward <dbl>, problemcode <chr>, #> # description <chr>, submitto <chr>, status <chr>, dateinvtdone <dttm>, #> # datetimeclosed <dttm>, prjcompletedate <dttm>, datecancelled <dttm>, #> # missing <lgl>, geometry <POINT [°]>