HOME Free ArcGIS tools HOME
Free functions of ET GeoWizards Free tools of ET GeoTools
Easy Calculate 10
how to perform field calculations without the field calculator in ArcGIS 10

Source code in .NET included
 

Easy Calculate 5.0

Download

What's New Calculate Edit Field Draw Examples

 EasyCalculate is a set of expressions (currently 110) for the ArcGIS field calculator. The expressions can be loaded in the Field Calculator and when executed calculate some spatial characteristics of the features, edit the shapes, add records to a target layer, draw graphics etc.

How to use:

  1. Unzip the file in a directory
  2. Right click on a field of a table ==> Calculate Values
  3. In the Field Calculator dialog: click the Load button and select the appropriate CAL file
    Some of the expressions require small changes in the code (adjustment of tolerances or field names). Places that require changes are clearly indicated in the code. The expressions that need 
    some adjustment are indicated with   in the Notes column of the table below
  4. Make the changes in the code ( if needed).
  5. Click OK to execute.

How to use the expressions programmatically:

See EasyCalculate Plus

New in EasyCalculate 5.0

1. 15 new expressions added - 29 July 2004
2. All expressions are compatible with ArcGIS 9.x. In order to accommodate ArcGIS 8.x & 9.x some of the expressions have versions. The version of the expressions are indicated in the name. If the name ends with "9x" it will run only in ArcGIS 9.0 and above. If the name ends with "8x" it will run only in ArcGIS 8.x. If the name does not have "9x" or "8x" suffix, the expression will run on ArcGIS 8.x & 9.x
3. Some typo errors fixed.
The new expressions  are indicated with   in the Applies To column of the table below

Description of EasyCalculate functions

Pl = Polyline Pg = Polygon Mp = Multipoint Pl_M = PolylineM Pl_Z = PolylineZ Tbl -  table
Applies To File name Description Field Type Notes

Calculate - populate a field with some spatial characteristics of the shapes.

Pl, Pl_Z polyline_GetAzimuth.cal Calculates the azimuth of a polyline in the user spacified point. Double See the example for polyline_GetAngle
Pl_Z polylineZ_GetSlope.cal Calculates the slope of a polylineZ in the user specified point Double See the example for polyline_GetAngle
Point point_Get_X_DMS.cal Calculates the X coordinates for points in Degrees Minutes Seconds String  
Point point_Get_Y_DMS.cal Calculates the Y coordinates for points in Degrees Minutes Seconds String  
Pl_Z+Pg_Z shape_Return3D_Length.cal Calculates the true 3D length of PolylineZ & PolygonZ shapes. Double  
Mp+Pl mp_get_X_Center.cal Uses a ConvexHull to calculate the X coordinate of the centroid of multipoints (can be used on polylines as well) Double  
Mp+Pl mp_get_Y_Center.cal Uses a ConvexHull to calculate the Y coordinate of the centroid of multipoints. Double  
PointM point_Get_M.cal calculates the M of points Double  
PointZ point_Get_Z.cal calculates the Z of points Double  
Pl_M polyline_Get_M_MiddlePoint.cal calculates the M of the Middle points of polylinesM Double See Example
Pl_Z polyline_Get_Z_MiddlePoint.cal calculates the Z of the Middle points of polylinesZ Double See Example
Pl polyline_Get_Azimuth.cal calculates the azimuth (0 = North, 90 = East 180 = South 270 = West) of polylines in their middle points Double See Example
Pl polyline_Get_Azimuth_9x.cal See above Double See Example
Pl, Pg, Mp shape_Get_X_Min.cal Calculates Min X for each shape (left of the bounding rectangle) Double  
Pl, Pg, Mp shape_Get_X_Max.cal Calculates Max X for each shape (right of the bounding rectangle) Double  
Pl, Pg, Mp shape_Get_Y_Min.cal Calculates Min Y for each shape (bottom of the bounding rectangle) Double  
Pl, Pg, Mp shape_Get_Y_Max.cal Calculates Max Y for each shape (top of the bounding rectangle) Double  
Pl, Pg, Mp shape_Get_BoundingRectangle_Area.cal Calculates the area of the bounding rectangle (extent) for each shape Double  
Pl, Pg shape_Return_Length.cal calculates the length of polylines or the perimeter of polygons Double  
All shape_Status.cal indicates the Null (-1), Empty(0) and Valid(1) shapes Integer  
All Z shape_Z_Status.cal indicates the Z status of the shapes Integer -2 ==> Null
-1 ==> Empty
0 ==> NaN Z value exists
1 ==> Valid Z values
All M shape_M_Status.cal indicates the M status of the shapes Integer -2 ==> Null
-1 ==> Empty
0 ==> NaN M value exists
1 ==> Valid M values
Pl, Pg, Mp shape_CountVertices.cal calculates the number of vertices for each shape Long  
Pl, Pg, Mp shape_CountAllParts.cal calculates the number of parts for each shape Long See Example
Point point_Get_X.cal calculates the X coordinate of points Double  
Point point_Get_Y.cal calculates the Y coordinate of points Double  
Polyline polyline_Get_X_FromPoint.cal calculates the X of the From (Start) points of polylines Double  
Polyline polyline_Get_Y_FromPoint.cal calculates the Y of the From (Start) points of polylines Double  
Polyline polyline_Get_X_ToPoint.cal calculates the X of the To (End) points of polylines Double  
Polyline polyline_Get_Y_ToPoint.cal calculates the Y of the To (End) points of polylines Double  
Polyline polyline_Get_X_MiddlePoint.cal calculates the X of the Middle points of polylines Double See Example
Polyline polyline_Get_Y_MiddlePoint.cal calculates the Y of the Middle points of polylines Double See Example
Polyline polyline_Get_Angle.cal calculates the angle of polylines in their middle points Double See Example
Polyline polyline_Get_Angle_9x.cal see above Double See Example
Polyline polyline_IsClosed.cal indicates Closed (1) and not closed (0) polylines Integer  
Polygon polygon_Get_X_Center.cal calculates the X of the centroids (center of gravity) of polygons Double  
Polygon polygon_Get_Y_Center.cal calculates the Y of the centroids (center of gravity) of polygons Double  
Polygon polygon_Get_X_Label.cal calculates the X of the label point (always inside) of polygons Double  
Polygon polygon_Get_Y_Label.cal calculates the Y of the label point (always inside) of polygons Double  
Polygon polygon_Return_Area.cal calculates the area of polygons, the spatial reference and the units for the calculation can be adjusted Double  
Polygon polygon_CountTrueParts.cal calculates the number of parts for each shape (holes not counted as parts) Long See Example
Polygon polygon_Thickness.cal calculates the thickness ratio of each polygon Double See Example
Pg,Pl polyline_GetBearing.cal calculates the bearings in ( N 45.00 E ) of polylines in an user specified point String See Example
Pg,Pl polyline_GetBearing_9x.cal see above String See Example
Pl_Z,Pg_Z shape_Get_Average_Z.cal Average Z for each shape Double  
Pl_Z,Pg_Z shape_Get_Z_Max.cal Max Z for each shape Double  
Pl_Z,Pg_Z shape_Get_Z_Min.cal Min Z for each shape Double  
Pl_Z,Pg_Z shape_Get_Z_Max_2.cal Max Z for each shape Double  
Pl_Z,Pg_Z shape_Get_Z_Min_2.cal Min Z for each shape Double  
Pl_M,Pg_M shape_Get_M_Max_2.cal Max M for each shape Double  
Pl_M,Pg_M shape_Get_M_Min_2.cal Min M for each shape Double  

Edit - Edit the shapes

Polyline polyline_Offset_Move.cal Offsets the polyline with the user specified offset distance. Positive values of the offset distance offset the polylines to the right, negative to the left. Shape  
Polyline polyline_Offset_Copy.cal Offsets the polyline with the user specified offset distance. Preserves the original polylines and adds the offset one to the same record. Shape Creates multi-part shape. See the Explode function of ET GeoWizards
Polyline polyline_Offset_TwoSide.cal Offsets the polyline with the user specified offset distance. The original polyline is replaced with the offsets to its both sides Shape Creates multi-part shape. See the Explode function of ET GeoWizards
Polyline shape_DensifyByAngle.cal Implements the "DensifyByAngle" method. Useful before converting true Arcs from GDB to shapefile. Shape Be careful with the tolerances. If too small the ArcMap might crush!
Pl, Pg shape_Densify.cal Converts the Shape into a Shape composed of Line segments with length dTol1 (or less) that are within dTol2 of the original shape Shape  
Pl, Pg shape_Generalize.cal Generalizes the Shape using the Douglas-Poiker algorithm. Shape  
Polyline polyline_To_Line.cal Converts polylines to lines defined by their From and To points Shape  
Polygon polygon_To_BoundingRectangle.cal Converts polygons to their bounding rectangles (envelopes) Shape  
Polygon Polygon_To_ConvexPolygon.cal Converts polygons to convex polygons defined by their vertices Shape  
Polygon Polygon_Buffer.cal Replaces polygons with their buffered equivalent. Shape  
Polygon Polygon_To_EqualAreaCircle.cal Converts polygons to circles with area equal to the original polygons and center in the Centroids of the polygons Shape  
Polyline polyline_Flip.cal reverses the direction of polylines Shape  
Point point_Disperse.cal Moves the points randomly within user specified tolerance Shape  
Point point_MoveTo.cal Moves the points to new locations. The new X & Y taken from two fields in the attribute table Shape  
Point point_MoveTo_9x.cal see above Shape  
Point create_Lines_FromPoints.cal Creates polylines in the target layer. Start points - the points of the input layer. User defined length and angle Integer Dummy field
Polygon polygon_Scale.cal Scales the polygons with user defined scale factor. Origin - in the centroid of the original polygon  Shape  
Polyline polyline_Set_M.cal Sets constant user defined M value for the polylines Shape  
Polyline polyline_Set_Z.cal Sets constant user defined Z value for the polylines Shape  
All M shape_Multiply_Ms.cal Multiplies all M values of a shape with user defined factor Shape  
All Z shape_Multiply_Zs.cal Multiplies all Z values of a shape with user defined factor Shape  
All M shape_Offset_M.cal Adds user defined M value to all vertices of the shape Shape  
All Z shape_Offset_Z.cal Adds user defined Z value to all vertices of the shape Shape  
Polyline polyline_rotate_byFieldValues.cal Rotates the polylines with an angle from a field. The rotation point for each polyline is on the polyline - defined by the user. (dafault - the middle point) Shape  
Polygon polygon_rotate_byFieldValues.cal Rotates the polylines with an angle from a field. The rotation point is the centroid of each polygon. Shape  
Polygon close_Polygons.cal Closes the non closed polygons. Shape  
Polyline close_Polylines.cal Closes the polylines by introducing a new segment Shape  
Pg,Pl clean_Shapes.cal Performs basic clean of the shapes Shape  
Polygon polygon_To_BoundingRectangle2.cal Converts polygons to their bounding rectangles. Shape  
Polygon polygon_FillHoles.cal Fills the holes in polygons Shape If island polygons are present, the result will contain overlaps
Pl,Pg point_along_polyline.cal Creates point/s in the target layer at the specified distance along the selected polylines Integer Dummy field.

Requires a target layer from the appropriate type. The index of the target layer in the TOC can be specified.

Point create_Rectangles_FromPoints.cal Creates rectangles in the target layer from the points. Rotation angle can be from a field or the same for all shapes. The source points - center of the rectangles Integer
Point create_Rectangles_FromPoints2.cal Creates rectangles in the target layer from the points. User specifies which corner of the rectangle will be in the source point. Integer

Field - calculate the values of a field based on another field

All+Tbl field_dd2dms_long.cal Converts X coord. values in Decimal Degrees from a numeric field to longitude strings in Degrees Minutes Seconds String  
All+Tbl field_dd2dms_lat.cal Converts Y coord. values in Decimal Degrees from a numeric field to longitude strings in Degrees Minutes Seconds String  
All+Tbl field_Mark_Duplicates_2.cal Calculates a unique number for each occurence of a value in a field. Long Example:
a==>1
b==>1
c==>1
b==>2
b==>3
a==>2
All+Tbl rec_Number_ConstantLengthString.cal Populates the field with consecutive numbers represented by a constatnt length string. Starting number, thestep size and the length of the string can be adjusted String Example:
000001
000002
...........
000011
...........
000345
All+Tbl rec_Number_ConstantLengthString2.cal
All+Tbl rec_Number_ConstantLengthString3.cal
All+Tbl field_DMS2DD.cal Converts the values of a Degree Minutes Secons string field to numbers in Decimal Degrees. Double See Example
All+Tb field_Mark_Duplicates.cal All records with values in the specified field that duplicate an already existing value will be marked with 1. The first instance of each duplicated record, and any records with no duplicates will get a value of 0. Integer  
All+Tbl field_Mark_Duplicates.cal1 All records with values in the specified field, that duplicates an already existing value will be marked with the ID of the record they duplicate. The records with no duplicates will get a value of -1 Long  
All+Tbl rec_Number.cal Populates the field with consecutive numbers. Starting number and a step size can be adjusted Long  
All+Tbl field_CumulateValues.cal Calculates the cumulative values of a records in a number field. Double Example:
5==>5
2==>7
10==>17
3==>20
All get_Subtype_Name.cal converts the subtypes in a feature class from a GDB to texts, so they can be exported to a shapefile String  
All+Tbl azimuth_To_Bearing.cal Convert Azimuth in DD to Bearings String

143.44 
=>
 S 36.56 E 

All+Tbl field_String_To_ConstantLengthString.cal Convert Strings To Constant length strings String Example:
A      ==>00000A
AB   ==>0000AB
ABC==>000ABC
All+Tbl field_String_To_ConstantLengthString2.cal String
All+Tbl field_BasicTrim.cal Removes leading and trailing occurrences of a character from a string String Example:
bbbtr eebbaa bb ==>
tr eebbaa
All+Tbl field_Date_Stamp.cal Adds current data in a user specified format to selected records String  
All+Tbl field_SplitString.cal   String Example:
abc#12 ==>abc
abcd#1 ==>abcd

Draw - Use the field calculator as a tool to draw graphics in the view

Pl,Pg,Pnt features_To_Graphics.cal Converts the features to graphic elements Any Dummy field
Polyline draw_Point_OnPolyline.cal Draws point on each polyline. User specified location of the point Any Dummy field
Pl,Pg,Pnt draw_Circle_inTheCentre.cal Draws a circle for each shape. The radius can be the same for each shape or taken from a numeric field Any Dummy field
Pl,Pg,Pnt draw_Buffer.cal Draws a graphic buffer for each shape Any Dummy field
Pl,Pg draw_Bounding_Rectangle.cal Draws the bounding rectangle for each shape Any Dummy field
Pl,Pg draw_Shape_Vertices.cal   Any Dummy field
Point draw_PointSquareBuffer.cal Draws Square/Rectangular buffers around the points. A rotation angle can be assigned for all the records or from a field. Any Dummy field
 

Notes:

  1. The result values for the functions that return coordinates, length and area will be in the projection of the View Frame
  2. For best results the fields should be from the types indicated in the table above
  3. The expressions with indicated Field Type of SHAPE should be used only on the SHAPE field.  Caution: The changes are applied directly on the original data set. If the expressions are applied out of an Editing session the changes will be irreversible. If you however want to use these or similar expression out of an Editing session, make sure to create a backup of the original data set.
  4. The calculation will be performed only on the selected records. If there is no selection - values for all the records will be calculated

Examples:

  • polyline_Get_X_MiddlePoint.cal, polyline_Get_X_MiddlePoint.cal and polylineGet_Angle.cal can be easily changed to return the characteristics for any other point of the polylines. Only the values of the dDistance and/or bAsRatio variables have to be changed in the Pre-Logic box of the Field Calculator.
  dDistance bAsRatio Description
Default 0.5 True Middle Point (angle at Middle Point)
Example 1 0.3 True Point (angle at Point) located on a distance 30% of the total length of the polyline from the start point along the polyline
Example 2 10 False Point (angle at Point) on the polyline 10 map units from the start point of the polyline along the polyline
  • shape_CountAllParts.cal and polygon_CountTrueParts.cal can be used together to find the polygons with holes or islands in a polygon data set. Use them on two different fields and then select all the records for which the results from the first expression are not equal to the results from the second one. The selected polygons will contain an island polygon or will have a hole.
  • polygon_Thickness.cal can be used to identify the skinny polygons in a polygon data set. For polygons with close to circular shape the results will be close to 1. The thinner the polygons are, the smaller the ratio will be. Using this expression one can identify the sliver polygons which are normally very thin.
  • field_DMS2DD.cal - A DMS string in virtually any format is accepted. Any character delimiter except "." (used as a decimal point) can be used. The letters "E", "W", "N" & "S" are used to determine the location of the Lat/Long coordinate. They can be used as delimiters, but the last occurrence of the letter in the DMS string will define the sign of the coordinate. The expression checks for validity of the DD coordinate - all the valid Longitudes should be between -180.00 and 180 degrees. If you want to check for Latitude validity you have to replace these values to -90.00 to 90 degrees. The records with string values that the expression could not standardize will be assigned a value of 0.00.
Input string Standardized string Decimal Degrees
37 45 23 S 37 45 23 S -37.7564
37º45'23"N 37 45 23 N 37.7564
123456 12 34 56 12.5822
1234567 123 45 67 123.769
W?37?45?23 37 45 23 W -37.7564
37-23.123-s 37 23.123 0 s -37.3854

For any comments and enquiries contact: webmaster@ian-ko.com
Esri and all Esri products mentioned are trademarks of Environmental Systems Research Institute, Inc.
Copyright: Ianko Tchoukanski