ogr2ogr: Interface to GDAL's ogr2ogr utility

Description Usage Arguments Value Author(s) Examples

View source: R/ogr2ogr.R

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
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,
  mapFieldType,
  unsetFieldWidth,
  splitlistfields,
  maxsubfields,
  explodecollections,
  zfield,
  gcp,
  order,
  tps,
  fieldmap,
  addfields,
  relaxedFieldNameMatch,
  forceNullable,
  unsetDefault,
  unsetFid,
  emptyStrAsNull,
  nomd,
  mo,
  noNativeData,
  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

See See ogr2ogr documentation.

fieldTypeToString, mapFieldType, unsetFieldWidth

See ogr2ogr documentation.

splitlistfields, maxsubfields, explodecollections, zfield, gcp

See ogr2ogr documentation.

order, tps, fieldmap, addfields, relaxedFieldNameMatch

See ogr2ogr documentation.

forceNullable, unsetDefault, unsetFid, emptyStrAsNull, nomd

See ogr2ogr documentation.

mo, noNativeData

See ogr2ogr documentation.

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

None. Called instead for its side effect.

Author(s)

Joshua O'Brien

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
## Prepare file paths
td <- tempdir()
lux <- system.file("external/lux.shp", package = "raster")
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(requireNamespace("raster", quietly = TRUE)) {
    library(raster)
    op <- par(mfcol = c(1,2))
    plot(shapefile(lux_merc), main = "WGS 84",
         border = "darkgrey", col = gray.colors(12))
    plot(shapefile(lux_lcc), main = "LCC",
         border = "darkgrey", col = gray.colors(12))
    par(op)
}

gdalUtilities documentation built on Oct. 26, 2021, 5:06 p.m.