conn.write_gdal: Write raster image to GDAL file(s)

write_gdalR Documentation

Write raster image to GDAL file(s)

Description

write_gdal writes in-memory object of class ursaRaster to disk using GDAL from rgdal package.

Usage

write_gdal(obj, ...)
ursa_write(obj, fname, ...)

Arguments

obj

Object of class ursaRaster.

...

Arguments, which are passed to create_gdal. Usually, only file name with extension (character) is required. If extension is ".envi", then GDAL driver "ENVI" is used. If extension is ".tif", then GDAL driver "GTiff" is used. If extension is ".img", then GDAL driver "HFA" is used. If extension is ".jpg" or "*.jpeg", then GDAL driver "JPEG" is used. If extension is ".bmp", then GDAL driver "BMP" is used. If extension is ".png", then GDAL driver "PNG" is used. Additionally, argument driver should be specified. If argument ... is missing, then occasional name is assigned.

For GDAL formats it is creation options "-co", e. g., compress="LZW",tiled="NO" are interpeted as -co "COMPRESS=LZW" -co "TILED=NO".

For GDAL formats options= (named list list(foo="bar1", foo2="bar2"), named characters c(foo="bar1", foo2="bar2"), characters in format "foo1=bar1 foo2=bar2") is interpeted as creation options (-co) explicitly.

For GDAL formats driver= is interpeted as driver short name (-fo) explicitly.

fname

Character. File name with extension.

Details

ursa_write is simplified call of write_gdal.

write_gdal implements writing the whole ursaRaster object to disk. For multiple access to disk (by chunks), use followed Replace construction:

a <- create_gdal(fname)
a[condition_1] <- value1
a[condition_2] <- value2
...
close(a)

Value

Integer code of ENVI data type. See values of the “data type” field in description of the ENVI Header Format.

Author(s)

Nikita Platonov platonov@sevin.ru

See Also

create_gdal, Replace method [<- for ursaRaster object, close method for ursaRaster object.

write_envi

Examples

session_grid(NULL)
ftemp <- tempfile(pattern="",fileext="")
fpath <- dirname(ftemp)
fname <- basename(ftemp)
a <- round(ursa_dummy(1,min=0,max=255,nodata=NA))
write_envi(a,file.path(fpath,paste0(fname,"_1",".envi")))
write_gdal(a,file.path(fpath,paste0(fname,"_2")))
write_gdal(a,file.path(fpath,paste0(fname,"_3",".tif")))
write_gdal(a,file.path(fpath,paste0(fname,"_4")),driver="EHdr")
flist <- dir(path=fpath,pattern=fname,full.names=TRUE)
file.remove(flist)
blist <- basename(flist)
res <- NULL
for (i in seq(4))
   res <- c(res,paste(grep(paste0("_",i),blist,value=TRUE),collapse=" "))
print(res)

ursa documentation built on Sept. 30, 2024, 9:35 a.m.