<?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: How to export a new layer by python after select by location? in Geoprocessing Questions</title>
    <link>https://community.esri.com/t5/geoprocessing-questions/how-to-export-a-new-layer-by-python-after-select/m-p/134909#M4613</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Your problem is that you are using SelectLayerByLocation slightly wrong. The syntax is: (in_layer, {overlap_type}, {select_features}, {search_distance}, {selection_type})&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The 1st parameter is the feature class from which to select features intersecting features in the 3rd parameter. Your 3rd parameter feature class was created empty with CreateFeatureClass, so there are no intersections with the 1st parameter.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Make the selection (referencing the correct feature class), then output that selection with &lt;/SPAN&gt;&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/Copy_Features/001700000035000000/"&gt;Copy Features&lt;/A&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 29 Aug 2011 21:10:36 GMT</pubDate>
    <dc:creator>DarrenWiens2</dc:creator>
    <dc:date>2011-08-29T21:10:36Z</dc:date>
    <item>
      <title>How to export a new layer by python after select by location?</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/how-to-export-a-new-layer-by-python-after-select/m-p/134908#M4612</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;My mission is to select some polygons by location ( intersect with existing lines), and then export the result as a new shape file layer. I have been trying different ways and search for helps but it ended to nothing yet. So please help if you know. Following is my current codes:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Import system modules&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; import sys, string, os, arcgisscripting&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Create the Geoprocessor object&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; gp = arcgisscripting.create()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Load required toolboxes&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.AddToolbox("C:/Program Files/ArcGIS/ArcToolbox/Toolboxes/Data Management.tbx")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;try:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Set the workspace (to avoid having to type in the full path to the data every time)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.Workspace = "C:\temp"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.overwriteOutput = 1&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; outFolder = r???C:\Temp???&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; outFile = ???Polygon.shp???&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.workspace = outFolder&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.CreateFeatureClass (outFolder, outFile, ???Polygon???, ???#???,???#???,???#???, "#")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Script arguments...&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Output_Feature_Class = outFile&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Input_Features = sys.argv[1]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Process: Find all stream crossings (points)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.SelectLayerByLocation(Input_Features, "intersect", Output_Feature_Class)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;except:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; # If an error occurred while running a tool, print the messages.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print gp.GetMessages()&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 29 Aug 2011 19:35:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/how-to-export-a-new-layer-by-python-after-select/m-p/134908#M4612</guid>
      <dc:creator>JiefanYu</dc:creator>
      <dc:date>2011-08-29T19:35:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to export a new layer by python after select by location?</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/how-to-export-a-new-layer-by-python-after-select/m-p/134909#M4613</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Your problem is that you are using SelectLayerByLocation slightly wrong. The syntax is: (in_layer, {overlap_type}, {select_features}, {search_distance}, {selection_type})&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The 1st parameter is the feature class from which to select features intersecting features in the 3rd parameter. Your 3rd parameter feature class was created empty with CreateFeatureClass, so there are no intersections with the 1st parameter.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Make the selection (referencing the correct feature class), then output that selection with &lt;/SPAN&gt;&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/Copy_Features/001700000035000000/"&gt;Copy Features&lt;/A&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 29 Aug 2011 21:10:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/how-to-export-a-new-layer-by-python-after-select/m-p/134909#M4613</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2011-08-29T21:10:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to export a new layer by python after select by location?</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/how-to-export-a-new-layer-by-python-after-select/m-p/134910#M4614</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;How about this?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; # Create the Geoprocessor object&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import arcgisscripting&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;gp = arcgisscripting.create()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;# Load required toolboxes&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;gp.AddToolbox("C:/Program Files/ArcGIS/ArcToolbox/Toolboxes/Data Management.tbx")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;# Set the workspace (to avoid having to type in the full path to the data every time)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;gp.Workspace = "C:\temps"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Input_Features = sys.argv[1]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Select_features= sys.argv[2]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;try:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;# Select intersect polygons &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; gp.SelectLayerByLocation("Input_Features", "intersect", "Select_features")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Write the selected features to a new feature class&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; gp.CopyFeatures("Input_Features", "C:\temps\result.shp")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;except:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; # If an error occurred, print the message to the screen&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; print gp.GetMessages()&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;//////////////////////////////////////////////////////////////////////////////////////&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;But when I try to run it, an error sign still pop up:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;type 'exceptions.IndentationError'&amp;gt;: ERROR 999999: Error executing function&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Failed to execute (Intersect).&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 31 Aug 2011 19:50:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/how-to-export-a-new-layer-by-python-after-select/m-p/134910#M4614</guid>
      <dc:creator>JiefanYu</dc:creator>
      <dc:date>2011-08-31T19:50:34Z</dc:date>
    </item>
  </channel>
</rss>

