ogrinfo: Retrieve information about a vector data source

View source: R/RcppExports.R

ogrinfoR Documentation

Retrieve information about a vector data source

Description

ogrinfo() is a wrapper of the ogrinfo command-line utility (see https://gdal.org/en/stable/programs/ogrinfo.html). This function lists information about an OGR-supported data source. It is also possible to edit data with SQL statements. Refer to the GDAL documentation at the URL above for a description of command-line arguments that can be passed in cl_arg. Requires GDAL >= 3.7.

Usage

ogrinfo(
  dsn,
  layers = NULL,
  cl_arg = as.character(c("-so", "-nomd")),
  open_options = NULL,
  read_only = TRUE,
  cout = TRUE
)

Arguments

dsn

Character string. Data source name (e.g., filename, database connection string, etc.)

layers

Optional character vector of layer names in the source dataset.

cl_arg

Optional character vector of command-line arguments for the ogrinfo command-line utility in GDAL (see URL above for reference). The default is c("-so", "-nomd") (see Note).

open_options

Optional character vector of dataset open options.

read_only

Logical scalar. TRUE to open the data source read-only (the default), or FALSE to open with write access.

cout

Logical scalar. TRUE to write info to the standard C output stream (the default). FALSE to suppress console output.

Value

Invisibly, a character string containing information about the vector dataset, or empty string ("") in case of error.

Note

The command-line argument -so provides a summary only, i.e., does not include details about every single feature of a layer. -nomd suppresses metadata printing. Some datasets may contain a lot of metadata strings.

See Also

ogr2ogr(), ogr_manage

Examples


src <- system.file("extdata/ynp_fires_1984_2022.gpkg", package="gdalraster")

# Get the names of the layers in a GeoPackage file
ogrinfo(src)

# Summary of a layer
ogrinfo(src, "mtbs_perims")

# Query an attribute to restrict the output of the features in a layer
args <- c("-ro", "-nomd", "-where", "ig_year = 2020")
ogrinfo(src, "mtbs_perims", args)

# Copy to a temporary in-memory file that is writeable
src_mem <- paste0("/vsimem/", basename(src))
vsi_copy_file(src, src_mem)

# Add a column to a layer
args <- c("-sql", "ALTER TABLE mtbs_perims ADD burn_bnd_ha float")
ogrinfo(src_mem, cl_arg = args, read_only = FALSE)

# Update values of the column with SQL and specify a dialect
sql <- "UPDATE mtbs_perims SET burn_bnd_ha = (burn_bnd_ac / 2.471)"
args <- c("-dialect", "sqlite", "-sql", sql)
ogrinfo(src_mem, cl_arg = args, read_only = FALSE)


gdalraster documentation built on June 8, 2025, 12:37 p.m.