<?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: Applying Definition Query to Layer in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/applying-definition-query-to-layer/m-p/357874#M28252</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Where are you establishing a reference to the 'dataSource_lyr' variable?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;As it shows,you have clearly established a reference to it above this section of code since you're using the 'dataSource_lyr' to call the layer in your 'MakeFeatureLayer_management()' function.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 21 Feb 2014 13:52:04 GMT</pubDate>
    <dc:creator>JohnDye</dc:creator>
    <dc:date>2014-02-21T13:52:04Z</dc:date>
    <item>
      <title>Applying Definition Query to Layer</title>
      <link>https://community.esri.com/t5/python-questions/applying-definition-query-to-layer/m-p/357872#M28250</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have some code that goes through and adds layers to a Map Document. I also want to apply definition queries to some layers:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.MakeFeatureLayer_management(dataSource,dataSource_lyr)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;addLayer = arcpy.mapping.Layer(dataSource_lyr)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.mapping.AddLayer(df,addLayer)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;if row.getValue("Definition_Query") &amp;lt;&amp;gt; None:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; addLayer.definitionQuery = "FIELD1" = 'Test'&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I think I may be confusing myself, but I'm thinking I set a feature layer on a data source of some kind (arcpy.MakeFeatureLayer_management), and then set that feature layer to a layer object (arcpy.mapping.Layer) so that I have access to the layers properties? At that point, can I not use the addLayer variable to set a definition query? &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;When I go into the resulting ArcMap and look at the definition query, it's empty.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Feb 2014 18:16:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/applying-definition-query-to-layer/m-p/357872#M28250</guid>
      <dc:creator>MikeMacRae</dc:creator>
      <dc:date>2014-02-20T18:16:49Z</dc:date>
    </item>
    <item>
      <title>Re: Applying Definition Query to Layer</title>
      <link>https://community.esri.com/t5/python-questions/applying-definition-query-to-layer/m-p/357873#M28251</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I believe that the expression syntax is wrong for the Definition Query.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You have:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;addLayer.definitionQuery = "FIELD1" = 'Test'&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Change to:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;addLayer.definitionQuery = ' "FIELD1" = \'Test\' '&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Feb 2014 23:01:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/applying-definition-query-to-layer/m-p/357873#M28251</guid>
      <dc:creator>AdamMarinelli</dc:creator>
      <dc:date>2014-02-20T23:01:37Z</dc:date>
    </item>
    <item>
      <title>Re: Applying Definition Query to Layer</title>
      <link>https://community.esri.com/t5/python-questions/applying-definition-query-to-layer/m-p/357874#M28252</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Where are you establishing a reference to the 'dataSource_lyr' variable?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;As it shows,you have clearly established a reference to it above this section of code since you're using the 'dataSource_lyr' to call the layer in your 'MakeFeatureLayer_management()' function.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Feb 2014 13:52:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/applying-definition-query-to-layer/m-p/357874#M28252</guid>
      <dc:creator>JohnDye</dc:creator>
      <dc:date>2014-02-21T13:52:04Z</dc:date>
    </item>
    <item>
      <title>Re: Applying Definition Query to Layer</title>
      <link>https://community.esri.com/t5/python-questions/applying-definition-query-to-layer/m-p/357875#M28253</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks Adam, I think that was one of my issues. The second issue, was I was doing a clip between setting the definition query and the adding the layer to the map, which appears to have deleted the query during the clip.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;John, the dataSource_lyr variable was just a string concatenation I set earlier to get a dynamic name for the feature layer output.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Feb 2014 15:15:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/applying-definition-query-to-layer/m-p/357875#M28253</guid>
      <dc:creator>MikeMacRae</dc:creator>
      <dc:date>2014-02-25T15:15:16Z</dc:date>
    </item>
  </channel>
</rss>

