Skip to content

Commit

Permalink
getting ready for v1.0 release - fix to rgdal, rgeos, etc.
Browse files Browse the repository at this point in the history
  • Loading branch information
jhollist committed Aug 17, 2023
1 parent 634edb4 commit 325f1f2
Show file tree
Hide file tree
Showing 13 changed files with 131 additions and 38 deletions.
14 changes: 9 additions & 5 deletions DESCRIPTION
@@ -1,6 +1,6 @@
Package: elevatr
Title: Access Elevation Data from Various APIs
Version: 1.0.0.9999
Version: 1.0.0
Authors@R: c(person("Jeffrey", "Hollister", email = "hollister.jeff@epa.gov",
role = c("aut", "cre"), comment = c(ORCID = "0000-0002-9254-9740")),
person("Tarak","Shah", role = "ctb"),
Expand All @@ -12,9 +12,11 @@ BugReports: https://github.com/jhollist/elevatr/issues/
Maintainer: Jeffrey Hollister <hollister.jeff@epa.gov>
Description: Several web services are available that provide access to elevation
data. This package provides access to many of those services and
returns elevation data either as a simple features POINT/MULTIPOINT from
point elevation services or as a terra SpatRaster object from raster
elevation services. Currently, the package supports access to the
returns elevation data either as a simple features POINT/MULTIPOINT
from point elevation services or as a raster RasterLayer from raster
elevation services. . In future versions, elevatr will drop
support for raster Raster Layers and will instead return terra
SpatRaster objects. Currently, the package supports access to the
Amazon Web Services Terrain Tiles <https://registry.opendata.aws/terrain-tiles/>,
the Open Topography Global Datasets API <https://opentopography.org/developers/>,
and the USGS Elevation Point Query Service <https://apps.nationalmap.gov/epqs/>.
Expand All @@ -30,7 +32,9 @@ Imports:
purrr,
units,
slippymath,
curl
curl,
raster,
methods
License: MIT + file LICENSE
Encoding: UTF-8
LazyData: true
Expand Down
3 changes: 2 additions & 1 deletion NEWS.md
@@ -1,10 +1,11 @@
elevatr 1.0.0 (????-??-??)
elevatr 1.0.0 (2023-08-17)
=============

# Major refactor
- dropped sp, rgdal and rgeos depends
- All sf
- Terra
- Still returns RasterLayer, but raster will be dropped in upcoming release.

# Vignette
- Add location clip example
Expand Down
3 changes: 2 additions & 1 deletion R/get_elev_point.R
Expand Up @@ -54,7 +54,7 @@
#' #Empty Raster
#' mts_raster <- rast(mts_sf, nrow = 5, ncol = 5)
#' # Raster with cells for each location
#' mts_raster_loc <- terra::rasterize(x, rast(x, nrow = 10, ncol = 10))
#' mts_raster_loc <- terra::rasterize(mts_sf, rast(mts_sf, nrow = 10, ncol = 10))
#'
#' get_elev_point(locations = mts, prj = ll_prj)
#' get_elev_point(locations = mts, units="feet", prj = ll_prj)
Expand Down Expand Up @@ -309,6 +309,7 @@ get_aws_points <- function(locations, z = 5, units = c("meters", "feet"),
verbose = TRUE, ...){
units <- match.arg(units)
dem <- get_elev_raster(locations, z, verbose = verbose, ...)
dem <- methods::as(dem, "SpatRaster")
elevation <- units::set_units(terra::extract(dem, locations)[,2], "m")
if(units == "feet"){
elevation <- as.numeric(units::set_units(elevation, "ft"))
Expand Down
6 changes: 5 additions & 1 deletion R/get_elev_raster.R
Expand Up @@ -66,6 +66,8 @@
#' @export
#' @examples
#' \dontrun{
#' library(elevatr)
#' library(sf)
#' data(lake)
#' lake_buff <- st_buffer(lake, 1000)
#' loc_df <- data.frame(x = runif(6,min=sf::st_bbox(lake)$xmin,
Expand Down Expand Up @@ -145,7 +147,9 @@ get_elev_raster <- function(locations, z, prj = NULL,
}

attr(raster_elev, "sources") <- sources
raster_elev
#Returning raster for now
#Switch to SpatRaster in near future.
raster::raster(raster_elev)

}

Expand Down
4 changes: 3 additions & 1 deletion R/zzz.R
Expand Up @@ -3,7 +3,9 @@ op <- options()
.onAttach <- function(libname, pkgname) {
packageStartupMessage(
"elevatr v1+ NOTE: Version 1.0+ of 'elevatr' use 'sf' and 'terra'.
The 'sp' and 'raster' packages are no longer supported.")
Support for the 'sp' and 'raster' packages is being deprecated; however,
get_elev_raster continues to return a RasterLayer. This will be dropped in
future versions, so please plan accordingly.")
}

.onUnload <- function(libname, pkgname){
Expand Down
2 changes: 1 addition & 1 deletion man/get_elev_point.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions man/get_elev_raster.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 12 additions & 9 deletions revdep/README.md
Expand Up @@ -10,23 +10,26 @@
|collate |English_United States.utf8 |
|ctype |English_United States.utf8 |
|tz |America/New_York |
|date |2023-05-30 |
|date |2023-06-16 |
|rstudio |2022.12.0+353 Elsbeth Geranium (desktop) |
|pandoc |NA |

# Dependencies

|package |old |new |Δ |
|:----------|:-----|:------|:--|
|elevatr |0.4.2 |0.4.3 |* |
|parallelly |NA |1.36.0 |* |
|sf |NA |1.0-13 |* |
|package |old |new |Δ |
|:--------|:-----|:----------|:--|
|elevatr |0.4.5 |1.0.0.9999 |* |
|curl |NA |5.0.1 |* |
|jsonlite |NA |1.8.5 |* |
|sf |NA |1.0-13 |* |
|sp |NA |1.6-1 |* |
|vctrs |NA |0.6.3 |* |

# Revdeps

## Failed to check (1)

|package |version |error |warning |note |
|:---------|:-------|:-----|:-------|:----|
|shoredate |1.0.2 |1 | | |
|package |version |error |warning |note |
|:---------|:-------|:--------|:-------|:----|
|[shoredate](failures.md#shoredate)|1.1.0 |1 __+1__ | | |

2 changes: 1 addition & 1 deletion revdep/cran.md
@@ -1,6 +1,6 @@
## revdepcheck results

We checked 9 reverse dependencies, comparing R CMD check results across CRAN and dev versions of this package.
We checked 10 reverse dependencies, comparing R CMD check results across CRAN and dev versions of this package.

* We saw 0 new problems
* We failed to check 1 packages
Expand Down
31 changes: 28 additions & 3 deletions revdep/failures.md
Expand Up @@ -2,16 +2,41 @@

<details>

* Version: 1.0.2
* Version: 1.1.0
* GitHub: https://github.com/isakro/shoredate
* Source code: https://github.com/cran/shoredate
* Date/Publication: 2023-05-02 23:00:02 UTC
* Number of recursive dependencies: 115
* Date/Publication: 2023-06-02 23:40:02 UTC
* Number of recursive dependencies: 116

Run `revdepcheck::revdep_details(, "shoredate")` for more info

</details>

## Newly broken

* checking tests ...
```
Running 'testthat.R'
ERROR
Running the tests in 'tests/testthat.R' failed.
Last 13 lines of output:
1. └─elevatr::get_elev_raster(target_wgs84, z = 14, src = "aws") at test-shoreline_date.R:111:2
2. └─elevatr:::loc_check(locations, prj)
3. ├─sf::st_coordinates(locations)
4. └─sf:::st_coordinates.sfc(locations)
5. └─base::matrix(...)
══ Failed tests ════════════════════════════════════════════════════════════════
── Error ('test-shoreline_date.R:113:3'): finding site elevation from a raster works ──
`shoreline_date(target_point, elevation = elev_raster)` threw an unexpected error.
Message: [extract] raster has no values
Class: simpleError/error/condition
[ FAIL 1 | WARN 1 | SKIP 1 | PASS 112 ]
Error: Test failures
Execution halted
```

## In both

* R CMD check timed out
Expand Down
45 changes: 44 additions & 1 deletion revdep/problems.md
@@ -1 +1,44 @@
*Wow, no problems at all. :)*
# shoredate

<details>

* Version: 1.1.0
* GitHub: https://github.com/isakro/shoredate
* Source code: https://github.com/cran/shoredate
* Date/Publication: 2023-06-02 23:40:02 UTC
* Number of recursive dependencies: 116

Run `revdepcheck::revdep_details(, "shoredate")` for more info

</details>

## Newly broken

* checking tests ...
```
Running 'testthat.R'
ERROR
Running the tests in 'tests/testthat.R' failed.
Last 13 lines of output:
1. └─elevatr::get_elev_raster(target_wgs84, z = 14, src = "aws") at test-shoreline_date.R:111:2
2. └─elevatr:::loc_check(locations, prj)
3. ├─sf::st_coordinates(locations)
4. └─sf:::st_coordinates.sfc(locations)
5. └─base::matrix(...)
══ Failed tests ════════════════════════════════════════════════════════════════
── Error ('test-shoreline_date.R:113:3'): finding site elevation from a raster works ──
`shoreline_date(target_point, elevation = elev_raster)` threw an unexpected error.
Message: [extract] raster has no values
Class: simpleError/error/condition
[ FAIL 1 | WARN 1 | SKIP 1 | PASS 112 ]
Error: Test failures
Execution halted
```

## In both

* R CMD check timed out


33 changes: 20 additions & 13 deletions tests/testthat/test-get_elev_raster.R
Expand Up @@ -25,14 +25,18 @@ test_that("get_elev_raster returns correctly", {
aws_sf_raster <- get_elev_raster(locations = sf_sm_raster, z = 6, src = "aws")

#class
expect_is(aws,"SpatRaster")
expect_is(aws_prj,"SpatRaster")
expect_is(aws_blnk_raster, "SpatRaster")
expect_is(aws_sf_raster, "SpatRaster")
#expect_is(aws,"SpatRaster")
#expect_is(aws_prj,"SpatRaster")
#expect_is(aws_blnk_raster, "SpatRaster")
#expect_is(aws_sf_raster, "SpatRaster")
expect_is(aws,"RasterLayer")
expect_is(aws_prj,"RasterLayer")
expect_is(aws_blnk_raster, "RasterLayer")
expect_is(aws_sf_raster, "RasterLayer")

#project
#expect_equal(st_crs(aws)$wkt,st_crs(ll_prj)$wkt)
expect_equal(st_crs(aws_prj)$wkt,st_crs(aea_prj)$wkt)
#expect_equal(st_crs(aws_prj)$wkt,st_crs(aea_prj)$wkt) remove comment when back to terra

})

Expand All @@ -41,10 +45,10 @@ test_that("get_elev_raster clip argument works", {
default_clip <- get_elev_raster(lake, z = 5, clip = "tile")
bbox_clip <- get_elev_raster(lake, z = 5, clip = "bbox")
locations_clip <- get_elev_raster(lake, z = 5, clip = "locations")
spat_rast_tile <- get_elev_raster(locations = sf_sm_raster, z = 5,
src = "aws", clip = "tile")
spat_rast_loc <- get_elev_raster(locations = sf_sm_raster, z = 5,
src = "aws", clip = "locations")
spat_rast_tile <- terra::rast(get_elev_raster(locations = sf_sm_raster, z = 5,
src = "aws", clip = "tile"))
spat_rast_loc <- terra::rast(get_elev_raster(locations = sf_sm_raster, z = 5,
src = "aws", clip = "locations"))

default_values <- terra::values(default_clip)
num_cell_default <- length(default_values[!is.na(default_values)])
Expand All @@ -71,12 +75,14 @@ test_that("get_elev_raster returns correctly from opentopo", {
clip = "bbox")

#class
expect_is(gl1,"SpatRaster")
expect_is(gl1_prj,"SpatRaster")
#expect_is(gl1,"SpatRaster")
#expect_is(gl1_prj,"SpatRaster")
expect_is(gl1,"RasterLayer")
expect_is(gl1_prj,"RasterLayer")

#project
#expect_equal(st_crs(gl1)$wkt,st_crs(ll_prj)$wkt)
expect_equal(st_crs(gl1_prj)$wkt,st_crs(aea_prj)$wkt)
#expect_equal(st_crs(gl1_prj)$wkt,st_crs(aea_prj)$wkt) turn back on after switch to terra

})

Expand All @@ -91,7 +97,8 @@ test_that("Parallel processing works",{
aws <- get_elev_raster(locations = sf_sm, z = 6, src = "aws", serial = TRUE)

#class
expect_is(serial_elev,"SpatRaster")
#expect_is(serial_elev,"SpatRaster")
expect_is(serial_elev,"RasterLayer")

#same size as serial
expect_equal(ncell(serial_elev),ncell(aws))
Expand Down
3 changes: 2 additions & 1 deletion tests/testthat/test-internal.R
Expand Up @@ -47,7 +47,8 @@ test_that("proj_expand works",{
origin_sf <- st_as_sf(data.frame(x = 0, y = 0), coords = c("x", "y"),
crs = ll_prj)
origins <- get_elev_raster(locations = origin_sf, z = 6)
expect_is(origins, "SpatRaster")
#expect_is(origins, "SpatRaster")
expect_is(origins, "RasterLayer")
})

test_that("loc_check errors correctly", {
Expand Down

0 comments on commit 325f1f2

Please sign in to comment.