ArcGIS字段计算器帮助文档.doc_第1页
ArcGIS字段计算器帮助文档.doc_第2页
ArcGIS字段计算器帮助文档.doc_第3页
ArcGIS字段计算器帮助文档.doc_第4页
ArcGIS字段计算器帮助文档.doc_第5页
全文预览已结束

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

TextID =p+cstr( ID )Specifying a calculation expressionThis dialog lets you calculate the values of a field by specifying a calculation expression. If any records are currently selected in the table, a check box in the dialog lets you choose between applying the calculation only to the selected records (the default) or to all the records. You can type the expression directly into the box or add fields, functions and operators into the box by clicking on them in the dialog.In field calculation expressions:- fields are enclosed in square brackets . These brackets are not shown in the Fields listing in the Field Calculator dialog, but when you double-click a field to add it into the expression, they will be added around the field name automatically in the expression.- text strings are enclosed in double quotes: text.How to use Visual Basic functions in a calculation expressionYou can include any Visual Basic Number, String or Date functions in the calculation expression you define. Commonly used functions are listed in the dialog for the current choice of data Type.For example, the following calculation expression uses the INT ( ) function on a number field to return the integer portion of the number in a number field called DIST_MILES:INT (DIST_MILES)And the following calculation expression uses the LEFT ( ) function on a string field to return the left-most three characters of the string in a text field called CODE:LEFT (CODE,3)The text concatenation operator, &, can be used with text fields and string functions. For example, the following expression takes the string in a text field called Name and concatenates it with the left-most three characters of the string in a text field called CODE:NAME & Left (CODE,3)To find the usage of the Visual Basic functions listed in this dialog, refer to the Visual Basic help in the Visual Basic editor included with ArcGIS. To access this help, go to the Tools pulldown menu and choose the Visual Basic Editor command from the Macros pullright. In the Visual Basic Editor, go the Help menu and choose Microsoft Visual Basic Help. In the Help, click the Index tab and select the function you want to find out about.For additional information, search for the topic called Making field calculations in the Desktop Help by entering that name in the Desktop Help Search tab.For a list of common conversion constants, search for the topic called About setting distance units by entering that name in the Desktop Help Search tab and then look for the link that topic that launches a table of conversion constants.How to use Visual Basic code in a calculation expressionCheck the Advanced box to enter Visual Basic For Applications (VBA) code that will be processed before the calculation expression executes. This can be used in various ways to prepare or pre-process the data ready for the calculation.Calculating fields to be geometric measurements such as the area or length of featuresThe attribute tables for geodatabase feature classes have area (Shape_Area), length (Shape_Length) and perimeter (Shape_Length) fields that are maintained automatically by ArcGIS. You dont need to create or update these fields manually. However you may want to add additional fields into the attribute table for a feature class showing these measurements in different units. Or you may be working with a non-geodatabase data source such as a shapefile, SDC feature class or CAD feature class that does not contain measurements like area, length and perimeter as fields in its attribute table. To calculate a field to be the area, perimeter, length, x y location, or xy centroid location of the feature that the record represents, use the Calculate Geometry dialog instead of the Field Calculator dialog to perform the calculation. The Calculate Geometry dialog, which is new in ArcGIS 9.2, makes it easy to calculate fields to be geometric measurements in the units of your choice. After calculating a fields values using the Calculate Geometry dialog, you may then use that field in the Field Calculator dialog to calculate values for a different field, such as using an area field to calculate density value or a price per square acre, etc.To launch the Calculate Geometry dialog, right-click the field you want to calculate in the table window and choose the Calculate Geometry command. Fields that you calculate using the Calculate Geometry dialog dont automatically get updated if the features are edited. So for example, if you calculate a field in a polygon shapefiles attribute table to be the area of the polygons, and you then edit the polygons or add new polygons, the area field that you added will be out of date. You can use the Calculate Geometry dialog to update the field by recalculating it. Remember that you dont have to do this in the case of the Shape_Area and Shape_Length fields in the attribute tables of feature classes stored in a geodatabase, because those Shape fields are maintained and updated automatically.How to use Visual Basic code to calculate fields based on area, length, perimeter, etc.You can use Visual Basic code in the Advanced box in the Field Calculator dialog to calculate fields using geometric measurements. Although the easiest way to perform these calculations is to use the Calculate Geometry dialog described above, there may be situations where you want to use Visual Basic code to perform these calculations in the Field Calculator instead. These examples show how to do this.1. These code examples return a value of type double, so use them to calculate either an existing field of type double or a new field of type double youve added to the table.2. Check Advanced. Youll see two empty text entry boxes.3. Enter one of these four line code examples into the topmost box, the one labeled Pre-Logic VBA Script Code. Tip: you can select the code in this help topic, right-click and choose Copy, and then paste it into the box.To calculate area:Dim Output as doubleDim pArea as IareaSet pArea = shapeOutput = pArea.areaTo calculate length or perimeter(depending on whether the features are lines or polygons):Dim Output as doubleDim pCurve as ICurveSet pCurve = shapeOutput = pCurve.LengthTo add the x coordinate of points:Dim Output As DoubleDim pPoint As IPointSet pPoint = ShapeOutput = pPoint.XTo add the x coordinate of polygon centroids:Dim Output As DoubleDim pArea As IAreaSet pArea = ShapeOutput = pArea.Centroid.X4. Type the variable Output into the second text box. Do not enclose it in quotes or brackets.5. Click OKThe units of the calculated values will be the units that your features are stored in, not the map units or display units of the data frame you are currently working with. So if your data is stored in feet, the calculated values will be in feet. If you want the calculated data to be in different units than the datas units, you could either add a conversion into the calculation expression, or (more simply) project your data into a coordinate system that uses the units you want the values to be in, and then perform the calculation.Why is the Field Calculator command sometimes disabled when I right-click a field in ArcMaps Table Window?If the Field Calculator command is disabled, it may be because:- The field you have selected is managed automatically by ArcGIS and therefore cannot be edited manually, such as:- the ObjectID (FID) field- the Shape_Length and Shape_Area fields for a feature class in a geodatabase- the Area, Perimeter and # fields for a point or polygon feature class in a coverage- the FNODE#, TNODE#, LPOLY#, RPOLY#, Length, and # fields for an arc feature class in a coverage- You are not in an edit session and you need to be editing to calculate the data. For example

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论