-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #213 from R-ArcGIS/rasterfn
Add raster function support for `arc_raster()`
- Loading branch information
Showing
7 changed files
with
127 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#' List Available Raster Funcitons | ||
#' | ||
#' This function returns the `rasterFunctionInfos` field of the `ImageServer`'s metadata | ||
#' as a `data.frame`. If the field does not exist then an error is emitted. | ||
#' | ||
#' @inheritParams arcgisutils::infer_esri_type | ||
#' @param x an `ImageServer`. | ||
#' @returns a data.frame of the available raster functions. | ||
#' @examples | ||
#' # example code | ||
#' | ||
list_service_raster_fns <- function(x, arg = rlang::caller_arg(x), call = rlang::caller_call()) { | ||
check_inherits_any(x, "ImageServer") | ||
|
||
if (!x$allowRasterFunction) { | ||
cli::cli_abort("{.arg arg} does not support raster functions") | ||
} | ||
data_frame(x$rasterFunctionInfos) | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
test_that("use raster functions", { | ||
furl <- "https://di-usfsdata.img.arcgis.com/arcgis/rest/services/FIA_BIGMAP_2018_Species_Aboveground_Biomass/ImageServer" | ||
|
||
x <- arc_open(furl) | ||
expect_no_error({ | ||
suppressWarnings({ | ||
balsams <- arc_raster( | ||
x, | ||
xmin = -71, | ||
xmax = -67, | ||
ymin = 43, | ||
ymax = 47.5, | ||
bbox_crs = 4326, | ||
width = 100, | ||
height = 100, | ||
raster_fn = "SPCD_0012_Abies_balsamea" | ||
) | ||
}) | ||
}) | ||
}) | ||
|
||
test_that("list service raster functions", { | ||
furl <- "https://di-usfsdata.img.arcgis.com/arcgis/rest/services/FIA_BIGMAP_2018_Species_Aboveground_Biomass/ImageServer" | ||
|
||
x <- arc_open(furl) | ||
raster_fns <- list_service_raster_fns(x) | ||
expect_identical(names(raster_fns), names(raster_fns)) | ||
expect_s3_class(raster_fns, "data.frame") | ||
expect_s3_class(raster_fns, "tbl") | ||
}) |