<?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 Passing paramaters / variables thru Select Layer By Location in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/passing-paramaters-variables-thru-select-layer-by/m-p/399323#M31489</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Good afternoon all&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Having some issues with the Select By Location function returning an odd error message that I can't shake out.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm pretty confident it's falling over on the first half of the if..else command. This is in there to differentiate between features which need to be checked with a buffer distance and those that don't (this bit of code will be iterated through all the features in a dataset individually).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Code (or snippets of):&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;sqlquery = OIDFieldName + "=" + str(oid)
dataset_tocheck_lyr = arcpy.MakeFeatureLayer_management(dataset_tocheck, "dataset_tocheck_lyr", "\"sqlquery\"")
themelocation_lyr = arcpy.MakeFeatureLayer_management(themelocation, "themelocation_lyr") #create temp layer of theme location
bufferdist = str(int(overlayfeature.DIST)) + " Meters"
.
.
.
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if int(overlayfeature.DIST) == 0: 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByLocation_management(themelocation_lyr, "INTERSECT", dataset_tocheck_lyr, "","NEW_SELECTION")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output_text.write("Buffer is zero, not factoring into SBL\n\n")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByLocation_management(themelocation_lyr, "INTERSECT", dataset_tocheck_lyr, "\"bufferdist\"", "NEW_SELECTION")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output_text.write("Buffer is not zero, factoring additional string into SBL\n\n")&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Error:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;Traceback (most recent call last):
&amp;nbsp; File "C:\Python26\ArcGIS10.0\Lib\site-packages\Pythonwin\pywin\framework\scriptutils.py", line 326, in RunScript
&amp;nbsp;&amp;nbsp;&amp;nbsp; exec codeObject in __main__.__dict__
&amp;nbsp; File "U:\PythonValuesChecking\Python Scripts\ValuesChecker.py", line 74, in &amp;lt;module&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByLocation_management(themelocation_lyr, "INTERSECT", dataset_tocheck_lyr, "","NEW_SELECTION")
&amp;nbsp; File "C:\Program Files\ArcGIS\Desktop10.0\arcpy\arcpy\management.py", line 4381, in SelectLayerByLocation
&amp;nbsp;&amp;nbsp;&amp;nbsp; raise e
ExecuteError: ERROR 999999: Error executing function.
An invalid SQL statement was used.
An invalid SQL statement was used.
An invalid SQL statement was used.
An invalid SQL statement was used.
Failed to execute (SelectLayerByLocation).
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This has thrown a few other problems at me, which I have so far been able to solve, but this one has got me stuffed.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any thoughts?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 19 Aug 2012 04:07:41 GMT</pubDate>
    <dc:creator>AnthonyCheesman1</dc:creator>
    <dc:date>2012-08-19T04:07:41Z</dc:date>
    <item>
      <title>Passing paramaters / variables thru Select Layer By Location</title>
      <link>https://community.esri.com/t5/python-questions/passing-paramaters-variables-thru-select-layer-by/m-p/399323#M31489</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Good afternoon all&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Having some issues with the Select By Location function returning an odd error message that I can't shake out.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm pretty confident it's falling over on the first half of the if..else command. This is in there to differentiate between features which need to be checked with a buffer distance and those that don't (this bit of code will be iterated through all the features in a dataset individually).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Code (or snippets of):&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;sqlquery = OIDFieldName + "=" + str(oid)
dataset_tocheck_lyr = arcpy.MakeFeatureLayer_management(dataset_tocheck, "dataset_tocheck_lyr", "\"sqlquery\"")
themelocation_lyr = arcpy.MakeFeatureLayer_management(themelocation, "themelocation_lyr") #create temp layer of theme location
bufferdist = str(int(overlayfeature.DIST)) + " Meters"
.
.
.
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if int(overlayfeature.DIST) == 0: 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByLocation_management(themelocation_lyr, "INTERSECT", dataset_tocheck_lyr, "","NEW_SELECTION")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output_text.write("Buffer is zero, not factoring into SBL\n\n")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByLocation_management(themelocation_lyr, "INTERSECT", dataset_tocheck_lyr, "\"bufferdist\"", "NEW_SELECTION")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output_text.write("Buffer is not zero, factoring additional string into SBL\n\n")&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Error:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;Traceback (most recent call last):
&amp;nbsp; File "C:\Python26\ArcGIS10.0\Lib\site-packages\Pythonwin\pywin\framework\scriptutils.py", line 326, in RunScript
&amp;nbsp;&amp;nbsp;&amp;nbsp; exec codeObject in __main__.__dict__
&amp;nbsp; File "U:\PythonValuesChecking\Python Scripts\ValuesChecker.py", line 74, in &amp;lt;module&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByLocation_management(themelocation_lyr, "INTERSECT", dataset_tocheck_lyr, "","NEW_SELECTION")
&amp;nbsp; File "C:\Program Files\ArcGIS\Desktop10.0\arcpy\arcpy\management.py", line 4381, in SelectLayerByLocation
&amp;nbsp;&amp;nbsp;&amp;nbsp; raise e
ExecuteError: ERROR 999999: Error executing function.
An invalid SQL statement was used.
An invalid SQL statement was used.
An invalid SQL statement was used.
An invalid SQL statement was used.
Failed to execute (SelectLayerByLocation).
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This has thrown a few other problems at me, which I have so far been able to solve, but this one has got me stuffed.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any thoughts?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 19 Aug 2012 04:07:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/passing-paramaters-variables-thru-select-layer-by/m-p/399323#M31489</guid>
      <dc:creator>AnthonyCheesman1</dc:creator>
      <dc:date>2012-08-19T04:07:41Z</dc:date>
    </item>
    <item>
      <title>Re: Passing paramaters / variables thru Select Layer By Location</title>
      <link>https://community.esri.com/t5/python-questions/passing-paramaters-variables-thru-select-layer-by/m-p/399324#M31490</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Seems like something with the extra qoutation marks and escape characters in the buffer distance you are passing to SBL.&amp;nbsp; Have you tried passing bufferdist without the "\"\""?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 19 Aug 2012 11:09:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/passing-paramaters-variables-thru-select-layer-by/m-p/399324#M31490</guid>
      <dc:creator>BruceBacia</dc:creator>
      <dc:date>2012-08-19T11:09:21Z</dc:date>
    </item>
  </channel>
</rss>

