Quantcast
Channel: Forums - Python
Viewing all articles
Browse latest Browse all 2485

Spatial Reference grab not working...

$
0
0
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.

First, the portion to write text to word (this works fine for all other instances in the script):

Code:

def search_replace_all(newword, find_str, replace_str):
    wdFindContinue = 1
    wdReplaceAll = 2
    app = win32com.client.Dispatch("Word.Application")
    app.Visible = 0
    app.DisplayAlerts = 0

    app.Documents.Open(newword)
    app.Selection.Find.Execute(find_str, False, False, False, False, False, \
        True, wdFindContinue, False, replace_str, wdReplaceAll)
    app.ActiveDocument.Close(SaveChanges=True)

    app.Quit()

search_replace_all(newword, olddate, newdate)

Here is the code that isn't working:

Code:

spatialdesc = arcpy.Describe(newlayer)
sr = spatialdesc.SpatialReference
newspatial = sr.Name

search_replace_all(newword, oldspatial, newspatial)

I've also seen this as/tried unsuccesfully in my code:


Code:

sr = arcpy.Describe(newlayer).spatialReference
newspatial = sr.name

search_replace_all(newword, oldspatial, newspatial)

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?

I am using ArcGIS 10.0 SP3, Windows 7, Python 2.7

Viewing all articles
Browse latest Browse all 2485

Trending Articles