This adds a function utm_convert() to convert tabular data in UTM zones to a standard CRS (default BC Albers). This is especially useful for field studies with data collected over a wide area that spans UTM zones.
The location data is expected to be in two columns with x and y, and the zone can be either in a column (when the data set spans multiple UTM zones), or can be specified for the whole data set. E.g.:
# Data with multiple zones, and a column denoting the zone
df <- data.frame(
animalid = c("a", "b", "c"),
zone = c(10, 11, 11),
easting = c(500000, 800000, 700000),
northing = c(5000000, 3000000, 1000000)
)
utm_convert(df, xcol = "easting", ycol = "northing", zone = "zone")
#> Simple feature collection with 3 features and 6 fields
#> Geometry type: POINT
#> Dimension: XY
#> Bounding box: xmin: 1237767 ymin: -3576605 xmax: 2418043 ymax: 21953.96
#> Projected CRS: NAD83 / BC Albers
#> animalid zone X Y easting northing
#> 10 a 10 1237767 21953.96 5e+05 5e+06
#> 11.2 b 11 2275642 -1807950.91 8e+05 3e+06
#> 11.3 c 11 2418043 -3576604.70 7e+05 1e+06
#> geometry
#> 10 POINT (1237767 21953.96)
#> 11.2 POINT (2275642 -1807951)
#> 11.3 POINT (2418043 -3576605)
# Data all in one zone, specify a single zone:
df <- data.frame(
animalid = c("a", "b"),
easting = c(500000, 800000),
northing = c(5000000, 3000000)
)
utm_convert(df, xcol = "easting", ycol = "northing", zone = 11)
#> Simple feature collection with 2 features and 5 fields
#> Geometry type: POINT
#> Dimension: XY
#> Bounding box: xmin: 1711595 ymin: -1807951 xmax: 2275642 ymax: 62209.93
#> Projected CRS: NAD83 / BC Albers
#> animalid X Y easting northing geometry
#> 1 a 1711595 62209.93 5e+05 5e+06 POINT (1711595 62209.93)
#> 2 b 2275642 -1807950.91 8e+05 3e+06 POINT (2275642 -1807951)
This adds a function
utm_convert()
to convert tabular data in UTM zones to a standard CRS (default BC Albers). This is especially useful for field studies with data collected over a wide area that spans UTM zones.The location data is expected to be in two columns with x and y, and the zone can be either in a column (when the data set spans multiple UTM zones), or can be specified for the whole data set. E.g.:
Created on 2023-11-17 with reprex v2.0.2