read.asc: ESRI ASCII Raster File Import And Export

Description Usage Arguments Details Value Author(s) Examples

Description

read.asc and read.asc.gz reads ESRI ArcInfo ASCII raster file either uncompressed or compressed using gzip.

write.asc and write.asc.gz writes an asc object to a ESRI ArcInfo ASCII raster file. The output can be either compressed or uncompressed.

These functions are faster methods based on the adehabitat import.asc and export.asc.

write.asc2 and write.asc2.gz are even faster implementations but have less error checking.

image.asc and print.asc are generic methods associated with plotting & summarizing data of class 'asc'; they were modified from adehabitat package.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
read.asc(file, gz = FALSE)

read.asc.gz(file)

write.asc(x, file, gz = FALSE)

write.asc.gz(x, file)

write.asc2(x, file, sigdig = 0, gz = FALSE)

write.asc2.gz(x, file, sigdig = 0)

## S3 method for class 'asc'
image(x, col = gray((240:1)/256), clfac = NULL, ...)

## S3 method for class 'asc'
print(x, ...)

Arguments

file

a character string representing the filename of the input/output file. The file extension should always be '.asc'.

gz

defines if the object is or should be compressed using gzip

x

an object of class 'asc' as defined in the adehabitat package

sigdig

is the number of significant digits to write when creating the ascii grid file

col

for maps of type "numeric", the colors to be used (see help(par))

clfac

for maps of type "factor", a character vector giving the names of colors for each level of the factor (see help(colasc))

...

additional arguments to be passed to the generic function image or print

Details

Implements a faster version of import.asc or export.asc from the adehabitat package. In addition, files can be read in and written to in gzip compressed format.

Generic methods of print and image were modified from adehabitat. Further details of them are found there.

Value

Returns a raster matrix of the class 'asc' defined in the adehabitat package with the following attributes:

xll

the x coordinate of the center of the lower left pixel of the map

yll

the y coordinate of the center of the lower left pixel of the map

cellsize

the size of a pixel on the studied map

type

either 'numeric' or 'factor'

levels

if type = 'factor', the levels of the factor.

Author(s)

Jeremy VanDerWal jjvanderwal@gmail.com

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
#create a simple object of class 'asc'
tasc = as.asc(matrix(rep(x=1:10, times=1000),nr=100)); print(tasc)

#write out the raster grid file
write.asc(tasc,'t.raster.asc')
write.asc.gz(tasc,'t.raster.asc') #actually save file name as t.raster.asc.gz

#read in the raster grid files
tasc2 = read.asc('t.raster.asc')
tasc3 = read.asc.gz('t.raster.asc.gz')

#remove the temporary raster
unlink(c('t.raster.asc','t.raster.asc.gz'))

jjvanderwal/SDMTools documentation built on May 19, 2019, 11:40 a.m.