import.asc {adehabitat} | R Documentation

## Arcview ASCII Raster File Importation And Exportation

### Description

`import.asc` imports Arcview ASCII raster file created with the Arcview 3.2 command `"File -> Export data source"`, or the Arcview 8 command `"Arc Toolbox -> Conversion tools -> From raster -> Raster to ASCII"`.
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 level of the factor)
`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`

### 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.

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

Clément Calenge calenge@biomserv.univ-lyon1.fr

### References

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

### See Also

`image.asc`

### Examples

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

[Package adehabitat version 1.3 Index]