import.asc: Arcview ASCII Raster File Importation And Exportation

Description Usage Arguments Details Value Author(s) References See Also Examples

Description

import.asc imports ESRI ArcInfo ASCII raster file ; conversely, export.asc allows to export an asc object to a ESRI ArcInfo ASCII raster file.

Usage

1
2
3
4
5
6
7
import.asc(file, type = c("numeric", "factor"), lev = NULL,
           levnb = 1, labnb = 3)
export.asc(x, file)
as.asc(x, xll = 1, yll = 1, cellsize = 1, type = c("numeric", "factor"),
       lev = levels(factor(x)))
## S3 method for class 'asc'
print(x, ...)

Arguments

file

a character string. The name of an Arcview ASCII Raster file

type

a character string. Either "numeric" or "factor"

lev

if type = "factor", either a vector giving the labels of the factor levels, or the name of a file giving the correspondence table of the map (see details)

levnb

if lev is the name of a file containing a correspondence table exported from Arcview, the column number in this table where the factor levels are stored (i.e. the numbers indicating the levels of the factor)

labnb

if lev is the name of a file containing a correspondence table exported from Arcview, the column number in this table where the factor labels are stored (i.e. the character strings indicating the labels associated with each level of the factor)

x

a matrix of class asc. For the function as.asc, a matrix

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

...

additionnal arguments to be passed to the function print

Details

With Arcview 3.x: ASCII raster files are created using the command "File -> Export data source"
With Arcview 8/9: ASCII raster files are created by the command "Arc Toolbox -> Conversion tools -> From raster -> Raster to ASCII".
With GRASS, the best way to import a raster map within R is to use the package spgrass6, and then to use the function spixdf2kasc to convert the files to format that can be managed by adehabitat.
ASCII raster files may also be created using other free programs, such as landserf (http://www.soi.city.ac.uk/~jwo/landserf/).

Raster maps are stored as matrices of class asc with adehabitat. They may be of type "numeric" (e.g. elevation on an area) or "factor" (e.g. the type of vegetation on an area). If the map is of type factor, the levels should be indicated. The ".asc" files store the values of the mapped variable with numeric values. Each level of the factor is coded on the map by a number. The argument lev of import.asc or as.asc gives the labels corresponding to each number. Alternatively, these levels may be specified using a correspondence table exported from Arcview (with this software, command "Theme -> table", then "File -> Export", and finally export in delimited text format). An example of such file is provided in the directory "ascfiles" of the package, see the examples below. export.asc allows only exportation of numeric maps.

Value

Returns a raster matrix of the class asc, 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)

Clement Calenge clement.calenge@oncfs.gouv.fr

References

Arcview: http://www.esri.com
Landserf: http://www.soi.city.ac.uk/~jwo/landserf/

See Also

image.asc

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
## Not run: 
## Importation of asc files: numeric
## Path of the file to be imported
(file1 <-  paste(system.file(package = "adehabitat"),
               "ascfiles/elevation.asc", sep = "/"))
el <- import.asc(file1)
image(el)
el


## Importation of asc files: factor
(file2 <- paste(system.file(package = "adehabitat"),
              "ascfiles/aspect.asc", sep = "/"))
(levelfile <- paste(system.file(package = "adehabitat"),
              "ascfiles/aspect.txt", sep = "/"))
asp <- import.asc(file2, lev = levelfile, type = "factor")
image(asp)
asp


## map of white noise
wafwaf <- matrix(rnorm(10000), 100, 100)
wafwaf <- as.asc(wafwaf)
image(wafwaf)

## exportation of a map
export.asc(wafwaf, "foo.asc")

## remove the created file:
file.remove("foo.asc")

## End(Not run)

adehabitat documentation built on Jan. 28, 2018, 5:02 p.m.