<?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: Points Within a view in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/points-within-a-view/m-p/273121#M21120</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;The SelectLayerByLocation_management is looking for another feature layer, just as though you used the menu items SELECT&amp;gt;&amp;gt;SELECT BY LOCATION. There is no choice for "view extent". &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;It seems to me that you need to get a pointer to the dataframe ie: df = arcpy.mappinglListDataFrames(mxd)[0] , then use df.extent to return the current extent.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Next, you could get a cursor on the point features, and iterate through the rows, checking if the point.x and point.y values are within the dataframe extents, and adding them to the selectionset if they are.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Adding the selected attributes to the layout is a different problem. Do you need to show the entire attribute table, or just a few columns of information? &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Jim&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 07 Jun 2012 15:17:36 GMT</pubDate>
    <dc:creator>JimCousins</dc:creator>
    <dc:date>2012-06-07T15:17:36Z</dc:date>
    <item>
      <title>Points Within a view</title>
      <link>https://community.esri.com/t5/python-questions/points-within-a-view/m-p/273117#M21116</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am fairly new to python.&amp;nbsp; But I have been asked to write a tool that will allow the user to pan to a specific location and hit a button that creates a PDF of the view as well as showing the attribute values from a layer&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;in the view.&amp;nbsp; I can create the PDF of the view no problem.&amp;nbsp; I am have difficulty with selecting and outputting the points from the layer. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;PRE class="plain" name="code"&gt;
newinputfile ="mypointfile"

arcpy.env.overwriteOutput = true

definput = arcpy.GetParameterAsText(0)

if definput == '#" or not definput":
 definput = newinputfile;
 env.workspace = "d:/Myprojects/DefWorkspace/projdata.gdb"

arcpy.AddMessage("starting")

mxd = arcpy.mapping.MapDocument("CURRENT")

layers = arcpy.mapping.ListLayers(mxd)

for layer in layers:
 if layer.longName == newinputfile:
 arcpy.addMessage("found layer")
# here is where I lose it
 arcpy.SelectLayerByLocation_management( ???, ???&amp;nbsp; 


arcpy.mapping.ExportToPDF(mxd,"outputPDF")

# somehow add the selected point attributes the PDF

#Done.
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks&amp;nbsp; for looking&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Jun 2012 19:38:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/points-within-a-view/m-p/273117#M21116</guid>
      <dc:creator>WilliamIde</dc:creator>
      <dc:date>2012-06-06T19:38:08Z</dc:date>
    </item>
    <item>
      <title>Re: Points Within a view</title>
      <link>https://community.esri.com/t5/python-questions/points-within-a-view/m-p/273118#M21117</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Could you please show the full statement for this line?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;arcpy.SelectLayerByLocation_management( ???, ???&amp;nbsp; ....)&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Another question, what do you mean by 'point attributes' when you say &lt;/SPAN&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;".... add the selected point attributes to the PDF.."? &lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Assuming, by "attributes" you mean the point features themselves, I suggest use these steps before exporting to PDF:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;# assuming you have only one data frame
df = arcpy.mapping.ListDataFrames(mxd)[0]

df.zoomToSelectedFeatures()

# clear selection - otherwise, the PDF will contain selection color 
arcpy.SelectLayerByAttribute_management("state_centroids", "CLEAR_SELECTION")&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 13:20:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/points-within-a-view/m-p/273118#M21117</guid>
      <dc:creator>NobbirAhmed</dc:creator>
      <dc:date>2021-12-11T13:20:27Z</dc:date>
    </item>
    <item>
      <title>Re: Points Within a view</title>
      <link>https://community.esri.com/t5/python-questions/points-within-a-view/m-p/273119#M21118</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;That's just it. I don't know what parameters to use in the SelectByLocation.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I will try the df code and get back to you.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Jun 2012 14:45:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/points-within-a-view/m-p/273119#M21118</guid>
      <dc:creator>WilliamIde</dc:creator>
      <dc:date>2012-06-07T14:45:02Z</dc:date>
    </item>
    <item>
      <title>Re: Points Within a view</title>
      <link>https://community.esri.com/t5/python-questions/points-within-a-view/m-p/273120#M21119</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I added the:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;df = arcpy.mapping.ListDataFrames(mxd) [0] &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;statement.&amp;nbsp; That completed.&amp;nbsp; The &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;df.zoomToSelectedFeatures()&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Failed it said that df didn't have zoom.... attribute.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The clear selection completed but did not alter the arcmap display. I assume because I didn't do an update.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What I am trying to accomplish is to find all of the points in the current view of the map.&amp;nbsp; Select then and then export each point as a table to a PDF.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Jun 2012 15:09:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/points-within-a-view/m-p/273120#M21119</guid>
      <dc:creator>WilliamIde</dc:creator>
      <dc:date>2012-06-07T15:09:36Z</dc:date>
    </item>
    <item>
      <title>Re: Points Within a view</title>
      <link>https://community.esri.com/t5/python-questions/points-within-a-view/m-p/273121#M21120</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;The SelectLayerByLocation_management is looking for another feature layer, just as though you used the menu items SELECT&amp;gt;&amp;gt;SELECT BY LOCATION. There is no choice for "view extent". &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;It seems to me that you need to get a pointer to the dataframe ie: df = arcpy.mappinglListDataFrames(mxd)[0] , then use df.extent to return the current extent.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Next, you could get a cursor on the point features, and iterate through the rows, checking if the point.x and point.y values are within the dataframe extents, and adding them to the selectionset if they are.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Adding the selected attributes to the layout is a different problem. Do you need to show the entire attribute table, or just a few columns of information? &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Jim&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Jun 2012 15:17:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/points-within-a-view/m-p/273121#M21120</guid>
      <dc:creator>JimCousins</dc:creator>
      <dc:date>2012-06-07T15:17:36Z</dc:date>
    </item>
    <item>
      <title>Re: Points Within a view</title>
      <link>https://community.esri.com/t5/python-questions/points-within-a-view/m-p/273122#M21121</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Just a few compared to the 20K or so records in the point featureclass.&amp;nbsp; I expect that the number of records will be between 30 and 60.&amp;nbsp; So I will interrogate the dr and come up with my map extent. Then as you say find the ones inside the extent.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;From other posts I have seen that outputing to a PDF has probelems using 10.0.&amp;nbsp; ( I am using 10.0 SP2 )&amp;nbsp; There are goofy workarounds suggested.&amp;nbsp; Which I will try once I get the list of selected points.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Jun 2012 15:46:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/points-within-a-view/m-p/273122#M21121</guid>
      <dc:creator>WilliamIde</dc:creator>
      <dc:date>2012-06-07T15:46:30Z</dc:date>
    </item>
  </channel>
</rss>

