找回密码
 注册
查看: 2434|回复: 0

R语言:as.raster()函数中文帮助文档(中英文对照)

[复制链接]
发表于 2012-2-16 17:25:12 | 显示全部楼层 |阅读模式
as.raster(grDevices)
as.raster()所属R语言包:grDevices

                                        Create a Raster Object
                                         创建一个栅格对象

                                         译者:生物统计家园网 机器人LoveR

描述----------Description----------

Functions to create a raster object (representing a bitmap image) and coerce other objects to a raster object.
栅格对象(即一个位图图像)和要挟其他对象的功能来创建一个栅格对象。


用法----------Usage----------


is.raster(x)
as.raster(x, ...)

## S3 method for class 'logical'
as.raster(x, max=1, ...)
## S3 method for class 'numeric'
as.raster(x, max=1, ...)
## S3 method for class 'character'
as.raster(x, max=1, ...)
## S3 method for class 'matrix'
as.raster(x, max=1, ...)
## S3 method for class 'array'
as.raster(x, max=1, ...)



参数----------Arguments----------

参数:x
Any R object.  
任何R对象。


参数:max
number giving the maximum of the color values range.
给予的颜色值范围内的最大数量。


参数:...
further arguments passed to or from other methods.
通过进一步的论据或其他方法。


Details

详情----------Details----------

An object of class "raster" is a matrix of colour values as given by rgb representing a bitmap image.
的"raster"类的对象是rgb代表一个位图图像的颜色值的矩阵。

It is not expected that the user will need to call these functions directly; functions to render bitmap images in graphics packages will make use of the as.raster() function to generate a raster object from their input.
据预计,用户将需要直接调用这些函数;位图图像呈现在图形软件包的功能将使as.raster()函数的使用,从他们的投入产生的栅格对象。

The as.raster() function is generic so methods can be written to convert other R objects to a raster object.
as.raster()函数是通用的方法,以便可以写入栅格对象转换成其他的R对象。

The default implementation for numeric matrices interprets scalar values on black-to-white scale.
数字矩阵的默认实现解释黑色到白色刻度的标值。

Raster objects can be subsetted like a matrix and it is possible to assign to a subset of a raster object.
Raster对象可以子集就像一个矩阵,它有可能分配到一个栅格对象的一个子集。

There is a method for converting a raster object to a matrix (of colour strings).
有一个矩阵(色彩字符串)转换为栅格对象的方法。

Raster objects can be compared for equality or inequality (with each other or with a colour string).
Raster对象,可以比较平等或不平等(与对方或用一种颜色的字符串)。

As from R 2.14.0 there is a is.na method which returns a logical matrix of the same dimensions as the raster object.  Note that NA values are interpreted as the fully transparent colour by some (but not all) graphics devices.
2.14.0从Ris.na方法返回一个栅格对象的尺寸相同的逻辑矩阵。请注意,NA值解释为完全透明的颜色,一些(但不是全部)图形设备。


值----------Value----------

For as.raster(), a raster object.
as.raster(),栅格对象。

For is.raster(), a logical indicating whether x is a raster object.
is.raster(),逻辑是否x是一个栅格对象。


举例----------Examples----------


# A red gradient[一个红色的渐变]
as.raster(matrix(hcl(0, 80, seq(50, 80, 10)),
                 nrow=4, ncol=5))

# Vectors are 1-column matrices ...[向量是1列矩阵...]
#   character vectors are color names ...[特征向量是颜色名称...]
as.raster(hcl(0, 80, seq(50, 80, 10)))
#   numeric vectors are greyscale ...[数字矢量灰度...]
as.raster(1:5, max=5)
#   locigal vectors are black and white ...[locigal向量是黑色和白色...]
as.raster(1:10 %% 2 == 0)

# ... unless nrow/ncol are supplied ...[... ,除非NROW / NCOL提供...]
as.raster(1:10 %% 2 == 0, nrow=1)

# Matrix can also be logical or numeric ...[矩阵也可以是逻辑或数字...]
as.raster(matrix(c(TRUE, FALSE), nrow=3, ncol=2))
as.raster(matrix(1:3/4, nrow=3, ncol=4))

# An array can be 3-plane numeric (R, G, B planes) ...[一个数组可以是3飞机数字(的R,G,B平面)...]
as.raster(array(c(0:1, rep(0.5, 4)), c(2, 1, 3)))

# ... or 4-plane numeric (R, G, B, A planes)[...或数字(的R,G,B,A的飞机4架飞机)]
as.raster(array(c(0:1, rep(0.5, 6)), c(2, 1, 4)))

# subsetting[子集]
r <- as.raster(matrix(colors()[1:100], ncol=10))
r[, 2]
r[2:4, 2:5]

# assigning to subset[分配到子集]
r[2:4, 2:5] <- "white"

# comparison[比较]
r == "white"



转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。


注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|小黑屋|生物统计家园 网站价格

GMT+8, 2025-2-2 20:01 , Processed in 0.018725 second(s), 15 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表