<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Clip parameters issue (C#, AnalysisTools) in Geoprocessing Questions</title>
    <link>https://community.esri.com/t5/geoprocessing-questions/clip-parameters-issue-c-analysistools/m-p/524057#M17413</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I did run into the same issue, after one hour of googling i found a solution. Have you tried setting a Layername?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;IFeatureLayer featureLayer = new FeatureLayer();
featureLayer.FeatureClass = featureClass;
featureLayer.Name = featureLayer.FeatureClass.AliasName;&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;Adding a name to the FeatureLayer worked fine for me...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Alternatively you can try creating a layer via ESRI.ArcGIS.DataManagementTools.MakeFeatureLayer.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Greetz&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 22:50:53 GMT</pubDate>
    <dc:creator>ChristopherDresel</dc:creator>
    <dc:date>2021-12-11T22:50:53Z</dc:date>
    <item>
      <title>Clip parameters issue (C#, AnalysisTools)</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/clip-parameters-issue-c-analysistools/m-p/524055#M17411</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi there,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;When I use AnalysisTools.Clip to clip a layer (feature class) in C# programming, I found that it didn't work when I specified the in_features and clip_features with IFeatureLayer. It worked when I specified the parameters with IFeatureClass. However, it works in ArcMap with ArcMap Layers. I want to use FeatureLayer because I want to apply some selection on layer (especially for clip_features). Otherwise, I have to use "select" tool to generate a middle shapefile. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This code works:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
IFeatureClass fcInFeatures = sdeWorkspace.OpenFeatureClass("SDE_DEVL.DBO.SdeHydro");
IFeatureClass fcClipFeatures = sdeWorkspace.OpenFeatureClass("SDE_DEVL.DBO.SdeTownship");
clip.in_features = fcInFeactures;
clip.clip_features = fcClipFeatures;
clip.out_features = @"c:\temp\clip_test.shp";
gp.execute(clip, null);
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But this didn't work with IFeatureLayer:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
IFeatureClass fcInFeatures = sdeWorkspace.OpenFeatureClass("SDE_DEVL.DBO.SdeHydro");
IFeatureClass fcClipFeatures = sdeWorkspace.OpenFeatureClass("SDE_DEVL.DBO.SdeTownship");
IFeatureLayer flClipFeatures = new FeatureLayerClass();
flClipFeatures.FeatureClass = fcClipFeatures;
IFeatureSelection fsClipFeatures = flClipFeatures as IFeatureSelection;
IQueryFilter qfClipper = new QueryFilterClass();
qfClipper.where_clause = "Mrt = 411039";
fsClipFeatures.SelectFeatures(qfClipper, esriSelectionResultEnum.esriSelectionResultNew, false); 
log.DebugFormat("There are {0} township(s) used to clip aggrements. ", fsTownship.SelectionSet.Count); //check the select result, it is ok, only one feature selected.
clip.in_features = fcInFeactures;
clip.clip_features = flClipFeatures; // this didn't work :(
clip.out_features = @"c:\temp\clip_test.shp";
gp.execute(clip, null);
&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;It reported "Invalid parameters".&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Does anyone work with this situation? Any suggestions?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks a lot.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Apr 2010 13:52:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/clip-parameters-issue-c-analysistools/m-p/524055#M17411</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2010-04-09T13:52:19Z</dc:date>
    </item>
    <item>
      <title>Re: Clip parameters issue (C#, AnalysisTools)</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/clip-parameters-issue-c-analysistools/m-p/524056#M17412</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm having exactly the same problem, clip works fine with Feature Classes, but not with Feature Layers which I need to use as they have a selection. Did you ever solve this?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I've tried alot of the solutions to this I could find with Google from the old forums, and the problem is always the invalid parameter of the feature layer. 2 of the mehtods I've tried are copied in below.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt; 
Dim GP As ESRI.ArcGIS.Geoprocessing.IGeoProcessor
GP = New ESRI.ArcGIS.Geoprocessing.GeoProcessor
Dim Parameters As IVariantArray
Parameters = New VarArray
Parameters.Add(pClipFtrLyr)
Parameters.Add(pInLayer)
Parameters.Add(pOutFtrClsNmDS.WorkspaceName.PathName &amp;amp; "\" &amp;amp; pOutFtrClsNmDS.Name)
Try
GP.Execute("Clip_analysis", Parameters, Nothing)
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.OkOnly, "Doh!")
End Try
&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;second method tested:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt; 
Dim GP As ESRI.ArcGIS.Geoprocessor.Geoprocessor = New ESRI.ArcGIS.Geoprocessor.Geoprocessor()
GP.OverwriteOutput = True
GP.AddOutputsToMap = False
Dim pClipTool As ESRI.ArcGIS.AnalysisTools.Clip = New ESRI.ArcGIS.AnalysisTools.Clip
pClipTool.in_features = pClipFtrLyr
pClipTool.clip_features = pInLayer
pClipTool.out_feature_class = pOutFtrClsNmDS.WorkspaceName.PathName &amp;amp; "\" &amp;amp; pOutFtrClsNmDS.Name
Dim pResult As ESRI.ArcGIS.Geoprocessing.IGeoProcessorResult
pResult = CType(GP.Execute(pClipTool, Nothing), ESRI.ArcGIS.Geoprocessing.IGeoProcessorResult)
If Not pResult Is Nothing Then
 Dim GPError As String = ""
 Dim ErrCount As Integer
 If GP.MessageCount &amp;gt; 0 Then
&amp;nbsp; For ErrCount = 0 To GP.MessageCount - 1
&amp;nbsp; GPError += (GP.GetMessage(ErrCount)) &amp;amp; vbNewLine
&amp;nbsp; Next
&amp;nbsp; MsgBox(GPError, MsgBoxStyle.OkOnly, "Failed")
 End If
Else
 Dim GPError As String = Nothing
 Dim ErrCount As Integer
 If GP.MessageCount &amp;gt; 0 Then
&amp;nbsp;&amp;nbsp; For ErrCount = 0 To GP.MessageCount - 1
&amp;nbsp; GPError += (GP.GetMessage(ErrCount)) &amp;amp; vbNewLine
&amp;nbsp; Next
&amp;nbsp; MsgBox(GPError, MsgBoxStyle.OkOnly, "Failed")
 End If
End If
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 22:50:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/clip-parameters-issue-c-analysistools/m-p/524056#M17412</guid>
      <dc:creator>AndrewEgleton</dc:creator>
      <dc:date>2021-12-11T22:50:50Z</dc:date>
    </item>
    <item>
      <title>Re: Clip parameters issue (C#, AnalysisTools)</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/clip-parameters-issue-c-analysistools/m-p/524057#M17413</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I did run into the same issue, after one hour of googling i found a solution. Have you tried setting a Layername?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;IFeatureLayer featureLayer = new FeatureLayer();
featureLayer.FeatureClass = featureClass;
featureLayer.Name = featureLayer.FeatureClass.AliasName;&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;Adding a name to the FeatureLayer worked fine for me...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Alternatively you can try creating a layer via ESRI.ArcGIS.DataManagementTools.MakeFeatureLayer.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Greetz&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 22:50:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/clip-parameters-issue-c-analysistools/m-p/524057#M17413</guid>
      <dc:creator>ChristopherDresel</dc:creator>
      <dc:date>2021-12-11T22:50:53Z</dc:date>
    </item>
  </channel>
</rss>

