Skip to content

utm_convert() drops tbl class #143

Closed
@ateucher

Description

library(dplyr)
#> 
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union
library(bcmaps)
#> Loading required package: sf
#> Linking to GEOS 3.11.0, GDAL 3.5.3, PROJ 9.1.0; sf_use_s2() is TRUE
#> Support for Spatial objects (`sp`) was removed in {bcmaps} v2.0.0. Please use `sf` objects with {bcmaps}.

tbl <- dplyr::tibble(
  a = "a",
  zone = 10,
  easting = 321123,
  northing = 5555555
)
tbl
#> # A tibble: 1 × 4
#>   a      zone easting northing
#>   <chr> <dbl>   <dbl>    <dbl>
#> 1 a        10  321123  5555555
class(tbl)
#> [1] "tbl_df"     "tbl"        "data.frame"

out <- utm_convert(tbl, "easting", "northing", "zone")

out
#> Simple feature collection with 1 feature and 6 fields
#> Geometry type: POINT
#> Dimension:     XY
#> Bounding box:  xmin: 1035564 ymin: 567840.9 xmax: 1035564 ymax: 567840.9
#> Projected CRS: NAD83 / BC Albers
#>    a zone       X        Y easting northing                 geometry
#> 10 a   10 1035564 567840.9  321123  5555555 POINT (1035564 567840.9)
class(out)
#> [1] "sf"         "data.frame"

Created on 2024-01-30 with reprex v2.1.0

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions