read.asc {SDMTools}R Documentation

ESRI ASCII Raster File Import And Export

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.

Usage

read.asc(file)
read.asc.gz(file)
write.asc(x,file)
write.asc.gz(x,file)

Arguments

file a character string representing the filename of the input/output file. The file extension should always be '.asc'.
x an object of class 'asc' as defined in the adehabitat package

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.

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


#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'))


[Package SDMTools version 1.0 Index]