Learn R Programming

adehabitat (version 1.1-1)

import.asc: Arcview ASCII Raster File Importation And Exportation

Description

import.asc imports Arcview ASCII raster file created with the Arcview command "File -> Export data source". Conversely, export.asc allows to export an asc object toward Arcview. ASCII raster files may also be created using the free program landserf (http://www.soi.city.ac.uk/~jwo/landserf/).

Usage

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)))
print.asc(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 lev
x
an object 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

Value

  • Returns a raster matrix of the class asc, with the following attributes :
  • xllthe x coordinate of the center of the lower left pixel of the map
  • yllthe y coordinate of the center of the lower left pixel of the map
  • cellsizethe size of a pixel on the studied map
  • typeeither "numeric" or "factor".
  • levelsif type = "factor", the levels of the factor.

Details

The raster maps 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.

References

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

See Also

image.asc

Examples

Run this code
## 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")

Run the code above in your browser using DataLab