<?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 feature classes by feature classes in Geoprocessing Questions</title>
    <link>https://community.esri.com/t5/geoprocessing-questions/clip-feature-classes-by-feature-classes/m-p/72273#M2537</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Here's a simple script that would do what you want.&amp;nbsp; It assumes you're using shapefiles.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import arcgisscripting, os
gp = arcgisscripting.create()

clippers = "c:/junk/clippers/"
toBeClipped = "c:/junk/toBeClipped/"
output = "c:/junk/toBeClipped/output/"

# Get a list of the "clippers"
for fc in os.listdir(clippers):
&amp;nbsp;&amp;nbsp;&amp;nbsp; if fc.endswith('.shp'):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Get a list of the files to be clipped.
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for shp in os.listdir(toBeClipped):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if shp.endswith('.shp'):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Clipping "+shp+" with "+fc
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # NOTE: add the name of the "clipper" onto the output name so it's unique.
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.Clip_analysis(toBeClipped+shp, clippers+fc, output+shp[:-4]+fc)&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 10 Dec 2021 22:47:55 GMT</pubDate>
    <dc:creator>RDHarles</dc:creator>
    <dc:date>2021-12-10T22:47:55Z</dc:date>
    <item>
      <title>Clip feature classes by feature classes</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/clip-feature-classes-by-feature-classes/m-p/72272#M2536</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;There are a lot of examples on the web on how to clip a lot of layers by a single feature class, and the python code would be more or less like below... But what happens when you want to clip each feature class in the input folder by more than one feature classs located for example in a "Clip_features" folder? Hor do you iterate at the same time over the input feature classes and the clip feature classes?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt; 
import arcgisscripting, sys, os
gp = arcgisscripting.create()
gp.workspace = "D:\inWorkspace"
clipFeatures = "D:\shape.shp"
outWorkspace = "D:\outWorkspace"
fcs = gp.ListFeatureClasses()
fcs.Reset()
fc = fcs.Next()
while fc:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; outFeatureClass = outWorkspace + os.sep + fc.split('_')[0] + "_clip.shp"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.Clip_analysis(fc, clipFeatures, outFeatureClass, "")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fc = fcs.Next()
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you in advance,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Bogdan&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 Jun 2010 13:52:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/clip-feature-classes-by-feature-classes/m-p/72272#M2536</guid>
      <dc:creator>bogdanpalade1</dc:creator>
      <dc:date>2010-06-16T13:52:57Z</dc:date>
    </item>
    <item>
      <title>Re: Clip feature classes by feature classes</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/clip-feature-classes-by-feature-classes/m-p/72273#M2537</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Here's a simple script that would do what you want.&amp;nbsp; It assumes you're using shapefiles.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import arcgisscripting, os
gp = arcgisscripting.create()

clippers = "c:/junk/clippers/"
toBeClipped = "c:/junk/toBeClipped/"
output = "c:/junk/toBeClipped/output/"

# Get a list of the "clippers"
for fc in os.listdir(clippers):
&amp;nbsp;&amp;nbsp;&amp;nbsp; if fc.endswith('.shp'):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Get a list of the files to be clipped.
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for shp in os.listdir(toBeClipped):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if shp.endswith('.shp'):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Clipping "+shp+" with "+fc
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # NOTE: add the name of the "clipper" onto the output name so it's unique.
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.Clip_analysis(toBeClipped+shp, clippers+fc, output+shp[:-4]+fc)&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 22:47:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/clip-feature-classes-by-feature-classes/m-p/72273#M2537</guid>
      <dc:creator>RDHarles</dc:creator>
      <dc:date>2021-12-10T22:47:55Z</dc:date>
    </item>
    <item>
      <title>Re: Clip feature classes by feature classes</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/clip-feature-classes-by-feature-classes/m-p/72274#M2538</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thank you very much for the code, it works perfectly. As I have a lot of data to be clipped, sometimes, when the output would be empty (there was no data to be clipped) I get the "Extent of the overlay operation will be empty. " error. Searching the forums I've seen that it was a common issue in the past for the ArcGIS 9.3 environment. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I'll try to put &lt;/SPAN&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;gp.extent = "MAXOF" &lt;/PRE&gt;&lt;SPAN&gt; in the script to see if it works.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The funny thing is that sometimes it generates the empty shapefile (when there's no data to be clipped) but othertimes it raises the above mentioned error.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you again for your help,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Bogdan&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 Jun 2010 07:42:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/clip-feature-classes-by-feature-classes/m-p/72274#M2538</guid>
      <dc:creator>bogdanpalade1</dc:creator>
      <dc:date>2010-06-18T07:42:07Z</dc:date>
    </item>
    <item>
      <title>Re: Clip feature classes by feature classes</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/clip-feature-classes-by-feature-classes/m-p/72275#M2539</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt; I get the "Extent of the overlay operation will be empty. " error. &lt;BR /&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;One way to avoid the script stopping on error (when you don't want it to) is to put the tool in a try/except like this.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;It will print the error message in the "except:" part and just keep on going...&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family:monospace;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcgisscripting, os
gp = arcgisscripting.create()

clippers = "c:/junk/clippers/"
toBeClipped = "c:/junk/toBeClipped/"
output = "c:/junk/toBeClipped/output/"

# Get a list of the "clippers"
for fc in os.listdir(clippers):
&amp;nbsp;&amp;nbsp;&amp;nbsp; if fc.endswith('.shp'):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Get a list of the files to be clipped.
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for shp in os.listdir(toBeClipped):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if shp.endswith('.shp'):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Clipping "+shp+" with "+fc
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # NOTE: add the name of the "clipper" onto the output name so it's unique.
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; try:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.Clip_analysis(toBeClipped+shp, clippers+fc, output+shp[:-4]+fc)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; except:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "ERROR output emtpy: "+output

print "\nDone.\n"&amp;nbsp; &lt;/PRE&gt;&lt;SPAN style="font-family:monospace;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 22:47:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/clip-feature-classes-by-feature-classes/m-p/72275#M2539</guid>
      <dc:creator>RDHarles</dc:creator>
      <dc:date>2021-12-10T22:47:57Z</dc:date>
    </item>
    <item>
      <title>Re: Clip feature classes by feature classes</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/clip-feature-classes-by-feature-classes/m-p/72276#M2540</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Well,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In the end we decided that even if the clip result would be empty, we still would want to have a empty feature class with the attribute table present. We found that by putting the gp.extent to "MAXOF" it does just that. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you for all your help&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Bogdan&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Jun 2010 08:16:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/clip-feature-classes-by-feature-classes/m-p/72276#M2540</guid>
      <dc:creator>bogdanpalade1</dc:creator>
      <dc:date>2010-06-25T08:16:23Z</dc:date>
    </item>
    <item>
      <title>Re: Clip feature classes by feature classes</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/clip-feature-classes-by-feature-classes/m-p/72277#M2541</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have a single shapefile that I need to clip multiple times with different shapefiles.&amp;nbsp; It seems like the code in this thread should work, but I tried the script and did not get any results.&amp;nbsp; No error messages, just nothing in the output folder.&amp;nbsp; How should I change the script to work with version 10 and my current workflow?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Dec 2010 20:24:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/clip-feature-classes-by-feature-classes/m-p/72277#M2541</guid>
      <dc:creator>SusanZwillinger</dc:creator>
      <dc:date>2010-12-29T20:24:19Z</dc:date>
    </item>
    <item>
      <title>Re: Clip feature classes by feature classes</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/clip-feature-classes-by-feature-classes/m-p/72278#M2542</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;I have a single shapefile that I need to clip multiple times with different shapefiles.&amp;nbsp; It seems like the code in this thread should work, but I tried the script and did not get any results.&amp;nbsp; No error messages, just nothing in the output folder.&amp;nbsp; How should I change the script to work with version 10 and my current workflow?&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Susan, &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;It could be many things:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1.) Have you set up the paths to your shapefiles correctly?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2.) Are all the shapefiles in the same coordinate system?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;* Whether you are using ARC 9.x or 10 shouldn't make any difference in this case.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;** I'd recommend posting the exact code you are trying to use&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Dec 2010 12:30:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/clip-feature-classes-by-feature-classes/m-p/72278#M2542</guid>
      <dc:creator>RDHarles</dc:creator>
      <dc:date>2010-12-30T12:30:53Z</dc:date>
    </item>
  </channel>
</rss>

