<?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: Spatial Reference grab not working... in Transportation Questions</title>
    <link>https://community.esri.com/t5/transportation-questions/spatial-reference-grab-not-working/m-p/407741#M1365</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Original User: SStrand&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;&lt;BR /&gt;The only other issue I can think of it being is something wonky with your 2.7 install and arcpy not playing nicely.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I'll try it out on another computer here and see how it goes.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 27 Feb 2013 21:05:43 GMT</pubDate>
    <dc:creator>Anonymous User</dc:creator>
    <dc:date>2013-02-27T21:05:43Z</dc:date>
    <item>
      <title>Spatial Reference grab not working...</title>
      <link>https://community.esri.com/t5/transportation-questions/spatial-reference-grab-not-working/m-p/407732#M1356</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Original User: SStrand&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have a large metadata generating script that is working great, except for some reason the spatial reference of the data being grabbed and wrote to a Word file is not working.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;First, the portion to write text to word (this works fine for all other instances in the script):&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;def search_replace_all(newword, find_str, replace_str):
&amp;nbsp;&amp;nbsp;&amp;nbsp; wdFindContinue = 1
&amp;nbsp;&amp;nbsp;&amp;nbsp; wdReplaceAll = 2
&amp;nbsp;&amp;nbsp;&amp;nbsp; app = win32com.client.Dispatch("Word.Application")
&amp;nbsp;&amp;nbsp;&amp;nbsp; app.Visible = 0
&amp;nbsp;&amp;nbsp;&amp;nbsp; app.DisplayAlerts = 0

&amp;nbsp;&amp;nbsp;&amp;nbsp; app.Documents.Open(newword)
&amp;nbsp;&amp;nbsp;&amp;nbsp; app.Selection.Find.Execute(find_str, False, False, False, False, False, \
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; True, wdFindContinue, False, replace_str, wdReplaceAll)
&amp;nbsp;&amp;nbsp;&amp;nbsp; app.ActiveDocument.Close(SaveChanges=True)

&amp;nbsp;&amp;nbsp;&amp;nbsp; app.Quit()

search_replace_all(newword, olddate, newdate)&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here is the code that isn't working:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;spatialdesc = arcpy.Describe(newlayer)
sr = spatialdesc.SpatialReference
newspatial = sr.Name

search_replace_all(newword, oldspatial, newspatial)&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I've also seen this as/tried unsuccesfully in my code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;sr = arcpy.Describe(newlayer).spatialReference
newspatial = sr.name

search_replace_all(newword, oldspatial, newspatial)&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;All I get is a generic script error failure response when it gets to this point. Any ideas as to why it won't complete this part correctly?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am using ArcGIS 10.0 SP3, Windows 7, Python 2.7&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 18:32:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/transportation-questions/spatial-reference-grab-not-working/m-p/407732#M1356</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-12-11T18:32:07Z</dc:date>
    </item>
    <item>
      <title>Re: Spatial Reference grab not working...</title>
      <link>https://community.esri.com/t5/transportation-questions/spatial-reference-grab-not-working/m-p/407733#M1357</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;How are you generating the oldspatial variable? Can you print out all the names you are passing to your word writing function in the interpreter before you attempt to call the function?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Feb 2013 19:54:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/transportation-questions/spatial-reference-grab-not-working/m-p/407733#M1357</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2013-02-27T19:54:10Z</dc:date>
    </item>
    <item>
      <title>Re: Spatial Reference grab not working...</title>
      <link>https://community.esri.com/t5/transportation-questions/spatial-reference-grab-not-working/m-p/407734#M1358</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Original User: SStrand&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So the way it works is I have a template word file that is copied and then edited with metadata information from a variety of sources, including the layer I am working with. 'Oldspatial' is the filler text in the template word file that is replaced by the actual spatial reference 'newspatial'.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;newlayer = arcpy.GetParameterAsText(0)
newlayername = arcpy.GetParameterAsText(1)
newdate = arcpy.GetParameterAsText(4)
tempword = "K:\\SDE_System\\metadata\\AGS10_Metadata\\_gis_metadata_template.doc"
tempdir = os.path.dirname(tempword)
newword = os.path.join(tempdir, newlayername + ".doc")
olddate = "06/09/2000"
oldspatial = "ie: State Plane California 6 Feet"&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;These are all related to what I have posted code wise.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 18:32:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/transportation-questions/spatial-reference-grab-not-working/m-p/407734#M1358</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-12-11T18:32:10Z</dc:date>
    </item>
    <item>
      <title>Re: Spatial Reference grab not working...</title>
      <link>https://community.esri.com/t5/transportation-questions/spatial-reference-grab-not-working/m-p/407735#M1359</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Original User: SStrand&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Just ran the script with&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;arcpy.AddMessage("test")&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;before the&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;search_replace_all(newword, oldspatial, newspatial)&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;and it failed without displaying the name. There is already an arcpy.AddMessage("The document is X% complete") right before&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;spatialdesc = arcpy.Describe(newlayer)
sr = spatialdesc.SpatialReference
newspatial = sr.Name&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;so something is going wrong in there...&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 18:32:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/transportation-questions/spatial-reference-grab-not-working/m-p/407735#M1359</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-12-11T18:32:13Z</dc:date>
    </item>
    <item>
      <title>Re: Spatial Reference grab not working...</title>
      <link>https://community.esri.com/t5/transportation-questions/spatial-reference-grab-not-working/m-p/407736#M1360</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;How are you passing this parameter to your tool? Object, string, something else?&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;newlayer = arcpy.GetParameterAsText(0)&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Feb 2013 20:30:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/transportation-questions/spatial-reference-grab-not-working/m-p/407736#M1360</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2013-02-27T20:30:30Z</dc:date>
    </item>
    <item>
      <title>Re: Spatial Reference grab not working...</title>
      <link>https://community.esri.com/t5/transportation-questions/spatial-reference-grab-not-working/m-p/407737#M1361</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Original User: SStrand&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In the script properties it is a Layer data type, to allow for a drop down of available layers in the ArcMap document. In the ArcGIS help under &lt;/SPAN&gt;&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/Describe/000v00000026000000/"&gt;describe&lt;/A&gt;&lt;SPAN&gt; it made it sound like that wasn't an issue.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Feb 2013 20:37:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/transportation-questions/spatial-reference-grab-not-working/m-p/407737#M1361</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2013-02-27T20:37:56Z</dc:date>
    </item>
    <item>
      <title>Re: Spatial Reference grab not working...</title>
      <link>https://community.esri.com/t5/transportation-questions/spatial-reference-grab-not-working/m-p/407738#M1362</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Does it work with the capitalization shown below?&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;sr = spatialdesc.&lt;STRONG&gt;s&lt;/STRONG&gt;patialReference
newspatial = sr.&lt;STRONG&gt;n&lt;/STRONG&gt;ame&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;edit: I should add, this works for me&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 18:32:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/transportation-questions/spatial-reference-grab-not-working/m-p/407738#M1362</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2021-12-11T18:32:16Z</dc:date>
    </item>
    <item>
      <title>Re: Spatial Reference grab not working...</title>
      <link>https://community.esri.com/t5/transportation-questions/spatial-reference-grab-not-working/m-p/407739#M1363</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Original User: SStrand&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Does it work with the capitalization shown below?&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;sr = spatialdesc.&lt;STRONG&gt;s&lt;/STRONG&gt;patialReference
newspatial = sr.&lt;STRONG&gt;n&lt;/STRONG&gt;ame&lt;/PRE&gt;&lt;BR /&gt;edit: I should add, this works for me&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Nope, that is actually how I originally had it until, while researching possible issues, I came across &lt;/SPAN&gt;&lt;A href="https://www.e-education.psu.edu/geog485/node/115" rel="nofollow noopener noreferrer" target="_blank"&gt;this page&lt;/A&gt;&lt;SPAN&gt; which had it the current way.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Edit: I don't believe the code is wrong...but I have no clue why it is failing.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 18:32:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/transportation-questions/spatial-reference-grab-not-working/m-p/407739#M1363</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-12-11T18:32:19Z</dc:date>
    </item>
    <item>
      <title>Re: Spatial Reference grab not working...</title>
      <link>https://community.esri.com/t5/transportation-questions/spatial-reference-grab-not-working/m-p/407740#M1364</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;This code works fine for me.&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy


def main(layer):
&amp;nbsp;&amp;nbsp;&amp;nbsp; spatialdesc = arcpy.Describe(layer)
&amp;nbsp;&amp;nbsp;&amp;nbsp; sr = spatialdesc.SpatialReference
&amp;nbsp;&amp;nbsp;&amp;nbsp; newspatial = sr.Name
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage(newspatial)

if __name__ == '__main__':
&amp;nbsp;&amp;nbsp;&amp;nbsp; layer = arcpy.GetParameterAsText(0)
&amp;nbsp;&amp;nbsp;&amp;nbsp; main(layer)
&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;The only other issue I can think of it being is something wonky with your 2.7 install and arcpy not playing nicely.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 18:32:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/transportation-questions/spatial-reference-grab-not-working/m-p/407740#M1364</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2021-12-11T18:32:21Z</dc:date>
    </item>
    <item>
      <title>Re: Spatial Reference grab not working...</title>
      <link>https://community.esri.com/t5/transportation-questions/spatial-reference-grab-not-working/m-p/407741#M1365</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Original User: SStrand&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;&lt;BR /&gt;The only other issue I can think of it being is something wonky with your 2.7 install and arcpy not playing nicely.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I'll try it out on another computer here and see how it goes.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Feb 2013 21:05:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/transportation-questions/spatial-reference-grab-not-working/m-p/407741#M1365</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2013-02-27T21:05:43Z</dc:date>
    </item>
    <item>
      <title>Re: Spatial Reference grab not working...</title>
      <link>https://community.esri.com/t5/transportation-questions/spatial-reference-grab-not-working/m-p/407742#M1366</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Original User: SStrand&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So the other computer I have access to here is running 10.1 so I'm not sure if that is a major issue. It shouldn't be in regards to what I am doing.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Running the script on 10.1, it still fails in the same spot but I get a real error!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Traceback (most recent call last)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; File KSDE_SystemlayersAGS10_Layers_LayerCreation.py, line 139, in module&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; spatialdesc = arcpy.Describe(newlayer)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; File cprogram filesarcgisdesktop10.1arcpyarcpy__init__.py, line 1200, in Describe&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return gp.describe(value)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; File cprogram filesarcgisdesktop10.1arcpyarcpygeoprocessing_base.py, line 374, in describe&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; self._gp.Describe(gp_fixargs(args, True)))&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;IOError AnnexationAreas_SOI does not exist&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Failed to execute (LayerCreation).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;AnnexationAreas_SOI&lt;/STRONG&gt;&lt;SPAN&gt; is the file I am testing the script with.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Feb 2013 21:18:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/transportation-questions/spatial-reference-grab-not-working/m-p/407742#M1366</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2013-02-27T21:18:32Z</dc:date>
    </item>
    <item>
      <title>Re: Spatial Reference grab not working...</title>
      <link>https://community.esri.com/t5/transportation-questions/spatial-reference-grab-not-working/m-p/407743#M1367</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Check to see &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;exactly&lt;/SPAN&gt;&lt;SPAN&gt; what is getting passed. Repr() is very handy for this.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
arcpy.AddMessage("newlayer: " + repr(newlayer))
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;it sounds from your error message that "AnnexationAreas_SOI" is what got passed. If your script is running within the ArcMap context (ie as a script tool in Arcmap) the Describe should be able to identify that string as a layer and successfully find it and retrieve it's spatialReference. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If not, it's just a string and what you should have passed a dataset instead.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 18:32:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/transportation-questions/spatial-reference-grab-not-working/m-p/407743#M1367</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2021-12-11T18:32:24Z</dc:date>
    </item>
  </channel>
</rss>

