create {gdalraster}R Documentation

Create a new uninitialized raster

Description

create() makes an empty raster in the specified format.

Usage

create(format, dst_filename, xsize, ysize, nbands, dataType, options = NULL)

Arguments

format

Raster format short name (e.g., "GTiff").

dst_filename

Filename to create.

xsize

Integer width of raster in pixels.

ysize

Integer height of raster in pixels.

nbands

Integer number of bands.

dataType

Character data type name. (e.g., common data types include Byte, Int16, UInt16, Int32, Float32).

options

Optional list of format-specific creation options in a vector of "NAME=VALUE" pairs (e.g., options = c("COMPRESS=LZW") to set LZW compression during creation of a GTiff file). The APPEND_SUBDATASET=YES option can be specified to avoid prior destruction of existing dataset.

Value

Logical indicating success (invisible TRUE). An error is raised if the operation fails.

See Also

GDALRaster-class, createCopy(), rasterFromRaster(), getCreationOptions()

Examples

new_file <- file.path(tempdir(), "newdata.tif")
create(format="GTiff", dst_filename=new_file, xsize=143, ysize=107,
       nbands=1, dataType="Int16")
ds <- new(GDALRaster, new_file, read_only=FALSE)
## EPSG:26912 - NAD83 / UTM zone 12N
ds$setProjection(epsg_to_wkt(26912))
gt <- c(323476.1, 30, 0, 5105082.0, 0, -30)
ds$setGeoTransform(gt)
ds$setNoDataValue(band = 1, -9999)
ds$fillRaster(band = 1, -9999, 0)
## ...
## close the dataset when done
ds$close()

deleteDataset(new_file)

[Package gdalraster version 1.11.1 Index]