注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

面朝大海 春暖花开

一点心得,转载本博客文章,请注明转帖,谢谢!

 
 
 

日志

 
 
关于我

中国科学院博士 主要从事遥感机理、定量反演、数据处理以及GIS应用研究。ArcGIS、Envi 、ERDAS、Ecognition软件、IDL语言、6S、SAIL

网易考拉推荐

ArcGIS中字段计算器field calculator函数  

2013-08-05 17:47:24|  分类: arcgis |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |

http://onlinehelp.tableausoftware.com/v7.0/pro/online/en-us/functions.html

1.String Functions

ASCII(string)

Return the ASCII code for the first character of string. For example, ASCII('A') = 65

CHAR(number)

Returns the character encoded by the ASCII code number. For example, CHAR(65) = 'A'

Contains(string, substring)

Returns true if the given string contains the specified substring. CONTAINS(“Calculation”, “alcu”) = true

ENDSWITH(string, substring)

Returns true if the given string ends with the specified substring. Trailing white spaces are ignored. ENDSWITH(“Tableau”, “leau”) = true

FIND(string, substring, [start])

Returns the index position of substring in string, or 0 if the substring isn't found. If the optional argument start is added, the function does the same thing, but ignores any instances of substring that appear before the index position start. The first character in the string is position 1. For example, FIND("Calculation", "alcu") = 2 FIND("Calculation", "Computer") = 0FIND("Calculation", "a", 3) = 7FIND("Calculation", "a", 2) = 2FIND("Calculation", "a", 8) = 0

LEFT(string, number)

Returns the left-most number of characters in the string. For example, LEFT("Matador", 4) = "Mata"

LEN(string)

Returns the length of the string. For example, LEN("Matador") = 7

LOWER(string)

Returns the lower case version of the string. For example, LOWER("ProductVersion") = "productversion"

LTRIM(string)

Returns the string with any leading spaces removed. For example, LTRIM(" Matador ") = "Matador "

MAX(a, b)

Usually applied to numbers, but also works on strings. Returns the maximum of a and b (a and b must be of the same type). With strings, MAX finds the value that is highest in the sort sequence defined by the database for that column. It returns Null if either argument is Null. For example, MAX ("Apple","Banana") = "Banana"

MID(string, start, [length])

Returns the string starting at index position start. The first character in the string is position 1. If the optional argument length is added, the returned string includes only that number of characters. For example, MID("Calculation", 2) = "alculation"MID("Calculation", 2, 5) ="alcul"

MIN(a, b)

Usually applied to numbers, but also works on strings. Returns the minimum of a and b (a and b must be of the same type). With strings, MIN finds the value that is lowest in the sort sequence. It returns Null if either argument is Null. For example, MIN ("Apple","Banana") = "Apple"

REPLACE(string, substring, replacement)

Searches the provided string for the given substring and replaces it with the replacement. If the substring is not found, the string is unchanged. For example, REPLACE("Version8.5", "8.5", "9.0") = "Version9.0"

RIGHT(string, number)

Returns the right-most number of characters in string. For example, RIGHT("Calculation", 4) = "tion"

RTRIM(string)

Returns the string with any trailing spaces removed. For example, RTRIM(" Calculation ") = " Calculation"

SPACE(number)

Returns a string that is composed of the specified number of repeated spaces. For example, SPACE(1) = " "

STARTSWITH(string, substring)

Returns true if the given string stars with the specified substring. Leading white spaces are ignored. For example, STARTSWITH(“Joker”, “Jo”) = true

TRIM(string)

Returns the string with leading and trailing spaces removed. For example, TRIM(" Calculation ") = "Calculation"

UPPER(string)

Returns the lower case version of the string. For example, UPPER("Calculation") = "CALCULATION"

2.Number Functions

ABS(number)

Returns the absolute value of the given number. For example, ABS(-7) = 7ABS([Budget Variance]) returns the absolute value for all the numbers contained in the Budget Variance field.

ACOS(number)

Returns the arc cosine of the given number. The result is in radians. For example, ACOS(-1) = 3.14159265358979

ASIN(number)

Returns the arc sine of a given number. The result is in radians. For example, ASIN(1) = 1.5707963267949

ATAN(number)

Returns the arc tangent of a given number. The result is in radians. For example, ATAN(180) = 1.5652408283942

ATAN2(y number, x number)

Returns the arc tangent of two given numbers (x and y). The result is in radians. For example, ATAN2(2, 1) = 1.10714871779409

COS(number)

Returns the cosine of a given number specified in radians. The number is in radians. For example, COS(PI( ) /4) = 0.707106781186548

COT(number)

Returns the cotangent of a given number specified in radians. The number is in radians. For example, COT(PI( ) /4) = 1

DEGREES(number)

Converts a given number in radians to degrees. For example, DEGREES(PI( )/4) = 45.0

EXP(number)

Returns e raised to the power of the given number. For example, EXP(2) = 7.389EXP(-[Growth Rate]*[Time])

LN(number)

Returns the natural logarithm of a number. Returns Null if number is less than or equal to 0.

LOG(number [, base])

Returns the logarithm of a number for the given base. If the base value is omitted, base 10 is used.

MAX(number, number)

Returns the maximum of the two arguments, which must be of the same type. Returns Null if either argument is Null. MAX can also be applied to a single field in an aggregate calculation. For example, MAX(4,7)MAX(Sales,Profit)MAX([First Name],[Last Name])

MIN(number, number)

Returns the minimum of the two arguments, which must be of the same type. Returns Null if either argument is Null. MIN can also be applied to a single field in an aggregate calculation. For example, MIN(4,7)MIN(Sales,Profit)MIN([First Name],[Last Name])

PI( )

Returns the numeric constant pi: 3.14159.

POWER(number, power)

Raises the number to the specified power.

For example, POWER(5,2) = 52 = 25POWER(Temperature, 2)

You can also use the ^ symbol.

For example, 5^2 = POWER(5,2) = 25

Radians (number)

Converts the given number from degrees to radians. For example, RADIANS(180) = 3.14159

ROUND(number, [decimals])

Rounds numbers to a specified number of digits. The decimals argument specifies how many decimal points of precision to include in the final result, and it is not required. If the decimals variable is omitted, number is rounded to the nearest integer. For example, ROUND(7.3) = 7ROUND(-6.9) = -7ROUND(123.47,1) = 123.5ROUND(Sales) rounds every Sales value to an integer.

Note that some databases such as MS SQL Server, allow specification of a negative length, where -1 rounds number to 10's, -2 rounds to 100's, and so on. This is not true of all databases to which you can connect. For example, it is not true of Excel or Access.

SIGN(number)

Returns the sign of a number: The possible return values are -1 if the number is negative, 0 if the number is zero, or 1 if the number is positive. For example, if the average of the profit field is negative, then SIGN(AVG(Profit)) = -1

SIN(number)

Returns the sine of a number specified in radians. The result is in radians. For example, SIN(0) = 1.0SIN(PI( )/4) = 0.707106781186548

SQRT(number)

Returns the square root of a number. For example, SQRT(25) = 5

SQUARE(number)

Returns the square of a number. For example, SQUARE(5) = 25

TAN(number)

Returns the tangent of a number specified in radians. The result is in radians. For example, TAN(PI ( )/4) = 1.0

ZN(expression)

Returns the expression if it is not null, otherwise returns zero. Use this function to use zero values instead of null values. ZN([Profit]) = [Profit]

http://hub.qgis.org/wiki/17/List_of_Field_Calculator_Functions

number - number

NULL - null value

sqrt(a) - square root

sin(a) - sinus of a

cos(a) - cosinus of b

tan(a) - tangens of a

asin(a) - arcussinus of a

acos(a) - arcuscosinus of a

atan(a) - arcustangens of a

to int(a) - convert string a to integer

to real(a) - convert string a to real

to string(a) - convert number a to string

lower(a) - convert string a to lower case

upper(a) - convert string a to upper case

length(a) - length of string a

atan2(y,x) - arcustangens of y/x using the signs of the two arguments to determine the quadrant of the result.

replace(a,replacethis,withthat) - replace replacethis with withthat in string a

regexp_replace(a,replacethis,withthat) - replace the regular expression replacethis with withthat in string a

substr(a,from,len) - len characters of string a starting from from (first character index is 1)

a || b - concatenate strings a and b

$rownum - number current row

$area - area of polygon

$perimeter - perimeter of polygon

$length - length of line

$id - feature id

$x - x coordinate of point

$y - y coordinate of point

xat(n) - x coordinate of nth point of a line (indexes start at 0; negative values apply to the last index)

yat(n) - y coordinate of nth point of a line (indexes start at 0; negative values apply to the last index)

a ^ b - a raised to the power of b

a * b - a multiplied by b

a / b - a divided by b

a + b - a plus b

a - b - a minus b

+a - positive sign

-a - negative value of a

来个中文版的,呵呵

http://hi.baidu.com/stone2w/item/283533322452e9ba623affff

Field Calculator 工具可以在属性表字段点击右键,选择“Field Calculator ”,或者Data Management Tools->fields-> Calculate Field打开。

1.基本函数

针对数值型:

?? Abs:求绝对值?
?? Atn:求反正切值?
?? Cos:求余弦值?
?? Exp:求反对数值?
?? Fix:取整数部分,与 Int 函数有区别的?
?? Int:取整数部分?
???? Int? 和? Fix? 函数的区别在于如果? number? 参数为负数时,Int? 函数返回小于或等于? number? 的第一个负
整数,而? Fix? 函数返回大于或等于? number? 参数的第一个负整数。?
???? MyNumber = Int(99.8)???? '? 返回? 99。?
???? MyNumber = Fix(99.2)???? '? 返回? 99。?
???? MyNumber = Int(‐99.8)??? '? 返回 ‐100。?
???? MyNumber = Fix(‐99.8)??? '? 返回‐99。?
???? MyNumber = Int(‐99.2)??? '? 返回 ‐100。?
???? MyNumber = Fix(‐99.2)??? '? 返回 ‐99。

Log:求对数值
Sin:求正弦值
Sqr:开方?
Tan:求正切

针对字符串型:

? Asc:返回与字符串的第一个字母对应的 ANSI? 字符代码?
? Chr:将一个 ASCII 码转为相应的字符,与它对应的是 ASC()函数?
? Format:返回根据格式 String? 表达式中包含的指令设置格式的字符串,例如 Format(13.3,"0.00")=13.30?
? Instr:返回某字符串在另一字符串中第一次出现的位置?
? LCase:返回字符串的小写格式,例如 LCase("ARCGIS")="arcgis"?
? Left:返回字符串左边的内容,例如 Left("arcgis",2)="ar" ,把[A]字段的前2个字符赋给[B]
? Len:返回字符串的长度,例如 Len("arcgis")=6?
? LTrim:去掉字符串左边的空格,例如 LTrim("?? arcgis")="arcgis"?
? Mid:取出字符串中间的内容,例如 Mid("arcgis",2,1)="r" 在name字段前四个字符后面加一个空格,left([name],4) & " " &? mid([name],5)
? QBColor:返回一个 Integer? 值,该值表示对应于指定的颜色编号的 RGB? 颜色代码?
? Right:返回字符串右边的内容,例如 Right("arcgis",2)="is"?
? RTrim:去掉字符串右边的空格,例如 RTim("arcgis?? ")="arcgis"?
? Space:返回由指定数量空格组成的字符串,例如 MyString = "Hello" & Space(10) & "World" '? 在两个字符串
之间插入? 10? 个空格。?
StrConv:返回按照指定方式转换的字符串。?
String:将对象转换为字符串。

Trim:去掉字符串前后的空格,例如 Trim("?? arcgis?? ")="arcgis"?
UCase:返回字符串的大写格式,例如 UCase("arcgis")="ARCGIS"

针对日期类型:

Date:获取日期?
DateAdd:返回一个? Date? 值,其中包含已添加指定时间间隔的日期和时间值。?
DateDiff:两个日期之间存在的指定时间间隔的数目?
DatePart:用于计算日期并返回指定的时间间隔?
Now:获取日期+时间

2.简单VBA

把属性值1、2、3换成A、B、C

Dim sResult as string?
Dim sField as string?
sField = [字段名]?
If (sField="1") Then?
sResult ="A"?
ElseIf (sField="2") Then

sResult ="B"?
ElseIf (sField="3") Then
sResult ="C"?
End If

  评论这张
 
阅读(4884)| 评论(0)
推荐 转载

历史上的今天

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2017