jasonratcliff / thesis

Source code and data for MSc thesis
https://scholarworks.uni.edu/etd/1108
Other
0 stars 0 forks source link

Add `rgdal` dependency for `elevatr` #83

Closed jasonratcliff closed 1 year ago

jasonratcliff commented 1 year ago

Elevation plot base layer call to elevatr requires rgdal package.

Error

> testthat::test_file("tests/testthat/test-maps.R")

── Error (test-maps.R:173:3): SpecimenMap R6 Subclass ──────────────────────────
Error in `sp::spTransform(locations, sp::CRS(SRS_string = "EPSG:4326"))`: package rgdal is required for spTransform methods
Backtrace:
 1. testthat::expect_s3_class(...)
      at test-maps.R:173:2
 4. vouchers$map(baselayer = "elevatr")
 5. private$base_elevatr(zoom = zoom)
 6. elevatr::get_elev_raster(...)
 7. elevatr:::estimate_raster_size(locations, prj, src, z)
 9. sp::spTransform(locations, sp::CRS(SRS_string = "EPSG:4326"))

[ FAIL 1 | WARN 0 | SKIP 0 | PASS 42 ]

Fix

  1. Add rgdal to DESCRIPTION as package import:
> usethis::use_package(package = "rgdal", type = "Imports")
  1. Update renv.lock lockfile to include package metadata:
> renv::snapshot()
The following package(s) will be updated in the lockfile:

# Bioconductor =======================
- ggtree   [3.8.0: unchanged]

# CRAN ===============================
- rgdal    [* -> 1.6-6]

Do you want to proceed? [y/N]: y
* Lockfile written to '/workspace/thesis/renv.lock'.
jasonratcliff commented 1 year ago

Note additional warnings observed on Gitpod but not locally:

> testthat::test_file("tests/testthat/test-maps.R")

══ Testing test-maps.R ═════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════
[ FAIL 0 | WARN 0 | SKIP 0 | PASS 41 ]i <https://maps.googleapis.com/maps/api/staticmap?center=44.5,-109.5&zoom=7&size=640x640&scale=2&maptype=satellite&language=en-EN&key=xxx>
Coordinate system already present. Adding new coordinate system, which will replace the existing one.
 Accessing raster elevation [=========================] 100%
Mosaicing & Projecting
Clipping DEM to bbox
[ FAIL 0 | WARN 5 | SKIP 0 | PASS 43 ]

── Warning (test-maps.R:173:3): SpecimenMap R6 Subclass ────────────────────────
NULL source CRS comment, falling back to PROJ string
Backtrace:
 1. testthat::expect_s3_class(...)
      at test-maps.R:173:2
 4. vouchers$map(baselayer = "elevatr")
 5. private$base_elevatr(zoom = zoom)
 6. elevatr::get_elev_raster(...)
 7. elevatr:::estimate_raster_size(locations, prj, src, z)
 9. sp::spTransform(locations, sp::CRS(SRS_string = "EPSG:4326"))

── Warning (test-maps.R:173:3): SpecimenMap R6 Subclass ────────────────────────
NULL source CRS comment, falling back to PROJ string
Backtrace:
  1. testthat::expect_s3_class(...)
       at test-maps.R:173:2
  4. vouchers$map(baselayer = "elevatr")
  5. private$base_elevatr(zoom = zoom)
  6. elevatr::get_elev_raster(...)
  7. elevatr::get_aws_terrain(...)
  8. elevatr:::proj_expand(locations, prj, expand)
 11. sp::spTransform(bbx, sp::CRS(ll_geo))

── Warning (test-maps.R:173:3): SpecimenMap R6 Subclass ────────────────────────
NULL target CRS comment, falling back to PROJ string
Backtrace:
  1. testthat::expect_s3_class(...)
       at test-maps.R:173:2
  4. vouchers$map(baselayer = "elevatr")
  5. private$base_elevatr(zoom = zoom)
  6. elevatr::get_elev_raster(...)
  7. elevatr::get_aws_terrain(...)
  8. elevatr:::proj_expand(locations, prj, expand)
 11. sp::spTransform(bbx, sp::CRS(ll_geo))

── Warning (test-maps.R:173:3): SpecimenMap R6 Subclass ────────────────────────
NULL source CRS comment, falling back to PROJ string
Backtrace:
  1. testthat::expect_s3_class(...)
       at test-maps.R:173:2
  4. vouchers$map(baselayer = "elevatr")
  5. private$base_elevatr(zoom = zoom)
  6. elevatr::get_elev_raster(...)
  7. elevatr:::clip_it(raster_elev, locations, expand, clip)
  9. sp::spTransform(loc, raster::crs(rast))
 11. rgdal (local) spTransform(xSP, CRSobj, ...)

── Warning (test-maps.R:173:3): SpecimenMap R6 Subclass ────────────────────────
NULL target CRS comment, falling back to PROJ string
Backtrace:
  1. testthat::expect_s3_class(...)
       at test-maps.R:173:2
  4. vouchers$map(baselayer = "elevatr")
  5. private$base_elevatr(zoom = zoom)
  6. elevatr::get_elev_raster(...)
  7. elevatr:::clip_it(raster_elev, locations, expand, clip)
  8. elevatr:::proj_expand(...)
 11. sp::spTransform(bbx, sp::CRS(ll_geo))

[ FAIL 0 | WARN 5 | SKIP 0 | PASS 43 ]