Native interface to gdal utils

gdal_utils(
  util = "info",
  source,
  destination,
  options = character(0),
  quiet = FALSE,
  processing = character(0),
  colorfilename = character(0)
)

Arguments

util

character; one of info, warp, rasterize, translate, vectortranslate (for ogr2ogr), buildvrt, demprocessing, nearblack, grid

source

character; name of input layer(s); for warp or buidvrt this can be more than one

destination

character; name of output layer

options

character; raster layer read options

quiet

logical; if TRUE, suppress printing of output for info

processing

character; processing options for demprocessing

colorfilename

character; name of color file for demprocessing (mandatory if processing="color-relief")

Value

info returns a character vector with the raster metadata; all other utils return (invisibly) a logical indicating success (i.e., TRUE); in case of failure, an error is raised.

Examples

if (sf_extSoftVersion()["GDAL"] > "2.1.0") { # info utils can be used to list information about about a raster # dataset. More info: https://gdal.org/programs/gdalinfo.html in_file <- system.file("tif/geomatrix.tif", package = "sf") gdal_utils("info", in_file, options = c("-mm", "-proj4")) # vectortranslate utils can be used to convert simple features data between # file formats. More info: https://gdal.org/programs/ogr2ogr.html in_file <- system.file("shape/storms_xyz.shp", package="sf") out_file <- paste0(tempfile(), ".gpkg") gdal_utils( util = "vectortranslate", source = in_file, destination = out_file, # output format must be specified for GDAL < 2.3 options = c("-f", "GPKG") ) # The parameters can be specified as c("name") or c("name", "value"). The # vectortranslate utils can perform also various operations during the # conversion process. For example we can reproject the features during the # translation. gdal_utils( util = "vectortranslate", source = in_file, destination = out_file, options = c( "-f", "GPKG", # output file format for GDAL < 2.3 "-s_srs", "EPSG:4326", # input file SRS "-t_srs", "EPSG:2264", # output file SRS "-overwrite" ) ) st_read(out_file) # The parameter s_srs had to be specified because, in this case, the in_file # has no associated SRS. st_read(in_file) }
#> Driver: GTiff/GeoTIFF #> Files: /tmp/RtmpCdQsky/temp_libpath64f92385e079/sf/tif/geomatrix.tif #> Size is 20, 20 #> Coordinate System is: #> PROJCS["WGS 84 / UTM zone 11N", #> GEOGCS["WGS 84", #> DATUM["WGS_1984", #> SPHEROID["WGS 84",6378137,298.257223563, #> AUTHORITY["EPSG","7030"]], #> AUTHORITY["EPSG","6326"]], #> PRIMEM["Greenwich",0, #> AUTHORITY["EPSG","8901"]], #> UNIT["degree",0.0174532925199433, #> AUTHORITY["EPSG","9122"]], #> AUTHORITY["EPSG","4326"]], #> PROJECTION["Transverse_Mercator"], #> PARAMETER["latitude_of_origin",0], #> PARAMETER["central_meridian",-117], #> PARAMETER["scale_factor",0.9996], #> PARAMETER["false_easting",500000], #> PARAMETER["false_northing",0], #> UNIT["metre",1, #> AUTHORITY["EPSG","9001"]], #> AXIS["Easting",EAST], #> AXIS["Northing",NORTH], #> AUTHORITY["EPSG","32611"]] #> PROJ.4 string is: #> '+proj=utm +zone=11 +datum=WGS84 +units=m +no_defs ' #> GeoTransform = #> 1841001.75, 1.5, -5 #> 1144003.25, -5, -1.5 #> Metadata: #> AREA_OR_POINT=Point #> Image Structure Metadata: #> INTERLEAVE=BAND #> Corner Coordinates: #> Upper Left ( 1841001.750, 1144003.250) (104d50'47.45"W, 10d 7'13.55"N) #> Lower Left ( 1840901.750, 1143973.250) (104d50'50.69"W, 10d 7'12.72"N) #> Upper Right ( 1841031.750, 1143903.250) (104d50'46.60"W, 10d 7'10.33"N) #> Lower Right ( 1840931.750, 1143873.250) (104d50'49.85"W, 10d 7' 9.50"N) #> Center ( 1840966.750, 1143938.250) (104d50'48.65"W, 10d 7'11.53"N) #> Band 1 Block=20x20 Type=Byte, ColorInterp=Gray #> Computed Min/Max=74.000,255.000 #> Reading layer `storms_xyz' from data source `/tmp/Rtmp0dwyov/file6cb54a6e9138.gpkg' using driver `GPKG' #> Simple feature collection with 71 features and 0 fields #> geometry type: LINESTRING #> dimension: XYZ #> bbox: xmin: -5785269 ymin: -8509454 xmax: 25097160 ymax: 15846560 #> z_range: zmin: 3031.49 zmax: 3336.608 #> CRS: 2264 #> Reading layer `storms_xyz' from data source `/tmp/RtmpCdQsky/temp_libpath64f92385e079/sf/shape/storms_xyz.shp' using driver `ESRI Shapefile' #> Simple feature collection with 71 features and 0 fields #> geometry type: LINESTRING #> dimension: XYZ #> bbox: xmin: -102.2 ymin: 8.3 xmax: 0 ymax: 59.5 #> z_range: zmin: 924 zmax: 1017 #> CRS: NA