ogr2ogr: Interface to GDAL's ogr2ogr utility

View source: R/ogr2ogr.R

ogr2ogrR Documentation

Interface to GDAL's ogr2ogr utility

Description

This function provides an interface mirroring that of the GDAL command-line app ogr2ogr. For a description of the utility and the arguments that it takes, see the documentation at https://gdal.org/programs/ogr2ogr.html.

Usage

ogr2ogr(
  src_datasource_name,
  dst_datasource_name,
  ...,
  layer,
  f,
  append,
  overwrite,
  update,
  select,
  progress,
  sql,
  dialect,
  where,
  skipfailures,
  spat,
  spat_srs,
  geomfield,
  dsco,
  lco,
  nln,
  nlt,
  dim,
  a_srs,
  t_srs,
  s_srs,
  ct,
  preserve_fid,
  fid,
  limit,
  oo,
  doo,
  gt,
  ds_transaction,
  clipsrc,
  clipsrcsql,
  clipsrclayer,
  clipsrcwhere,
  clipdst,
  clipdstsql,
  clipdstlayer,
  clipdstwhere,
  wrapdateline,
  datelineoffset,
  simplify,
  segmentize,
  makevalid,
  fieldTypeToString,
  unsetFieldWidth,
  mapFieldType,
  fieldmap,
  splitlistfields,
  maxsubfields,
  resolveDomains,
  explodecollections,
  zfield,
  gcp,
  order,
  tps,
  s_coord_epoch,
  t_coord_epoch,
  a_coord_epoch,
  addfields,
  unsetFid,
  emptyStrAsNull,
  relaxedFieldNameMatch,
  forceNullable,
  unsetDefault,
  nomd,
  mo,
  noNativeData,
  config_options = character(0),
  dryrun = FALSE
)

Arguments

src_datasource_name

Character. Path to a GDAL-supported readable datasource.

dst_datasource_name

Character. Path to a GDAL-supported output file.

...

Here, a placeholder argument that forces users to supply exact names of all subsequent formal arguments.

layer, f, append, overwrite, update, select, progress, sql, dialect

See the GDAL project's ogr2ogr documentation for details.

where, skipfailures, spat, spat_srs, geomfield, dsco, lco, nln, nlt

See ogr2ogr documentation.

dim, a_srs, t_srs, s_srs, ct, preserve_fid, fid, limit, oo, doo, gt

See the See ogr2ogr documentation.

ds_transaction, clipsrc, clipsrcsql, clipsrclayer, clipsrcwhere

See ogr2ogr documentation.

clipdst, clipdstsql, clipdstlayer, clipdstwhere, wrapdateline

See ogr2ogr documentation.

datelineoffset, simplify, segmentize, makevalid, addfields

See See ogr2ogr documentation.

fieldmap, splitlistfields, maxsubfields

See ogr2ogr documentation.

resolveDomains, explodecollections, zfield, gcp, order, tps

See ogr2ogr documentation.

s_coord_epoch, t_coord_epoch, a_coord_epoch

See ogr2ogr documentation.

unsetFid, emptyStrAsNull, relaxedFieldNameMatch, forceNullable

See See ogr2ogr documentation.

unsetDefault, fieldTypeToString, unsetFieldWidth, mapFieldType

See ogr2ogr documentation.

nomd, mo, noNativeData

See ogr2ogr documentation.

config_options

A named character vector with GDAL config options, of the form c(option1=value1, option2=value2). (See here for a complete list of supported config options.)

dryrun

Logical (default FALSE). If TRUE, instead of executing the requested call to GDAL, the function will print the command-line call that would produce the equivalent output.

Value

Silently returns path to dst_datasource_name.

Author(s)

Joshua O'Brien

Examples


## Prepare file paths
td <- tempdir()
lux <- system.file("ex/lux.shp", package = "terra")
lux_merc <- file.path(td, "mercator.shp")
lux_lcc <- file.path(td, "lcc.shp")

## Reproject to 'WGS 84/World Mercator'
## https://en.wikipedia.org/wiki/Mercator_projection
ogr2ogr(lux, lux_merc, t_srs = "EPSG:3395", overwrite = TRUE)
## Reproject to a Canadian 'Lambert conformal conic projection'
## https://en.wikipedia.org/wiki/Lambert_conformal_conic_projection
ogr2ogr(lux, lux_lcc, t_srs = "EPSG:3347", overwrite = TRUE)

if(require(terra)) {
    op <- par(mfcol = c(1,2))
    plot(vect(lux_merc), main = "WGS 84",
         border = "darkgrey", col = gray.colors(12))
    plot(vect(lux_lcc), main = "LCC",
         border = "darkgrey", col = gray.colors(12))
    par(op)
}


gdalUtilities documentation built on Aug. 10, 2023, 5:08 p.m.