Beispiel #1
0
        /// <summary>
        /// 空间擦除
        /// </summary>
        /// <param name="featureClassPath"></param>
        /// <param name="layerId"></param>
        /// <param name="outFsName"></param>
        /// <returns></returns>
        public static IFeatureClass spatialErase(string gdb, IFeatureClass features, int layerId)
        {
            IFeatureClass kzxFs = Utils.featureClsArray[layerId];

            string layer_name = kzxFs.AliasName;

            Geoprocessor gp    = new Geoprocessor();
            Erase        erase = new Erase();

            erase.in_features    = features;
            erase.erase_features = kzxFs;

            erase.out_feature_class = gdb + @"\results\" + layer_name + @"EraseResult";

            try
            {
                gp.AddOutputsToMap = false;
                gp.OverwriteOutput = true;
                gp.Execute(erase, null);

                gp.ResetEnvironments();
                IFeatureClass outFs = FeatureOperations.OpenFeatureClass(gdb, "results", layer_name + @"EraseResult");

                return(outFs);
            }
            catch (System.Exception ex)
            {
                string error = "";
                for (int i = 0; i < gp.MessageCount; i++)
                {
                    error += gp.GetMessage(i);
                }
                return(null);
            }
        }
Beispiel #2
0
        /// <summary>
        /// 空间求交
        /// </summary>
        /// <param name="featureClassPath"></param>
        /// <param name="layerId"></param>
        /// <returns></returns>
        public static IFeatureClass spatialIntersect(string gdb, IFeatureClass features, int layerId)
        {
            IFeatureClass kzxFs = Utils.featureClsArray[layerId];

            string layer_name = kzxFs.AliasName;

            Geoprocessor gp        = new Geoprocessor();
            Intersect    intersect = new Intersect();

            string fs1 = gdb + @"\inputs\input";
            string fs2 = gdb + @"\kzx\" + layer_name;

            intersect.in_features       = fs1 + ";" + fs2;
            intersect.out_feature_class = gdb + @"\results\" + layer_name + @"IntersectResult";

            try
            {
                gp.AddOutputsToMap = false;
                gp.OverwriteOutput = true;
                gp.Execute(intersect, null);

                gp.ResetEnvironments();
                IFeatureClass outFs = FeatureOperations.OpenFeatureClass(gdb, "results", layer_name + @"IntersectResult");

                return(outFs);
            }
            catch (System.Exception ex)
            {
                string error = "";
                for (int i = 0; i < gp.MessageCount; i++)
                {
                    error += gp.GetMessage(i);
                }
                return(null);
            }
        }