Learn R Programming

arcgislayers (version 0.5.0)

encode_field_values: Encode Domain Values

Description

encode_field_values() can replace column values based on codedValue type field domains from a corresponding Table or FeatureLayer object created with arc_open().

Usage

encode_field_values(
  .data,
  .layer,
  field = NULL,
  codes = c("replace", "label"),
  call = rlang::caller_env()
)

Value

A data.frame with fields encoded with their respective domains.

Arguments

.data

A data frame returned by arc_select() or arc_read().

.layer

A Table or FeatureLayer object. Required.

field

Optional character vector with names of fields to replace. Fields that do not have coded value domains are ignored. Defaults to NULL to replace or label all fields with coded value domains.

codes

Use of field alias values. Defaults to "replace". There are two options:

  • "replace": coded values replace existing column values.

  • "label": coded values are applied as value labels via a "label" attribute.

call

The execution environment of a currently running function, e.g. caller_env(). The function will be mentioned in error messages as the source of the error. See the call argument of abort() for more information.

Examples

Run this code
# \donttest{
layer <- arc_open(
  "https://geodata.baltimorecity.gov/egis/rest/services/Housing/dmxOwnership/MapServer/0"
)

res <- arc_select(
  layer,
  n_max = 100,
  where = "RESPAGCY <> '  '",
  fields = "RESPAGCY"
)
encoded <- encode_field_values(res, layer)
table(encoded$RESPAGCY)
# }

Run the code above in your browser using DataLab