<?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/674625#M52181</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Just using the code provided in the desktop python window.&amp;nbsp; Then clipping a feature that's in my window of contents with the poly variable created. Thats it!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;import arcpy&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;#mxd = arcpy.mapping.MapDocument("CURRENT")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;df = arcpy.mapping.ListDataFrames(mxd,"Layers")[0]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;extent = df.extent&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;array = arcpy.Array()&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;array.add(extent.lowerLeft)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;array.add(extent.lowerRight)#array.add(extent.upperRight)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;array.add(extent.upperLeft)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;array.add(extent.lowerLeft)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;poly = arcpy.Polygon(array)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.Clip_analysis('Trapper Lines',poly,"Trapper_Extent")&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 20 Jun 2012 21:00:19 GMT</pubDate>
    <dc:creator>DevonJenkins</dc:creator>
    <dc:date>2012-06-20T21:00:19Z</dc:date>
    <item>
      <title>Clipping by view extent</title>
      <link>https://community.esri.com/t5/python-questions/clipping-by-view-extent/m-p/674617#M52173</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;I want to clip features based on my window extent. Right now I am creating a clip feature class polygon to match my view. instead of inputting "clip features" to clip, is there a syntax to input for the dataframe?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;thanks&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Jun 2012 14:32:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/clipping-by-view-extent/m-p/674617#M52173</guid>
      <dc:creator>DevonJenkins</dc:creator>
      <dc:date>2012-06-20T14:32:07Z</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/674618#M52174</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Devon,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You could create a polygon object based on the MXD's data frame extent, and then use the object to clip the feature class.&amp;nbsp; Here is an example:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
from arcpy import env
from arcpy import mapping
env.workspace = r"C:\temp\python\test.gdb"

mxd = mapping.MapDocument(r"C:\temp\python\County.mxd")
df = mapping.ListDataFrames(mxd)[0]
xmin = df.extent.XMin
ymin = df.extent.YMin
xmax = df.extent.XMax
ymax = df.extent.YMax

pnt1 = arcpy.Point(xmin, ymin)
pnt2 = arcpy.Point(xmin, ymax)
pnt3 = arcpy.Point(xmax, ymax)
pnt4 = arcpy.Point(xmax, ymin)

array = arcpy.Array()
array.add(pnt1)
array.add(pnt2)
array.add(pnt3)
array.add(pnt4)
array.add(pnt1)

poly = arcpy.Polygon(array)

arcpy.Clip_analysis("Hospitals", poly, "Hospitals_clip")
del mxd&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 04:26:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/clipping-by-view-extent/m-p/674618#M52174</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2021-12-12T04:26:52Z</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/674619#M52175</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hey thanks for the reply. So everything works great up until I run the actually clip. It creates a shape file however it contains no features. Any thoughts?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Jun 2012 17:56:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/clipping-by-view-extent/m-p/674619#M52175</guid>
      <dc:creator>DevonJenkins</dc:creator>
      <dc:date>2012-06-20T17:56:25Z</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/674620#M52176</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;One thing I forgot to mention is to make sure your data frame coordinate system matches that of your feature class.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Jun 2012 18:31:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/clipping-by-view-extent/m-p/674620#M52176</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2012-06-20T18:31:16Z</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/674621#M52177</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Hi Devon,&lt;BR /&gt;&lt;BR /&gt;You could create a polygon object based on the MXD's data frame extent, and then use the object to clip the feature class.&amp;nbsp; Here is an example:&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
from arcpy import env
from arcpy import mapping
env.workspace = r"C:\temp\python\test.gdb"

mxd = mapping.MapDocument(r"C:\temp\python\County.mxd")
df = mapping.ListDataFrames(mxd)[0]
xmin = df.extent.XMin
ymin = df.extent.YMin
xmax = df.extent.XMax
ymax = df.extent.YMax

pnt1 = arcpy.Point(xmin, ymin)
pnt2 = arcpy.Point(xmin, ymax)
pnt3 = arcpy.Point(xmax, ymax)
pnt4 = arcpy.Point(xmax, ymin)

array = arcpy.Array()
array.add(pnt1)
array.add(pnt2)
array.add(pnt3)
array.add(pnt4)
array.add(pnt1)

poly = arcpy.Polygon(array)

arcpy.Clip_analysis("Hospitals", poly, "Hospitals_clip")
del mxd&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Hey Jake, just wondering what the reasoning is behind everything broken up like that? This is a similar code I use, I don't remember if I wrote it or stole it from someone. If I did steal it credit to them.&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import arcpy

mxd = arcpy.mapping.MapDocument("CURRENT")
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)

polygon = arcpy.Polygon(array)
...&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 04:26:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/clipping-by-view-extent/m-p/674621#M52177</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2021-12-12T04:26:54Z</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/674622#M52178</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Matt,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;No reasoning, just wrote it out when I replied to the thread so I didn't have time to simplify the script.&amp;nbsp; Yours will do exactly the same, just less lines of code.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Jun 2012 19:07:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/clipping-by-view-extent/m-p/674622#M52178</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2012-06-20T19:07:40Z</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/674623#M52179</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Coordinate systems are the same.... still generated an empty output. There is only one data frame.... it seems as if my data isn't in the same area as the clipper...which isn't the case but that's the error I'm getting using both syntax from above:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;"000117 Warning empty output generated:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;A common occurrence of this warning occurs when the Extent (or XYDomain) environment has been set previously for a geographically distinct area. Since the Extent environment is used to limit the features used, an inappropriately set Extent environment could exclude all features."&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Jun 2012 20:25:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/clipping-by-view-extent/m-p/674623#M52179</guid>
      <dc:creator>DevonJenkins</dc:creator>
      <dc:date>2012-06-20T20:25:50Z</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/674624#M52180</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Coordinate systems are the same.... still generated an empty output. There is only one data frame.... it seems as if my data isn't in the same area as the clipper...which isn't the case but that's the error I'm getting using both syntax from above:&lt;BR /&gt;&lt;BR /&gt;"000117 Warning empty output generated:&lt;BR /&gt;A common occurrence of this warning occurs when the Extent (or XYDomain) environment has been set previously for a geographically distinct area. Since the Extent environment is used to limit the features used, an inappropriately set Extent environment could exclude all features."&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;It definitely works for me. How are you incorporating this script? Is it part of a larger tool or are you just executing this section in the python window?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Jun 2012 20:46:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/clipping-by-view-extent/m-p/674624#M52180</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2012-06-20T20:46:16Z</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/674625#M52181</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Just using the code provided in the desktop python window.&amp;nbsp; Then clipping a feature that's in my window of contents with the poly variable created. Thats it!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;import arcpy&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;#mxd = arcpy.mapping.MapDocument("CURRENT")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;df = arcpy.mapping.ListDataFrames(mxd,"Layers")[0]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;extent = df.extent&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;array = arcpy.Array()&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;array.add(extent.lowerLeft)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;array.add(extent.lowerRight)#array.add(extent.upperRight)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;array.add(extent.upperLeft)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;array.add(extent.lowerLeft)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;poly = arcpy.Polygon(array)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.Clip_analysis('Trapper Lines',poly,"Trapper_Extent")&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Jun 2012 21:00:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/clipping-by-view-extent/m-p/674625#M52181</guid>
      <dc:creator>DevonJenkins</dc:creator>
      <dc:date>2012-06-20T21:00:19Z</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/674626#M52182</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;It looks like you are only inputting 4 points to create your polygon, you need 5 points to create a closed rectangle.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Jun 2012 21:23:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/clipping-by-view-extent/m-p/674626#M52182</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2012-06-20T21:23:42Z</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/674627#M52183</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;It looks like you are only inputting 4 points to create your polygon, you need 5 points to create a closed rectangle.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Yeah that was just a typo when writing the code here.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Jun 2012 14:23:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/clipping-by-view-extent/m-p/674627#M52183</guid>
      <dc:creator>DevonJenkins</dc:creator>
      <dc:date>2012-06-26T14:23:18Z</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/674628#M52184</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Devon,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What is the input you are using for the Clip GP tool (i.e. shapefile, feature class)?&amp;nbsp; I noticed there is a space in the name (Trapper Lines).&amp;nbsp; Try renaming the shapefile/feature class and remove the space.&amp;nbsp; When naming a shapefile, feature class, or table you should follow the 3 rules below:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;1.&amp;nbsp; Should not contain spaces&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2.&amp;nbsp; Should not begin with a number&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;3.&amp;nbsp; Should not contain any special characters&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Jun 2012 15:22:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/clipping-by-view-extent/m-p/674628#M52184</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2012-06-26T15:22:32Z</dc:date>
    </item>
  </channel>
</rss>

