<?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: Clipping by view extent in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/clipping-by-view-extent/m-p/390743#M30884</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;It doesn't look like you are specifying the .shp extension when you are executing the 'CopyFeatures' function.&amp;nbsp; Since your workspace is set to a folder, you will need to specify the extension.&amp;nbsp; Try the following and see if it works:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
arcpy.CopyFeatures_management("LINE DATA &amp;amp; DISPOSITIONS/Trapper Lines","Trapper_copy.shp")&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 17:55:06 GMT</pubDate>
    <dc:creator>JakeSkinner</dc:creator>
    <dc:date>2021-12-11T17:55:06Z</dc:date>
    <item>
      <title>Clipping by view extent</title>
      <link>https://community.esri.com/t5/python-questions/clipping-by-view-extent/m-p/390742#M30883</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi everyone,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This is the second post I have made on this subject.....I couldnt find the old post. Here is my script. Everything seems to be in order however when the clip function runs, it clips features by the window extent...however it produces and empty shape file. Any ideas?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;

#DESCRIPTION:
#-clips Hydro and trapper features by data frame window extent
#-dissolves hyrdro layer to simplify line work
#-densify's both features to create more detailed line work
#-matches the trapper lines accordingly with the water features

#Import arcpy modules
import arcpy
#import operating system-level tools - usefull when working with paths
import os

#displays location of python script
home = os.getcwd()

#Declare Water feature variable
Hydro = "G:/Data/GIS/ArcGIS_Mapping/Hydrography.gdb/Watercourse_Poly"

#Provides access to map document
mxd = arcpy.mapping.MapDocument("CURRENT")

#Directs output shapefile to specified folder
arcpy.env.workspace = "C:/Users/DJenkins/Desktop/Temp_Folder Apr2012 - Present/Python/Trapper Script/Output Shape"

#Allows data to be overwritten
arcpy.env.overwriteOutput = True

#Makes a copy of original Trapper Line Data
arcpy.CopyFeatures_management("LINE DATA &amp;amp; DISPOSITIONS/Trapper Lines","Trapper_copy")

df = arcpy.mapping.ListDataFrames(mxd,"Layers")[0]

extent = df.extent
array = arcpy.Array()

array.add(extent.lowerLeft)
array.add(extent.lowerRight)
array.add(extent.upperRight)
array.add(extent.upperLeft)
array.add(extent.lowerLeft)

poly = arcpy.Polygon(array)

#Clip Trapper feature by window extent
arcpy.Clip_analysis("Trapper_copy",poly,"Trapper_Extent")

#Clip Hydro feature by window extent
arcpy.Clip_analysis(Hydro,poly,"Hydro_extent")

#Dissolve Hydro_copy
arcpy.Dissolve_management("Hydro_extent","Hydro_Dissolve","FID")

#Find the number of features in the the trapper_extent &amp;amp; Hydro_copy
arcpy.GetCount_management("Trapper_Extent")
arcpy.GetCount_management("Hydro_Dissolve")


try:
&amp;nbsp;&amp;nbsp;&amp;nbsp; #Add more points along trapper/Hydro features
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Densify_edit("Trapper_Extent", "DISTANCE", "25 meters")
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Densify_edit("Hydro_Dissolve", "DISTANCE", "25 meters")
&amp;nbsp;&amp;nbsp;&amp;nbsp; #Snap the trapper points to match the Hydro features
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Snap_edit("Trapper_Extent", [["Hydro_Dissolve","EDGE", "250 meters"]])
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
except:&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; #Print the results
&amp;nbsp;&amp;nbsp;&amp;nbsp; print arcpy.GetMessages(2)
else:
&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Congradulations! The script finished successfully. Your trapper lines now match with the hydro features."

del mxd&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Jun 2012 19:30:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/clipping-by-view-extent/m-p/390742#M30883</guid>
      <dc:creator>DevonJenkins</dc:creator>
      <dc:date>2012-06-28T19:30:53Z</dc:date>
    </item>
    <item>
      <title>Re: Clipping by view extent</title>
      <link>https://community.esri.com/t5/python-questions/clipping-by-view-extent/m-p/390743#M30884</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;It doesn't look like you are specifying the .shp extension when you are executing the 'CopyFeatures' function.&amp;nbsp; Since your workspace is set to a folder, you will need to specify the extension.&amp;nbsp; Try the following and see if it works:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
arcpy.CopyFeatures_management("LINE DATA &amp;amp; DISPOSITIONS/Trapper Lines","Trapper_copy.shp")&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 17:55:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/clipping-by-view-extent/m-p/390743#M30884</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2021-12-11T17:55:06Z</dc:date>
    </item>
    <item>
      <title>Re: Clipping by view extent</title>
      <link>https://community.esri.com/t5/python-questions/clipping-by-view-extent/m-p/390744#M30885</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Have you tried using a different workspace.&amp;nbsp; The number of spaces that are in your current workspace may be causing issues.&amp;nbsp; Attached is a File Geodatabase and MXD that you can test with.&amp;nbsp; Create a folder called 'Temp' on you C: drive and extract the contents of the zip there, then execute the following within ArcMap while the MXD is open:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import arcpy
import os

mxd = arcpy.mapping.MapDocument("CURRENT")

arcpy.env.workspace = "C:/Temp"
arcpy.env.overwriteOutput = True

arcpy.CopyFeatures_management("Trapper Lines","Trapper_copy")

df = arcpy.mapping.ListDataFrames(mxd,"Layers")[0]

extent = df.extent
array = arcpy.Array()

array.add(extent.lowerLeft)
array.add(extent.lowerRight)
array.add(extent.upperRight)
array.add(extent.upperLeft)
array.add(extent.lowerLeft)

poly = arcpy.Polygon(array)

arcpy.Clip_analysis("Trapper_copy",poly,"Trapper_Extent")&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 17:55:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/clipping-by-view-extent/m-p/390744#M30885</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2021-12-11T17:55:09Z</dc:date>
    </item>
  </channel>
</rss>

