<?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: WKT, SpatialReference, and DefineProjection Problem in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/wkt-spatialreference-and-defineprojection-problem/m-p/1502803#M71010</link>
    <description>&lt;P&gt;change,&lt;/P&gt;&lt;P&gt;print wkt&lt;/P&gt;&lt;P&gt;To&lt;/P&gt;&lt;P&gt;return wkt # Return the WKT string instead of printing it&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;def describeFileWKT(filepath):
    desc = arcpy.Describe(filepath)
    spatialRef = desc.spatialReference
    wkt = spatialRef.exportToString()
    return wkt&lt;/LI-CODE&gt;</description>
    <pubDate>Mon, 08 Jul 2024 21:37:04 GMT</pubDate>
    <dc:creator>TonyAlmeida</dc:creator>
    <dc:date>2024-07-08T21:37:04Z</dc:date>
    <item>
      <title>WKT, SpatialReference, and DefineProjection Problem</title>
      <link>https://community.esri.com/t5/python-questions/wkt-spatialreference-and-defineprojection-problem/m-p/1502684#M71009</link>
      <description>&lt;P&gt;Hello developer,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Why when I use DefineProjection on DEM .tif files to manually set their spatial reference using a wkt string, "None" is added to the end of the string?&lt;/P&gt;&lt;P&gt;&lt;EM&gt;GEOGCS['GCS_WGS_1984',DATUM['D_WGS_1984',SPHEROID['WGS_1984',6378137.0,298.257223563]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]],VERTCS['EGM2008',VDATUM['EGM2008']&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;,PARAMETER['Vertical_Shift',0.0],PARAMETER['Direction',1.0],UNIT['Meter',1.0]];-400 -400 11258999068426.2;-100000 10000;-100000 10000;8.98315284119521E-09;0.001;0.001;IsHighPrecisi&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;on&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;None&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;Btw, the reason I am trying to manually change those spatial reference is because my DEM files have incomplete metadata ("unknown" for VDATUM) and I need to make it match my mosaic dataset's spatial reference.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;def describeFileWKT(filepath):
    desc = arcpy.Describe(filepath)
    spatialRef = desc.spatialReference
    wkt = spatialRef.exportToString()
    print(wkt)

wkt = """
GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],
PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],
VERTCS["EGM2008",VDATUM["EGM2008"],
PARAMETER["Vertical_Shift",0.0],PARAMETER["Direction",1.0],UNIT["Meter",1.0]];
-400 -400 11258999068426.2;-100000 10000;-100000 10000;8.98315284119521E-09;0.001;0.001;IsHighPrecision
"""
# sr = arcpy.SpatialReference(text=wkt)
sr = arcpy.SpatialReference()
sr.loadFromString(wkt)


print(sr.exportToString())  # The same wkt is printed
print

inputFolderPath = r"\\server\Input"
for name in os.listdir(inputFolderPath):
    path = os.path.join(inputFolderPath, name)
    if os.path.isfile(path) and (name.lower().endswith('.tif') or name.lower().endswith('.tiff')):  # Check if isn't a directory, and if is a TIF file
        arcpy.DefineProjection_management(path, sr)
        print("Adding " + name)
        print(describeFileWKT(path))  # wkt + new line + "None" is printed&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Jul 2024 19:00:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/wkt-spatialreference-and-defineprojection-problem/m-p/1502684#M71009</guid>
      <dc:creator>oookokkookookk</dc:creator>
      <dc:date>2024-07-08T19:00:44Z</dc:date>
    </item>
    <item>
      <title>Re: WKT, SpatialReference, and DefineProjection Problem</title>
      <link>https://community.esri.com/t5/python-questions/wkt-spatialreference-and-defineprojection-problem/m-p/1502803#M71010</link>
      <description>&lt;P&gt;change,&lt;/P&gt;&lt;P&gt;print wkt&lt;/P&gt;&lt;P&gt;To&lt;/P&gt;&lt;P&gt;return wkt # Return the WKT string instead of printing it&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;def describeFileWKT(filepath):
    desc = arcpy.Describe(filepath)
    spatialRef = desc.spatialReference
    wkt = spatialRef.exportToString()
    return wkt&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 08 Jul 2024 21:37:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/wkt-spatialreference-and-defineprojection-problem/m-p/1502803#M71010</guid>
      <dc:creator>TonyAlmeida</dc:creator>
      <dc:date>2024-07-08T21:37:04Z</dc:date>
    </item>
  </channel>
</rss>

