Home | Categories | Alphabetical | Classes | All Contents | [ < ] | [ > ]

IDLffShape::AddAttribute


Syntax | Arguments | Keywords | Examples | Version History

The IDLffShape::AddAttribute method adds an attribute definition to a Shapefile. Adding a the attribute definition is required before adding the actual attribute data to a file. For more information on attributes, see Attributes.

Note
You can only define new attributes to Shapefiles that do not have any existing values in any attributes.

Syntax

Obj->[IDLffShape::]AddAttribute, Name, Type, Width [, PRECISION=integer]

Arguments

Name

Set to a string that contains the attribute name. Name values are limited to 11 characters. Arguments longer than 11 characters will be truncated.

Type

Set to the IDL type code that corresponds to the data type that will be stored in the attribute. The valid types are:

Code
Description
3
Longword Integer
5
Double-precision floating-point
7
String

Width

Set to the width of the field for the data value of the attribute. The following table describes the possible values depending on the defined Type:

Field Type
Valid Values
Longword Integer
Maximum size of the field.
Double-precision floating-point
Maximum size of the field.
String
Maximum length of the string.

Keywords

PRECISION

Set this keyword to the number of positions to be included after the decimal point. The default is 8. This keyword is only valid for fields defined as double-precision floating-point.

Examples

In the following example, we add the attribute "ELEVATION" to an existing Shapefile. Note that if the file already contains data in an attribute for any of the entities defined in the file, this operation will fail.

PRO ex_addattr_shapefile 
 
;Open a shapefile 
myshape=OBJ_NEW('IDLffShape', FILEPATH('cities.shp', $ 
   SUBDIR=['examples', 'data']), /UPDATE) 
 
;Define a new attribute for the Shapefile 
myshape->IDLffShape::AddAttribute, 'ELEVATION', 3, 4, $ 
   PRECISION=0 
 
;Close the shapefile 
OBJ_DESTROY, myshape 
 
END 

Version History

Introduced: 5.4


Home | Categories | Alphabetical | Classes | All Contents | [ < ] | [ > ]