<?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: Zoom to ATS Location and Merge Features in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/zoom-to-ats-location-and-merge-features/m-p/427512#M33602</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;To do things like zooming etc you will need to work with the 'current' mxd.&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;mxd = arcpy.mapping.MapDocument("current")&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;* is not a valid query value for arc (unless you are dealing with strings). It is hard to tell, are the values in your table you are querying in string format or numeric?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 16 Apr 2013 12:44:41 GMT</pubDate>
    <dc:creator>MathewCoyle</dc:creator>
    <dc:date>2013-04-16T12:44:41Z</dc:date>
    <item>
      <title>Zoom to ATS Location and Merge Features</title>
      <link>https://community.esri.com/t5/python-questions/zoom-to-ats-location-and-merge-features/m-p/427509#M33599</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Alright. Let me start off by saying I am completely new to python . I am a GIS student and for a project I have (ambitiously) decided to try and make a couple (I thought simple) script tools. The first one I want is to be able to have the user input which meridian, township, range, section, quarter section, and LSD they want to look at (yes just look at) and then have the map zoom to that area. I need the script to still work if any of the fields are left blank (they put in meridian, township, range but nothing else, for example). Simple right? I thought so but apparently my brain is too mushy to figure it out. I have no idea where to start.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The second thing i want to do is a little more tricky. I downloaded multiple NTS base features and need to (in the end) be able to rename them, define the projection, reproject them, merge like-features into one (all hydrology together, all roads together, etc), and then use this final feature in a cost distance analysis. What I've done for this is create a model that iterates through the folder I have all of my folders of base features in and rename them (Hydrology_0, Hydrology_1, etc) and defines the projection and then puts the shapefiles back into the folder of folders (so outside their original ones but inside the folder containing them). I then manually merged them and used them but is there any way to make this simpler using python? &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any help is greatly appreciated! Thanks so much&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Apr 2013 23:18:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/zoom-to-ats-location-and-merge-features/m-p/427509#M33599</guid>
      <dc:creator>CourtneySorsdahl</dc:creator>
      <dc:date>2013-04-09T23:18:59Z</dc:date>
    </item>
    <item>
      <title>Re: Zoom to ATS Location and Merge Features</title>
      <link>https://community.esri.com/t5/python-questions/zoom-to-ats-location-and-merge-features/m-p/427510#M33600</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;For your first problem it is fairly simple to design a script tool to take optional parameters. Then based on which parameters are input create a query to input into a layer selection or layer definition query to then get the selected extent and set that to your data frame extent.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here's a simple example.&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;arcpy.SelectLayerByAttribute_management(
&amp;nbsp;&amp;nbsp;&amp;nbsp; lyr, "NEW_SELECTION", "{0} = '{1}'".format(field, value))

df.extent = lyr.getSelectedExtent(False)&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The second problem is a little harder, it will be highly dependant on your particular environment and requirements in regards to specific features and how they are organized.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 19:14:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/zoom-to-ats-location-and-merge-features/m-p/427510#M33600</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2021-12-11T19:14:37Z</dc:date>
    </item>
    <item>
      <title>Re: Zoom to ATS Location and Merge Features</title>
      <link>https://community.esri.com/t5/python-questions/zoom-to-ats-location-and-merge-features/m-p/427511#M33601</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks so much for the tip. So I kind of have some kind of code but I don't know if i have everything I need.. Every time I run it it gives me different errors, but most have to do with my expression. any advice?? Oh, I'm also trying to make a script tool out of it and I have all of the parameters set as strings..&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 mapping

mxd = arcpy.mapping.MapDocument(r"F:\CostDistanceEx.mxd")
df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]
lyr = arcpy.mapping.ListLayers(mxd, "QTR_83K", df)[0]

Meridian = arcpy.GetParameterAsText(0)
if Meridian == '':
&amp;nbsp;&amp;nbsp;&amp;nbsp; Meridian = "*" 

Range = arcpy.GetParameterAsText(1)
if Range == '':
&amp;nbsp;&amp;nbsp;&amp;nbsp; Range = "*" 

Township = arcpy.GetParameterAsText(2)
if Township == '':
&amp;nbsp;&amp;nbsp;&amp;nbsp; Township = "*" 

Section = arcpy.GetParameterAsText(3)
if Section == '':
&amp;nbsp;&amp;nbsp;&amp;nbsp; Section = "*" 

Quarter = arcpy.GetParameterAsText(4)
if Quarter == '':
&amp;nbsp;&amp;nbsp;&amp;nbsp; Quarter = "*" 

Expression = "\"MER\" = " + str(Meridian) + "\"RGE\" = " + str(Range) + "\"TWP\" = " + str(Township) + "\"SEC\" = " + str(Section) + "\"QTR\" = " + str(Quarter)

arcpy.SelectLayerByAttribute_management(lyr, "NEW_SELECTION", Expression)

df.extent = lyr.getSelectedExtent(False)

df.scale = df.scale * 1.1

arcpy.RefreshActiveView()
del mxd&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 19:14:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/zoom-to-ats-location-and-merge-features/m-p/427511#M33601</guid>
      <dc:creator>CourtneySorsdahl</dc:creator>
      <dc:date>2021-12-11T19:14:39Z</dc:date>
    </item>
    <item>
      <title>Re: Zoom to ATS Location and Merge Features</title>
      <link>https://community.esri.com/t5/python-questions/zoom-to-ats-location-and-merge-features/m-p/427512#M33602</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;To do things like zooming etc you will need to work with the 'current' mxd.&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;mxd = arcpy.mapping.MapDocument("current")&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;* is not a valid query value for arc (unless you are dealing with strings). It is hard to tell, are the values in your table you are querying in string format or numeric?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Apr 2013 12:44:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/zoom-to-ats-location-and-merge-features/m-p/427512#M33602</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2013-04-16T12:44:41Z</dc:date>
    </item>
    <item>
      <title>Re: Zoom to ATS Location and Merge Features</title>
      <link>https://community.esri.com/t5/python-questions/zoom-to-ats-location-and-merge-features/m-p/427513#M33603</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Sorry it's confusing, I'm not very good at explaining things! the MER, RGE, TWP and SEC fields are all long (numeric) and the QTR field is a string.. like I said I'm very new to python (this is my second month learning it) and I can't really find anything along the same lines. Thanks so much for the help. if anything else is unclear let me know&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Apr 2013 15:01:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/zoom-to-ats-location-and-merge-features/m-p/427513#M33603</guid>
      <dc:creator>CourtneySorsdahl</dc:creator>
      <dc:date>2013-04-16T15:01:28Z</dc:date>
    </item>
    <item>
      <title>Re: Zoom to ATS Location and Merge Features</title>
      <link>https://community.esri.com/t5/python-questions/zoom-to-ats-location-and-merge-features/m-p/427514#M33604</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I came up with something like the following. It will take any parameter input and append the associated field name and the value as a tuple to a list. Then iterate through that list appending the values to the expression for however many values there are. Then at the end it removes the 'AND' tag that is defaulted at the end of each loop. The AddMessage is a good line to add when trouble shooting to ensure your variables are being put together as expected.&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;list1 = []
Expression = ''

Meridian = arcpy.GetParameterAsText(0)
if Meridian:
&amp;nbsp;&amp;nbsp;&amp;nbsp; list1.append(('MER', Meridian))

Range = arcpy.GetParameterAsText(1)
if Range:
&amp;nbsp;&amp;nbsp;&amp;nbsp; list1.append(('RGE', Range))

Township = arcpy.GetParameterAsText(2)
if Township:
&amp;nbsp;&amp;nbsp;&amp;nbsp; list1.append(('TWP', Township))

Section = arcpy.GetParameterAsText(3)
if Section:
&amp;nbsp;&amp;nbsp;&amp;nbsp; list1.append(('SEC', Section))

Quarter = arcpy.GetParameterAsText(4)
if Quarter:
&amp;nbsp;&amp;nbsp;&amp;nbsp; list1.append(('QTR', "'{0}'".format(Quarter)))

for field, val in list1:
&amp;nbsp;&amp;nbsp;&amp;nbsp; Expression += '{0} = {1} AND '.format(field, val)
Expression = Expression.strip()[:-4]
arcpy.AddMessage(Expression)
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 19:14:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/zoom-to-ats-location-and-merge-features/m-p/427514#M33604</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2021-12-11T19:14:42Z</dc:date>
    </item>
    <item>
      <title>Re: Zoom to ATS Location and Merge Features</title>
      <link>https://community.esri.com/t5/python-questions/zoom-to-ats-location-and-merge-features/m-p/427515#M33605</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Alright yeah that makes sense! now.. I would just put my select by attributes and the rest of it as i had it or does it need to be changed? was the rest of it okay? because I just tried it and that part worked fine but its giviing me a syntax error at this part &lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;arcpy.SelectLayerByAttribute_management(lyr, "NEW_SELECTION", Expression)&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;if i follow it with whats below, is that the correct way to do it? &lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;df.extent = lyr.getSelectedExtent(False)
df.scale = df.scale * 1.1
arcpy.RefreshActiveView()
del mxd&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 19:14:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/zoom-to-ats-location-and-merge-features/m-p/427515#M33605</guid>
      <dc:creator>CourtneySorsdahl</dc:creator>
      <dc:date>2021-12-11T19:14:45Z</dc:date>
    </item>
    <item>
      <title>Re: Zoom to ATS Location and Merge Features</title>
      <link>https://community.esri.com/t5/python-questions/zoom-to-ats-location-and-merge-features/m-p/427516#M33606</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Scratch that! thanks so so much!!! you're a life saver. Works great&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Apr 2013 16:37:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/zoom-to-ats-location-and-merge-features/m-p/427516#M33606</guid>
      <dc:creator>CourtneySorsdahl</dc:creator>
      <dc:date>2013-04-16T16:37:06Z</dc:date>
    </item>
  </channel>
</rss>

