Skip to contents

Read an ArcGIS layer (or table or ImageServer) and optionally encode domains

Usage

arc_read_encode(
  url,
  col_names = TRUE,
  col_select = NULL,
  n_max = Inf,
  name_repair = "unique",
  crs = NULL,
  ...,
  fields = NULL,
  alias = "drop",
  token = arcgisutils::arc_token(),
  encode_field_values = FALSE,
  codes = c("replace", "label")
)

Arguments

url

The URL of the FeatureLayer, Table, or ImageServer.

col_names

Default TRUE. Column names or name handling rule. col_names can be TRUE, FALSE, NULL, or a character vector:

  • If TRUE, use existing default column names for the layer or table. If FALSE or NULL, column names will be generated automatically: X1, X2, X3 etc.

  • If col_names is a character vector, values replace the existing column names. col_names can't be length 0 or longer than the number of fields in the returned layer.

col_select

Default NULL. A character vector of the field names to be returned. By default, all fields are returned.

n_max

Defaults to Inf or an option set with options("arcgislayers.n_max" = <max records>). Maximum number of records to return.

name_repair

Default "unique". See vctrs::vec_as_names() for details. If name_repair = NULL and alias = "replace" may include invalid names.

crs

the spatial reference to be returned. If the CRS is different than the CRS for the input FeatureLayer, a transformation will occur server-side. Ignored if x is a Table.

...

Additional arguments passed to arcgislayers::arc_select() if URL is a FeatureLayer or Table or arcgislayers::arc_raster() if URL is an ImageLayer.

fields

Default NULL a character vector of the field names to returned. By default all fields are returned. Ignored if col_names is supplied.

alias

Use of field alias values. Default c("drop", "label", "replace"),. There are three options:

  • "drop", field alias values are ignored.

  • "label": field alias values are assigned as a label attribute for each field.

  • "replace": field alias values replace existing column names. col_names

token

your authorization token.

encode_field_values

Logical, character vector, or list of character vectors.

  • FALSE (the default): do not encode any fields.

  • TRUE: encode all fields that have coded-value domains.

  • Specific field or list of fields to replace. Fields that do not have coded value domains are ignored.

codes

Character scalar, one of "replace" or "label". Passed through to arcgislayers::encode_field_values() to control whether domain labels replace the raw codes or just attach as an attribute.

Value

If url is an ImageServer, a SpatRaster; otherwise an sf or data.frame.