Ejemplo n.º 1
0
        /// <summary>
        ///     Calculates summary statistics for field(s) in a table.
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="outputTableName">Name of the output table.</param>
        /// <param name="workspace">The workspace.</param>
        /// <param name="statisticField">The numeric field containing attribute values used to calculate the specified statistic.</param>
        /// <param name="statisticType">Type of the statistic (SUM, MEAN, MIN, MAX, RANGE, STD, FIRST, LAST, COUNT).</param>
        /// <param name="caseFields">
        ///     The fields in the Input Table used to calculate statistics separately for each unique
        ///     attribute value (or combination of attributes values when multiple fields are specified).
        /// </param>
        /// <param name="trackCancel">The track cancel.</param>
        /// <param name="eventHandler">The events.</param>
        /// <returns>
        ///     Return <see cref="ITable" /> representing the table of statistic data.
        /// </returns>
        public static ITable Statistics(this IFeatureClass source, string outputTableName, IWorkspace workspace, string statisticField, StatisticType statisticType, string[] caseFields, ITrackCancel trackCancel, IGeoProcessorEvents eventHandler)
        {
            var list = new List <KeyValuePair <string, StatisticType> >();

            list.Add(new KeyValuePair <string, StatisticType>(statisticField, statisticType));

            return(source.Statistics(outputTableName, workspace, list, caseFields, trackCancel, eventHandler));
        }
 /// <summary>
 ///     Locate lines features along the route and writes the result to a new line event table.
 /// </summary>
 /// <param name="source">The lines to locate.</param>
 /// <param name="locateLinesAlongRouteName">The name of the event table of the located features.</param>
 /// <param name="workspace">The workspace.</param>
 /// <param name="sourceWhereClause">The source where clause.</param>
 /// <param name="route">The route to locate.</param>
 /// <param name="routeWhereClause">The route where clause.</param>
 /// <param name="routeIDFieldName">
 ///     The field containing values that uniquely identify each route. This field can be numeric
 ///     or character.
 /// </param>
 /// <param name="clusterTolerance">
 ///     A numeric value representing the maximum tolerated distance between the input lines and
 ///     the target routes.
 /// </param>
 /// <param name="toleranceUnits">The units.</param>
 /// <param name="keepAllFields">
 ///     Allows you to include or disinclude the attributes of the point feature class.  If this is
 ///     set to False, the output event table will only contain the route event properties.
 /// </param>
 /// <param name="trackCancel">The track cancel.</param>
 /// <param name="eventHandler">The event handler.</param>
 /// <returns>
 ///     Returns a <see cref="ITable" /> representing the event table of the results.
 /// </returns>
 public static ITable LocateAlongRoute(this IFeatureClass source, string locateLinesAlongRouteName, IWorkspace workspace, string sourceWhereClause, IFeatureClass route, string routeWhereClause, string routeIDFieldName, double clusterTolerance, esriUnits toleranceUnits, bool keepAllFields, ITrackCancel trackCancel, IGeoProcessorEvents eventHandler)
 {
     return(LocateAlongRouteImpl(source, locateLinesAlongRouteName, workspace, sourceWhereClause, route, routeWhereClause, routeIDFieldName, clusterTolerance, toleranceUnits, false, keepAllFields, trackCancel, eventHandler));
 }
Ejemplo n.º 3
0
        /// <summary>
        ///     Compares two tables or table views and returns the comparison results. This tool can report differences and
        ///     similarities with tabular values and field definitions
        /// </summary>
        /// <param name="source">
        ///     The Input Base Table is compared with the Input Test Table. The Input Base Table refers to tabular
        ///     data that you have declared valid. This base data has the correct field definitions and attribute values.
        /// </param>
        /// <param name="tableName">
        ///     The Input Test Table is compared against the Input Base Table. The Input Test Table refers to data
        ///     that you have made changes to by editing or compiling new fields, new records, or new attribute values.
        /// </param>
        /// <param name="outputFile">
        ///     This file will contain all similarities and differences between the Input Base Features and
        ///     the Input Test Features. This file is a comma-delimited text file that can be viewed and used as a table in ArcGIS.
        /// </param>
        /// <param name="sortFields">
        ///     The field or fields used to sort records in the Input Base Table and the Input Test Table. The
        ///     records are sorted in ascending order.
        /// </param>
        /// <param name="omitFields">
        ///     The field or fields that will be omitted during comparison. The field definitions and the
        ///     tabular values for these fields will be ignored.
        /// </param>
        /// <param name="continueCompare">Indicates whether to compare all properties after encountering the first mismatch.</param>
        /// <param name="trackCancel">The track cancel.</param>
        /// <param name="eventHandler">The event handler.</param>
        public static void Compare(this ITable source, string tableName, string outputFile, string[] sortFields, string[] omitFields, bool continueCompare, ITrackCancel trackCancel, IGeoProcessorEvents eventHandler)
        {
            var test = ((IDataset)source).Workspace.GetTable(tableName);

            CompareImpl(source, test, outputFile, sortFields, omitFields, "ATTRIBUTES_ONLY", "", continueCompare, trackCancel, eventHandler);
        }
 /// <summary>
 ///     Creates a feature class containing points at the midpoint, not necessarily a vertex, of each input line or polygon
 ///     boundary.
 /// </summary>
 /// <param name="source">The source.</param>
 /// <param name="outputTableName">Name of the output table.</param>
 /// <param name="workspace">The workspace.</param>
 /// <param name="trackCancel">The track cancel.</param>
 /// <param name="eventHandler">The events.</param>
 /// <remarks>License ArcGIS Desktop Advanced: Yes</remarks>
 /// <returns>
 ///     Returns a <see cref="IFeatureClass" /> representing the feature class.
 /// </returns>
 public static IFeatureClass CreateMidVertexPoints(this IFeatureClass source, string outputTableName, IWorkspace workspace, ITrackCancel trackCancel, IGeoProcessorEvents eventHandler)
 {
     return(CreateVertexPointsImpl(source, outputTableName, workspace, trackCancel, eventHandler, "MID"));
 }
 /// <summary>
 ///     Locate point features along the route and writes the result to a new point event table.
 /// </summary>
 /// <param name="source">The points to locate.</param>
 /// <param name="locatePointsAlongRouteName">The name of the event table of the located features.</param>
 /// <param name="workspace">The workspace.</param>
 /// <param name="sourceWhereClause">An optional filter used to use a subset of the points data.</param>
 /// <param name="route">The route to locate.</param>
 /// <param name="routeWhereClause">An optional filter used to use a subset of the route data.</param>
 /// <param name="routeIDFieldName">
 ///     The field containing values that uniquely identify each route. This field can be numeric
 ///     or character.
 /// </param>
 /// <param name="searchRadius">
 ///     If the input features are points, the search radius is a numeric value defining how far around each point a search
 ///     will be done to find a target route. If the input features are lines, the search tolerance is really a cluster
 ///     tolerance, which is a numeric value
 ///     representing the maximum tolerated distance between the input lines and the target routes. If the input features
 ///     are polygons, this parameter is ignored since no search radius is used.
 /// </param>
 /// <param name="units">The units.</param>
 /// <param name="searchMultipleLocations">
 ///     If the point falls on more than one route for the given search radius, you can
 ///     have the option to create multiple event records that correspond to each route in the search radius vicinity
 /// </param>
 /// <param name="keepAllFields">
 ///     Allows you to include or disinclude the attributes of the point feature class.  If this is
 ///     set to False, the output event table will only contain the route event properties.
 /// </param>
 /// <param name="trackCancel">The track cancel.</param>
 /// <param name="eventHandler">The event handler.</param>
 /// <returns>
 ///     Returns a <see cref="ITable" /> representing the event table of the results.
 /// </returns>
 public static ITable LocateAlongRoute(this IFeatureClass source, string locatePointsAlongRouteName, IWorkspace workspace, string sourceWhereClause, IFeatureClass route, string routeWhereClause, string routeIDFieldName, double searchRadius, esriUnits units, bool searchMultipleLocations, bool keepAllFields, ITrackCancel trackCancel, IGeoProcessorEvents eventHandler)
 {
     return(LocateAlongRouteImpl(source, locatePointsAlongRouteName, workspace, sourceWhereClause, route, routeWhereClause, routeIDFieldName, searchRadius, units, searchMultipleLocations, keepAllFields, trackCancel, eventHandler));
 }
Ejemplo n.º 6
0
        /// <summary>
        ///     Creates a table view from an input table or feature class. The table view that is created by the tool is temporary
        ///     and will not persist after the session ends unless the document is saved
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="tableName">The name of the table view to be created.</param>
        /// <param name="filter">An SQL expression used to select a subset of features. </param>
        /// <param name="visibleFields">
        ///     Specifies which fields from the input table to rename and make visible in the output table
        ///     view.
        /// </param>
        /// <param name="trackCancel">The track cancel.</param>
        /// <param name="eventHandler">The event handler.</param>
        /// <returns>Returns a <see cref="string" /> representing the path to the view.</returns>
        internal static string MakeView(this ITable source, string tableName, IQueryFilter filter, Dictionary <string, string> visibleFields, ITrackCancel trackCancel, IGeoProcessorEvents eventHandler)
        {
            var ds    = (IDataset)source;
            var input = ds.Workspace.GetAbsolutePath(tableName);

            MakeTableView gp = new MakeTableView();

            gp.in_table     = source;
            gp.where_clause = filter == null ? null : filter.WhereClause;
            gp.out_view     = input;

            if (visibleFields != null && visibleFields.Any())
            {
                IGpFieldInfoObject fieldInfo = new GpFieldInfoObjectClass();
                foreach (var field in visibleFields)
                {
                    fieldInfo.AddField(field.Key, field.Value, "true", "");
                }

                gp.field_info = fieldInfo;
            }

            if (gp.Run(trackCancel, eventHandler) == esriJobStatus.esriJobSucceeded)
            {
                return(input);
            }

            return(null);
        }
Ejemplo n.º 7
0
        /// <summary>
        ///     Adds an attribute index to an existing table, feature class, shapefile, coverage, or attributed relationship class.
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="name">
        ///     The name of the new index. An index name is necessary when adding an index to geodatabase feature
        ///     classes and tables. For other data types, such as shapefiles and coverage feature classes, index names cannot be
        ///     specified.
        /// </param>
        /// <param name="fields">
        ///     The list of fields that can participate in an attribute index. Any number of these fields can be
        ///     part of the index.
        /// </param>
        /// <param name="unique">if set to <c>true</c> when the values in the index are unique.</param>
        /// <param name="ascending">if set to <c>true</c> when the values are indexed in ascending order.</param>
        /// <param name="trackCancel">The track cancel.</param>
        /// <param name="eventHandler">The events.</param>
        public static void AddIndex(this ITable source, string name, string[] fields, bool unique, bool ascending, ITrackCancel trackCancel, IGeoProcessorEvents eventHandler)
        {
            AddIndex gp = new AddIndex();

            gp.in_table   = source;
            gp.index_name = name;
            gp.fields     = string.Join(";", fields);
            gp.unique     = unique ? "UNIQUE" : "NON_UNIQUE";
            gp.ascending  = ascending ? "ASCENDING" : "NON_ASCENDING";
            gp.Run(trackCancel, eventHandler);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Copies the rows from the source into the the target table.
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="target">The target.</param>
        /// <param name="filter">The filter.</param>
        /// <param name="visibleFields">Specifies which fields from the input table to rename and make visible in the output table
        /// view.</param>
        /// <param name="trackCancel">The track cancel.</param>
        /// <param name="eventHandler">The event handler.</param>
        public static void CopyTo(this ITable source, ITable target, IQueryFilter filter, Dictionary <string, string> visibleFields, ITrackCancel trackCancel, IGeoProcessorEvents eventHandler)
        {
            object input = source;

            if (filter != null && !string.IsNullOrEmpty(filter.WhereClause))
            {
                var name = string.Format("{0}_V", ((IDataset)source).Name);
                input = source.MakeView(name, filter, visibleFields, trackCancel, eventHandler);
            }

            CopyRows gp = new CopyRows();

            gp.in_rows   = input;
            gp.out_table = target;

            gp.Run(trackCancel, eventHandler);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Copies the rows from the source into the the target table.
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="filter">The filter.</param>
        /// <param name="trackCancel">The track cancel.</param>
        /// <param name="eventHandler">The event handler.</param>
        public static void Truncate(this ITable source, IQueryFilter filter, ITrackCancel trackCancel, IGeoProcessorEvents eventHandler)
        {
            object input = source;

            if (filter != null && !string.IsNullOrEmpty(filter.WhereClause))
            {
                var name = string.Format("{0}_V", ((IDataset)source).Name);
                input = source.MakeView(name, filter, null, trackCancel, eventHandler);
            }

            DeleteRows gp = new DeleteRows();

            gp.in_rows = input;

            gp.Run(trackCancel, eventHandler);
        }
Ejemplo n.º 10
0
 /// <summary>
 ///     Calculates the values of a field for a feature class.
 /// </summary>
 /// <param name="source">The source.</param>
 /// <param name="fieldName">The field that will be updated with the new calculation.</param>
 /// <param name="expression">The simple calculation expression used to create a value that will populate the selected rows.</param>
 /// <param name="python">A block of Python code for complex expresssions.</param>
 /// <param name="trackCancel">The track cancel.</param>
 /// <param name="eventHandler">The events.</param>
 public static void Calculate(this IFeatureClass source, string fieldName, string expression, string python, ITrackCancel trackCancel, IGeoProcessorEvents eventHandler)
 {
     ((ITable)source).Calculate(fieldName, expression, python, trackCancel, eventHandler);
 }
Ejemplo n.º 11
0
        /// <summary>
        ///     Calculates the values of a field for a feature class.
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="fieldName">The field that will be updated with the new calculation.</param>
        /// <param name="expression">The simple calculation expression used to create a value that will populate the selected rows.</param>
        /// <param name="python">A block of Python code for complex expresssions.</param>
        /// <param name="trackCancel">The track cancel.</param>
        /// <param name="eventHandler">The events.</param>
        public static void Calculate(this ITable source, string fieldName, string expression, string python, ITrackCancel trackCancel, IGeoProcessorEvents eventHandler)
        {
            CalculateField gp = new CalculateField();

            gp.in_table        = source;
            gp.field           = fieldName;
            gp.expression      = expression;
            gp.code_block      = python;
            gp.expression_type = "PYTHON_9.3";
            gp.Run(trackCancel, eventHandler);
        }
Ejemplo n.º 12
0
        /// <summary>
        ///     Adds the fields POINT_X and POINT_Y to the point input features and calculates their values. It also appends the
        ///     POINT_Z and POINT_M fields if the input features are Z- and M-enabled.
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="trackCancel">The track cancel.</param>
        /// <param name="eventHandler">The events.</param>
        public static void AddXY(this IFeatureClass source, ITrackCancel trackCancel, IGeoProcessorEvents eventHandler)
        {
            AddXY gp = new AddXY();

            gp.in_features = source;
            gp.Run(trackCancel, eventHandler);
        }
Ejemplo n.º 13
0
        /// <summary>
        ///     Joins attributes from one feature to another based on the spatial relationship. The target features and the joined
        ///     attributes from the join features are written to the output feature class.
        /// </summary>
        /// <param name="source">
        ///     The source features and the attributes from the joined features are transferred to the output
        ///     feature class. However, a subset of attributes can be defined in the field map parameter.
        /// </param>
        /// <param name="join">The attributes from the join features are joined to the attributes of the source features.</param>
        /// <param name="tableName">A new feature class containing the attributes of the target and join features.</param>
        /// <param name="operation">
        ///     Determines how joins between the target features and join features will be handled in the
        ///     output feature class if multiple join features are found that have the same spatial relationship with a single
        ///     target feature.
        /// </param>
        /// <param name="isOuterJoin">
        ///     if set to <c>true</c> if all target features will be maintained in the output feature class
        ///     (known as outer join), or only those that have the specified spatial relationship with the join features (inner
        ///     join).
        /// </param>
        /// <param name="option">Defines the criteria used to match rows.</param>
        /// <param name="caseFields">The attribute fields will be in the output feature class.</param>
        /// <param name="searchRadius">
        ///     Join features within this distance of a target feature will be considered for the spatial
        ///     join.
        /// </param>
        /// <param name="trackCancel">The track cancel.</param>
        /// <param name="eventHandler">The event handler.</param>
        /// <returns>Returns a <see cref="IFeatureClass" /> representing the feature class of the joined data.</returns>
        public static IFeatureClass Join(this IFeatureClass source, IFeatureClass join, string tableName, JoinOperation operation, bool isOuterJoin, SpatialOperation option, string[] caseFields, double searchRadius, ITrackCancel trackCancel, IGeoProcessorEvents eventHandler)
        {
            IGpFieldMappingsObject fieldMappings = new GpFieldMappingsObjectClass();

            fieldMappings.AddTable(source.GetAbsolutePath());
            fieldMappings.AddTable(join.GetAbsolutePath());

            int[] caseIndexes = caseFields.Select(fieldMappings.FindFieldMapIndex).ToArray();

            for (int i = fieldMappings.FieldCount - 1; i >= 0; i--)
            {
                if (caseIndexes.Contains(i))
                {
                    continue;
                }

                fieldMappings.RemoveFieldMap(i);
            }

            return(source.Join(join, tableName, operation, isOuterJoin, option, fieldMappings, searchRadius, trackCancel, eventHandler));
        }
Ejemplo n.º 14
0
        /// <summary>
        ///     Reads a table and a set of fields and creates a new table containing unique field values and the number of
        ///     occurrences of each unique field value
        /// </summary>
        /// <param name="source">
        ///     The table containing the field(s) that will be used to calculate frequency statistics. This table
        ///     can be an INFO or OLE DB table, a dBASE or a VPF table, or a feature class table.
        /// </param>
        /// <param name="outputTableName">Name of the output table.</param>
        /// <param name="workspace">The workspace.</param>
        /// <param name="frequencyFields">The attribute field or fields that will be used to calculate frequency statistics.</param>
        /// <param name="summaryFields">
        ///     The attribute field or fields to sum and add to the output table. Null values are excluded from this calculation.
        /// </param>
        /// <param name="trackCancel">The track cancel.</param>
        /// <param name="eventHandler">The events.</param>
        /// <returns>
        ///     Return <see cref="ITable" /> representing the table that stores the calculated frequency statistics.
        /// </returns>
        public static ITable Frequency(this IFeatureClass source, string outputTableName, IWorkspace workspace, string[] frequencyFields, string[] summaryFields, ITrackCancel trackCancel, IGeoProcessorEvents eventHandler)
        {
            Frequency gp = new Frequency();

            gp.in_table         = source;
            gp.out_table        = workspace.GetAbsolutePath(outputTableName);
            gp.summary_fields   = (summaryFields != null) ? string.Join(";", summaryFields) : null;
            gp.frequency_fields = string.Join(";", frequencyFields);

            if (gp.Run(trackCancel, eventHandler) == esriJobStatus.esriJobSucceeded)
            {
                return(workspace.GetTable(outputTableName));
            }

            return(null);
        }
Ejemplo n.º 15
0
 /// <summary>
 ///     Creates a table view from an input table or feature class. The table view that is created by the tool is temporary
 ///     and will not persist after the session ends unless the document is saved
 /// </summary>
 /// <param name="source">The source.</param>
 /// <param name="tableName">The name of the table view to be created.</param>
 /// <param name="filter">An SQL expression used to select a subset of features.</param>
 /// <param name="visibleFields">
 ///     Specifies which fields from the input table to rename and make visible in the output table
 ///     view.
 /// </param>
 /// <param name="trackCancel">The track cancel.</param>
 /// <param name="eventHandler">The event handler.</param>
 /// <returns>
 ///     Returns a <see cref="string" /> representing the path to the view.
 /// </returns>
 internal static string MakeView(this IFeatureClass source, string tableName, string filter, Dictionary <string, string> visibleFields, ITrackCancel trackCancel, IGeoProcessorEvents eventHandler)
 {
     return(source.MakeView(tableName, new QueryFilterClass {
         WhereClause = filter
     }, visibleFields, trackCancel, eventHandler));
 }
Ejemplo n.º 16
0
        /// <summary>
        ///     Copies the features from the source into the the target feature class.
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="targetTableName">Name of the target table.</param>
        /// <param name="filter">The filter.</param>
        /// <param name="visibleFields">
        ///     Specifies which fields from the input table to rename and make visible in the output table
        ///     view.
        /// </param>
        /// <param name="schemaMatchRequired">
        ///     if set to <c>true</c> if the schema must match between the two feature classes to
        ///     append the data.
        /// </param>
        /// <param name="workspace">The workspace.</param>
        /// <param name="trackCancel">The track cancel.</param>
        /// <param name="eventHandler">The event handler.</param>
        public static void CopyTo(this IFeatureClass source, string targetTableName, IQueryFilter filter, Dictionary <string, string> visibleFields, bool schemaMatchRequired, IWorkspace workspace, ITrackCancel trackCancel, IGeoProcessorEvents eventHandler)
        {
            object input = source;

            if (filter != null && !string.IsNullOrEmpty(filter.WhereClause))
            {
                var name = string.Format("{0}_V", ((IDataset)source).Name);
                input = source.MakeView(name, filter, visibleFields, trackCancel, eventHandler);
            }

            Append gp = new Append();

            gp.inputs      = input;
            gp.target      = workspace.GetAbsolutePath(targetTableName);
            gp.schema_type = schemaMatchRequired ? "TEST" : "NO_TEST";

            gp.Run(trackCancel, eventHandler);
        }
Ejemplo n.º 17
0
 /// <summary>
 ///     Adds the field to the feature class.
 /// </summary>
 /// <param name="source">The source.</param>
 /// <param name="name">The name.</param>
 /// <param name="type">The type.</param>
 /// <param name="length">The length.</param>
 /// <param name="trackCancel">The track cancel.</param>
 /// <param name="eventHandler">The events.</param>
 public static void AddField(this IFeatureClass source, string name, Type type, int length, ITrackCancel trackCancel, IGeoProcessorEvents eventHandler)
 {
     ((ITable)source).AddField(name, type, length, trackCancel, eventHandler);
 }
Ejemplo n.º 18
0
        /// <summary>
        ///     Adds the field to the table.
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="name">The name.</param>
        /// <param name="type">The type.</param>
        /// <param name="length">The length.</param>
        /// <param name="trackCancel">The track cancel.</param>
        /// <param name="eventHandler">The events.</param>
        public static void AddField(this ITable source, string name, Type type, int length, ITrackCancel trackCancel, IGeoProcessorEvents eventHandler)
        {
            AddField gp = new AddField();

            gp.in_table     = source;
            gp.field_name   = name;
            gp.field_type   = type == typeof(string) ? "TEXT" : type.Name.ToUpperInvariant();
            gp.field_length = length;

            gp.Run(trackCancel, eventHandler);
        }
Ejemplo n.º 19
0
 /// <summary>
 ///     Adds an attribute index to an existing table, feature class, shapefile, coverage, or attributed relationship class.
 /// </summary>
 /// <param name="source">The source.</param>
 /// <param name="name">
 ///     The name of the new index. An index name is necessary when adding an index to geodatabase feature
 ///     classes and tables. For other data types, such as shapefiles and coverage feature classes, index names cannot be
 ///     specified.
 /// </param>
 /// <param name="fields">
 ///     The list of fields that can participate in an attribute index. Any number of these fields can be
 ///     part of the index.
 /// </param>
 /// <param name="unique">if set to <c>true</c> when the values in the index are unique.</param>
 /// <param name="ascending">if set to <c>true</c> when the values are indexed in ascending order.</param>
 /// <param name="trackCancel">The track cancel.</param>
 /// <param name="eventHandler">The events.</param>
 public static void AddIndex(this IFeatureClass source, string name, string[] fields, bool unique, bool ascending, ITrackCancel trackCancel, IGeoProcessorEvents eventHandler)
 {
     ((ITable)source).AddIndex(name, fields, unique, ascending, trackCancel, eventHandler);
 }
Ejemplo n.º 20
0
        /// <summary>
        ///     Deletes records in a feature class or table which have identical values in a list of fields. If the field Shape is
        ///     selected, feature geometries are compared.s
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="fields">The field or fields whose values will be compared to find identical records.</param>
        /// <param name="trackCancel">The track cancel.</param>
        /// <param name="eventHandler">The event handler.</param>
        /// <remarks>
        ///     This tool finds identical records based on input field values, then deletes all but one of the identical
        ///     records from each set of identical records. The values from multiple fields in the input dataset can be compared.
        ///     If more than one field is specified, records are matched by the values in the first field, then by the values of
        ///     the second field, and so on.
        /// </remarks>
        public static void DeleteIdentical(this ITable source, string[] fields, ITrackCancel trackCancel, IGeoProcessorEvents eventHandler)
        {
            DeleteIdentical gp = new DeleteIdentical();

            gp.in_dataset = source;
            gp.fields     = string.Join(";", fields);
            gp.Run(trackCancel, eventHandler);
        }
        /// <summary>
        ///     Creates a feature class containing points generated from specified vertices or locations of the input features.
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="outputTableName">Name of the output table.</param>
        /// <param name="workspace">The workspace.</param>
        /// <param name="trackCancel">The track cancel.</param>
        /// <param name="eventHandler">The events.</param>
        /// <param name="location">The location.</param>
        /// <remarks>License ArcGIS Desktop Advanced: Yes</remarks>
        /// <returns>
        ///     Returns a <see cref="IFeatureClass" /> representing the feature class.
        /// </returns>
        private static IFeatureClass CreateVertexPointsImpl(IFeatureClass source, string outputTableName, IWorkspace workspace, ITrackCancel trackCancel, IGeoProcessorEvents eventHandler, string location)
        {
            var tableName = workspace.Define(outputTableName, new FeatureClassNameClass());

            workspace.Delete(tableName);

            FeatureVerticesToPoints gp = new FeatureVerticesToPoints();

            gp.in_features       = source;
            gp.out_feature_class = workspace.GetAbsolutePath(outputTableName);
            gp.point_location    = location;

            var status = gp.Run(trackCancel, eventHandler);

            return(status == esriJobStatus.esriJobSucceeded ? workspace.GetFeatureClass(outputTableName) : null);
        }
Ejemplo n.º 22
0
        /// <summary>
        ///     Aggregates features based on specified attributes.
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="filter">The filter.</param>
        /// <param name="tableName">Name of the table.</param>
        /// <param name="workspace">The workspace.</param>
        /// <param name="dissolveFields">The field or fields on which to aggregate features.</param>
        /// <param name="statisticFields">The fields and statistics with which to summarize attributes.</param>
        /// <param name="multiPart">if set to <c>true</c> when multipart features are allowed.</param>
        /// <param name="unsplitLines">
        ///     if set to <c>false</c> the lines are dissolved into a single feature. When UNSPLIT_LINES is
        ///     specified, only two lines that have a common endpoint (known as pseudonode) are merged into one continuous line.
        /// </param>
        /// <param name="trackCancel">The track cancel.</param>
        /// <param name="eventHandler">The event handler.</param>
        /// <returns>Returns a <see cref="IFeatureClass" /> representing the feature class that contains the aggregated features.</returns>
        public static IFeatureClass Dissolve(this IFeatureClass source, IQueryFilter filter, string tableName, IWorkspace workspace, string[] dissolveFields, List <KeyValuePair <string, StatisticType> > statisticFields, bool multiPart, bool unsplitLines, ITrackCancel trackCancel, IGeoProcessorEvents eventHandler)
        {
            object input = source;

            if (filter != null && !string.IsNullOrEmpty(filter.WhereClause))
            {
                var name = string.Format("{0}_V", ((IDataset)source).Name);
                input = source.MakeView(name, filter, null, trackCancel, eventHandler);
            }

            Dissolve gp = new Dissolve();

            gp.in_features       = input;
            gp.out_feature_class = workspace.GetAbsolutePath(tableName);

            gp.dissolve_field = string.Join("; ", dissolveFields);

            if (statisticFields != null)
            {
                string        x  = null;
                StringBuilder sb = new StringBuilder();
                foreach (var kvp in statisticFields)
                {
                    sb.Append(x);
                    sb.AppendFormat("{0} {1}", kvp.Key, kvp.Value);
                    x = ";";
                }

                gp.statistics_fields = sb.ToString().ToUpperInvariant();
            }

            gp.multi_part    = multiPart ? "MULTI_PART" : "SINGLE_PART";
            gp.unsplit_lines = unsplitLines ? "UNSPLIT_LINES" : "DISSOLVE_LINES";

            if (gp.Run(trackCancel, eventHandler) == esriJobStatus.esriJobSucceeded)
            {
                return(workspace.GetFeatureClass(tableName));
            }

            return(null);
        }
 /// <summary>
 ///     Locate point features along the route and writes the result to a new point event table.
 /// </summary>
 /// <param name="source">The points to locate.</param>
 /// <param name="locatePointsAlongRouteName">The name of the event table of the located features.</param>
 /// <param name="route">The route to locate.</param>
 /// <param name="routeIDFieldName">
 ///     The field containing values that uniquely identify each route. This field can be numeric
 ///     or character.
 /// </param>
 /// <param name="searchRadius">
 ///     If the input features are points, the search radius is a numeric value defining how far around each point a search
 ///     will be done to find a target route. If the input features are lines, the search tolerance is really a cluster
 ///     tolerance, which is a numeric value
 ///     representing the maximum tolerated distance between the input lines and the target routes. If the input features
 ///     are polygons, this parameter is ignored since no search radius is used.
 /// </param>
 /// <param name="units">The units.</param>
 /// <param name="searchMultipleLocations">
 ///     If the point falls on more than one route for the given search radius, you can
 ///     have the option to create multiple event records that correspond to each route in the search radius vicinity
 /// </param>
 /// <param name="keepAllFields">
 ///     Allows you to include or disinclude the attributes of the point feature class.  If this is
 ///     set to False, the output event table will only contain the route event properties.
 /// </param>
 /// <param name="trackCancel">The track cancel.</param>
 /// <param name="eventHandler">The event handler.</param>
 /// <returns>
 ///     Returns a <see cref="ITable" /> representing the event table of the results.
 /// </returns>
 public static ITable LocateAlongRoute(this IFeatureClass source, string locatePointsAlongRouteName, IFeatureClass route, string routeIDFieldName, double searchRadius, esriUnits units, bool searchMultipleLocations, bool keepAllFields, ITrackCancel trackCancel, IGeoProcessorEvents eventHandler)
 {
     return(source.LocateAlongRoute(locatePointsAlongRouteName, ((IDataset)source).Workspace, null, route, null, routeIDFieldName, searchRadius, units, searchMultipleLocations, keepAllFields, trackCancel, eventHandler));
 }
Ejemplo n.º 24
0
 /// <summary>
 ///     Writes the rows from an feature class to a new feature class.
 /// </summary>
 /// <param name="source">The rows from a feature class to be copied.</param>
 /// <param name="tableName">The name of the table to which the rows will be written.</param>
 /// <param name="workspace">The workspace that will contain the table.</param>
 /// <param name="trackCancel">The track cancel.</param>
 /// <param name="eventHandler">The event handler.</param>
 /// <returns>
 ///     Returns a <see cref="IFeatureClass" /> representing the exported table.
 /// </returns>
 public static IFeatureClass Export(this IFeatureClass source, string tableName, IWorkspace workspace, ITrackCancel trackCancel, IGeoProcessorEvents eventHandler)
 {
     return(source.Export(null, tableName, workspace, trackCancel, eventHandler));
 }
        /// <summary>
        ///     Locates the along route implementation.
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="locateAlongRouteName">Name of the locate along route.</param>
        /// <param name="workspace">The workspace.</param>
        /// <param name="sourceWhereClause">The source where clause.</param>
        /// <param name="route">The route.</param>
        /// <param name="routeWhereClause">The route where clause.</param>
        /// <param name="routeIDFieldName">Name of the route identifier field.</param>
        /// <param name="radiusOrTolerance">The radius or tolerance.</param>
        /// <param name="radiusOrToleranceUnits">The radius or tolerance units.</param>
        /// <param name="searchMultipleLocations">if set to <c>true</c> [search multiple locations].</param>
        /// <param name="keepAllFields">if set to <c>true</c> [keep all fields].</param>
        /// <param name="trackCancel">The track cancel.</param>
        /// <param name="eventHandler">The event handler.</param>
        /// <returns></returns>
        private static ITable LocateAlongRouteImpl(IFeatureClass source, string locateAlongRouteName, IWorkspace workspace, string sourceWhereClause, IFeatureClass route, string routeWhereClause, string routeIDFieldName, double radiusOrTolerance, esriUnits radiusOrToleranceUnits, bool searchMultipleLocations, bool keepAllFields, ITrackCancel trackCancel, IGeoProcessorEvents eventHandler)
        {
            var ds = (IDataset)source;

            object input    = route;
            object features = source;

            if (!string.IsNullOrEmpty(routeWhereClause))
            {
                var name = string.Format("{0}_V", ((IDataset)route).Name);
                input = route.MakeView(name, routeWhereClause, null, trackCancel, eventHandler);
            }

            if (!string.IsNullOrEmpty(sourceWhereClause))
            {
                var name = string.Format("{0}_V", ds.Name);
                features = source.MakeView(name, sourceWhereClause, null, trackCancel, eventHandler);
            }

            LocateFeaturesAlongRoutes gp = new LocateFeaturesAlongRoutes();

            gp.in_features    = features;
            gp.in_fields      = keepAllFields ? "FIELDS" : "NO_FIELDS";
            gp.in_routes      = input;
            gp.route_id_field = routeIDFieldName;

            gp.out_table = workspace.GetAbsolutePath(locateAlongRouteName);

            if (source.ShapeType == esriGeometryType.esriGeometryPolyline)
            {
                gp.out_event_properties = string.Format("{0} LINE FMEASURE TMEASURE", routeIDFieldName);
            }
            else
            {
                gp.out_event_properties = string.Format("{0} POINT MEASURE", routeIDFieldName);
            }

            IUnitConverter converter = new UnitConverterClass();

            gp.radius_or_tolerance = string.Format("{0} {1}", radiusOrTolerance, converter.EsriUnitsAsString(radiusOrToleranceUnits, esriCaseAppearance.esriCaseAppearanceUpper, true));

            gp.route_locations = searchMultipleLocations ? "ALL" : "FIRST";

            if (gp.Run(trackCancel, eventHandler) == esriJobStatus.esriJobSucceeded)
            {
                return(workspace.GetTable(locateAlongRouteName));
            }

            return(null);
        }
Ejemplo n.º 26
0
        /// <summary>
        ///     Writes the rows from an feature class to a new feature class.
        /// </summary>
        /// <param name="source">The rows from a feature class to be copied.</param>
        /// <param name="filter">The filter used to create a subset of the data.</param>
        /// <param name="tableName">The name of the table to which the rows will be written.</param>
        /// <param name="workspace">The workspace that will contain the table.</param>
        /// <param name="trackCancel">The track cancel.</param>
        /// <param name="eventHandler">The event handler.</param>
        /// <returns>
        ///     Returns a <see cref="IFeatureClass" /> representing the exported table.
        /// </returns>
        public static IFeatureClass Export(this IFeatureClass source, IQueryFilter filter, string tableName, IWorkspace workspace, ITrackCancel trackCancel, IGeoProcessorEvents eventHandler)
        {
            object input = source;

            if (filter != null && !string.IsNullOrEmpty(filter.WhereClause))
            {
                input = source.MakeView(string.Format("{0}_V", tableName), filter, null, trackCancel, eventHandler);
            }

            CopyFeatures gp = new CopyFeatures();

            gp.in_features       = input;
            gp.out_feature_class = workspace.GetAbsolutePath(tableName);

            if (gp.Run(trackCancel, eventHandler) == esriJobStatus.esriJobSucceeded)
            {
                var table = workspace.GetFeatureClass(tableName);
                return(table);
            }

            return(null);
        }
Ejemplo n.º 27
0
        /// <summary>
        ///     Compares two tables or table views and returns the comparison results. This tool can report differences and
        ///     similarities with tabular values and field definitions
        /// </summary>
        /// <param name="source">
        ///     The Input Base Table is compared with the Input Test Table. The Input Base Table refers to tabular data that you
        ///     have declared valid. This base data has the correct field definitions and attribute values.
        /// </param>
        /// <param name="test">
        ///     The Input Test Table is compared against the Input Base Table. The Input Test Table refers to data that you have
        ///     made changes to by editing or compiling new fields, new records, or new attribute values.
        /// </param>
        /// <param name="outputFile">
        ///     This file will contain all similarities and differences between the Input Base Features and
        ///     the Input Test Features. This file is a comma-delimited text file that can be viewed and used as a table in ArcGIS.
        /// </param>
        /// <param name="sortFields">
        ///     The field or fields used to sort records in the Input Base Table and the Input Test Table. The
        ///     records are sorted in ascending order.
        /// </param>
        /// <param name="omitFields">
        ///     The field or fields that will be omitted during comparison. The field definitions and the
        ///     tabular values for these fields will be ignored.
        /// </param>
        /// <param name="compareType">
        ///     The comparision type. The default is All, which will compare all properties of the rows being compared.
        ///     ALL —All properties of the tables will be compared. This is the default.
        ///     ATTRIBUTES_ONLY —Only the attributes and their values will be compared.
        ///     SCHEMA_ONLY —Only the schema of the tables will be compared.
        /// </param>
        /// <param name="ignoreOptions">
        ///     These properties will not be compared.
        ///     IGNORE_EXTENSION_PROPERTIES —Do not compare extension properties.
        ///     IGNORE_SUBTYPES —Do not compare subtypes.
        ///     IGNORE_RELATIONSHIPCLASSES —Do not compare Relationship classes.
        ///     IGNORE_FIELDALIAS —Do not compare field alias
        /// </param>
        /// <param name="continueCompare">Indicates whether to compare all properties after encountering the first mismatch.</param>
        /// <param name="trackCancel">The track cancel.</param>
        /// <param name="eventHandler">The event handler.</param>
        private static void CompareImpl(ITable source, ITable test, string outputFile, string[] sortFields, string[] omitFields, string compareType, string ignoreOptions, bool continueCompare, ITrackCancel trackCancel, IGeoProcessorEvents eventHandler)
        {
            TableCompare gp = new TableCompare();

            gp.in_base_table = source;
            gp.in_test_table = test;

            if (sortFields != null)
            {
                gp.sort_field = string.Join(";", sortFields);
            }
            else
            {
                gp.sort_field = source.OIDFieldName;
            }

            if (omitFields != null)
            {
                gp.omit_field = string.Join(";", omitFields);
            }

            gp.compare_type   = compareType;
            gp.ignore_options = ignoreOptions;

            gp.continue_compare = continueCompare ? "CONTINUE_COMPARE" : "NO_CONTINUE_COMPARE";
            gp.out_compare_file = outputFile;

            gp.Run(trackCancel, eventHandler);
        }
Ejemplo n.º 28
0
        /// <summary>
        ///     Writes the rows from an input table to a new table.
        /// </summary>
        /// <param name="source">The rows from a table to be copied.</param>
        /// <param name="filter">The filter used to create a subset of the data.</param>
        /// <param name="tableName">The name of the table to which the rows will be written.</param>
        /// <param name="workspace">The workspace that will contain the table.</param>
        /// <param name="trackCancel">The track cancel.</param>
        /// <param name="eventHandler">The event handler.</param>
        /// <returns>
        ///     Returns a <see cref="ITable" /> representing the exported table.
        /// </returns>
        public static ITable Export(this ITable source, IQueryFilter filter, string tableName, IWorkspace workspace, ITrackCancel trackCancel, IGeoProcessorEvents eventHandler)
        {
            object input = source;

            if (filter != null && !string.IsNullOrEmpty(filter.WhereClause))
            {
                var name = string.Format("V_{0}", tableName);
                input = source.MakeView(name, filter, null, trackCancel, eventHandler);
            }

            CopyRows gp = new CopyRows();

            gp.in_rows   = input;
            gp.out_table = tableName;

            if (gp.Run(trackCancel, eventHandler) == esriJobStatus.esriJobSucceeded)
            {
                var table = workspace.GetTable(tableName);
                return(table);
            }

            return(null);
        }
Ejemplo n.º 29
0
 /// <summary>
 ///     Compares two tables or table views and returns the comparison results. This tool can report differences and
 ///     similarities with tabular values and field definitions
 /// </summary>
 /// <param name="source">
 ///     The Input Base Table is compared with the Input Test Table. The Input Base Table refers to tabular
 ///     data that you have declared valid. This base data has the correct field definitions and attribute values.
 /// </param>
 /// <param name="test">
 ///     The Input Test Table is compared against the Input Base Table. The Input Test Table refers to data
 ///     that you have made changes to by editing or compiling new fields, new records, or new attribute values.
 /// </param>
 /// <param name="outputFile">
 ///     This file will contain all similarities and differences between the Input Base Features and
 ///     the Input Test Features. This file is a comma-delimited text file that can be viewed and used as a table in ArcGIS.
 /// </param>
 /// <param name="sortFields">
 ///     The field or fields used to sort records in the Input Base Table and the Input Test Table. The
 ///     records are sorted in ascending order.
 /// </param>
 /// <param name="omitFields">
 ///     The field or fields that will be omitted during comparison. The field definitions and the
 ///     tabular values for these fields will be ignored.
 /// </param>
 /// <param name="continueCompare">Indicates whether to compare all properties after encountering the first mismatch.</param>
 /// <param name="trackCancel">The track cancel.</param>
 /// <param name="eventHandler">The event handler.</param>
 public static void Compare(this ITable source, ITable test, string outputFile, string[] sortFields, string[] omitFields, bool continueCompare, ITrackCancel trackCancel, IGeoProcessorEvents eventHandler)
 {
     CompareImpl(source, test, outputFile, sortFields, omitFields, "ATTRIBUTES_ONLY", "", continueCompare, trackCancel, eventHandler);
 }
Ejemplo n.º 30
0
        /// <summary>
        ///     Calculates summary statistics for field(s) in a table.
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="outputTableName">Name of the output table.</param>
        /// <param name="workspace">The workspace.</param>
        /// <param name="statisticFields">
        ///     The numeric field containing attribute values used to calculate the specified
        ///     statistic by the type of the statistic (SUM, MEAN, MIN, MAX, RANGE, STD, FIRST, LAST, COUNT).
        /// </param>
        /// <param name="caseFields">
        ///     The fields in the Input Table used to calculate statistics separately for each unique
        ///     attribute value (or combination of attributes values when multiple fields are specified).
        /// </param>
        /// <param name="trackCancel">The track cancel.</param>
        /// <param name="eventHandler">The events.</param>
        /// <returns>
        ///     Return <see cref="ITable" /> representing the table of statistic data.
        /// </returns>
        public static ITable Statistics(this IFeatureClass source, string outputTableName, IWorkspace workspace, List <KeyValuePair <string, StatisticType> > statisticFields, string[] caseFields, ITrackCancel trackCancel, IGeoProcessorEvents eventHandler)
        {
            Statistics gp = new Statistics();

            gp.in_table  = source;
            gp.out_table = workspace.GetAbsolutePath(outputTableName);

            string        x  = null;
            StringBuilder sb = new StringBuilder();

            foreach (var kvp in statisticFields)
            {
                sb.Append(x);
                sb.AppendFormat("{0} {1}", kvp.Key, kvp.Value);
                x = ";";
            }

            gp.statistics_fields = sb.ToString().ToUpperInvariant();
            gp.case_field        = string.Join(";", caseFields).ToUpperInvariant();

            if (gp.Run(trackCancel, eventHandler) == esriJobStatus.esriJobSucceeded)
            {
                return(workspace.GetTable(outputTableName));
            }

            return(null);
        }