import.asc {adehabitat} | R Documentation |
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/).
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, ...)
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 |
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.
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. |
Clément Calenge calenge@biomserv.univ-lyon1.fr
Arcview: http://www.esri.com
Landserf: http://www.soi.city.ac.uk/~jwo/landserf/
## 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)