bcgov / bcmaps

An R package of map layers for British Columbia
http://bcgov.github.io/bcmaps/
Apache License 2.0
73 stars 17 forks source link

utm_zone_lookup not found #144

Open Karine-Pigeon opened 7 months ago

Karine-Pigeon commented 7 months ago

Error in lookup_epsg_code(zone, datum) : object 'utm_zone_lookup' not found

Fixed by calling the .csv directly using utm_zone_lookup <- read.csv("https://raw.githubusercontent.com/bcgov/bcmaps/main/data-raw/utm-zone-lookup.csv")

R version 4.3.1. bcmaps version 2.2.0

test 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, easting = "easting", northing = "northing", zone = "zone")

boshek commented 7 months ago

Hey @Karine-Pigeon can you provide some info on how you are generating this error? What function are you calling?

Also what versions of bcdata and R are you using? The output of sessionInfo() would be ideal.

stephhazlitt commented 7 months ago

Thanks for adding the reprex @Karine-Pigeon. I cannot seem to reproduce the error with bcmaps::utm_convert()—can you confirm this code errors for you in a fresh session?

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}.

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, easting = "easting", northing = "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)

session_info() ─ Session info ───────────────────────────────────────────────── setting value version R version 4.3.3 (2024-02-29) os macOS Sonoma 14.3.1 system aarch64, darwin20 ui RStudio language (EN) collate en_US.UTF-8 ctype en_US.UTF-8 tz America/Vancouver date 2024-04-04 rstudio 2023.12.1+402 Ocean Storm (desktop) pandoc 3.1.1 @ /Applications/RStudio.app/Contents/Resources/app/quarto/bin/tools/ (via rmarkdown)

─ Packages ───────────────────────────────────────────────────── package version date (UTC) lib source bcmaps 2.2.0 2024-01-24 [1] CRAN (R 4.3.1)