Hello developer,
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?
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;IsHighPrecisi
on
None
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.
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
Solved! Go to Solution.
change,
print wkt
To
return wkt # Return the WKT string instead of printing it
def describeFileWKT(filepath):
desc = arcpy.Describe(filepath)
spatialRef = desc.spatialReference
wkt = spatialRef.exportToString()
return wkt
change,
print wkt
To
return wkt # Return the WKT string instead of printing it
def describeFileWKT(filepath):
desc = arcpy.Describe(filepath)
spatialRef = desc.spatialReference
wkt = spatialRef.exportToString()
return wkt