This function runs standard unit tests on sf object parameters for
functions. If the suggested sf package is not installed, it will only
test that x is an object of class sf. The remaining checks for
geometry column name, geometry type, crs, and whether or not a geographic
coordinate system is acceptable all require that the sf package
is installed.
Usage
dis_sf(x, valid_geometry_name = NULL, valid_geometry_type = NULL,
valid_crs = NULL, valid_longlat = NULL, null_valid = TRUE, param = NULL,
call = NULL, fact_check = "global")Arguments
- x
Required object; a parameter argument to test.
- valid_geometry_name
Optional character scalar; required name for the geometry column. If
NULL(default), any name is permissible. If a character string is included (i.e."geometry", the typical name of a geometry column), thesfobject must have a geometry column whose name matches the argument. This test requires thatsfis installed.- valid_geometry_type
Optional character scalar; required geometry type(s) for
x. The most common are"POINT","LINESTRING", and"POLYGON"as well as the"MULTI"versions of each ("MULTIPOINT","MULTILINESTRING", and"MULTIPOLYGON").Other valid geometry types are
"GEOMETRY"and"GEOMETRYCOLLECTION", which is used for "geometry collections." However, you should note that geometry collections will cause errors with some spatial data operations.Less common geometry types include
"CIRCULARSTRING","COMPOUNDCURVE","CURVEPOLYGON","MULTICURVE","MULTISURFACE","CURVE","SURFACE","POLYHEDRALSURFACE","TIN", and"TRIANGLE".If multiple values are given,
xcan be any one of those values. IfNULL(default), this test is skipped. This test requires thatsfis installed.- valid_crs
Optional character scalar; the required CRS value that
xmust use. If multiple values are given,xcan be any one of those values. IfNULL(default), this test is skipped. This test requires thatsfis installed.- valid_longlat
Optional logical scalar; if
TRUE,xmust use a geographic coordinate system. IfFALSE,xmust use a projected coordinate system. IfNULL(default), this test is skipped. This test requires thatsfis installed.- null_valid
Required logical scalar; whether the parameter can be
NULL. IfFALSE, the function will throw an error ifxisNULL. Default isTRUE.- param
Optional character scalar; the parameter name. If
NULL(default), the function will attempt to determine the parameter name from the calling environment. If nesting functions, it is recommended to provide the parameter name to ensure the correct parameter is referenced usingrlang::caller_arg().- call
Optional environment; the environment in which the function was called. If
NULL(default), the function will attempt to determine the calling environment. If nesting functions, it is recommended to provide the calling environment to ensure the correct environment is referenced usingrlang::caller_env().- fact_check
Required character scalar; whether to override fact checking environment setting. If
"global"(default),dis_characterwill follow the global setting. If"always",dis_characterwill ignore any global setting and will always checkx. This argument is primarily intended for Shiny developers who wish to usedisputeRin modules. See the vignette onvignette("developing", package = "disputeR")for details on how to use this function.
Details
See the vignette on vignette("developing", package = "disputeR")
for details about internal validation of arguments for this function.
Examples
# create example function that uses dis_sf()
example <- function(x){
## check inputs with disputeR
dis_not_missing(.f = rlang::is_missing(x))
dis_sf(x)
## return output
return(x)
}
# test example function
# example(x = sf)