arcpy.Describe.PixelType returns useless value

646
1
12-03-2015 06:11 AM
Status: Open
DavidJames
New Contributor III
in a Python window in ArcGIS 10.3.1...using arcpy.Describe on a raster will yield an appropriate value for the raster format...'S32'...which stands for 32_BIT_SIGNED. The returned value is NOT a valid value for use in other commands, such as CopyRaster, which require the quoted string -- "32_BIT_SIGNED".  

Please...change Describe or change the commnads to honor the returned Describe value. Left hand, right hand, meet each other!


>>> PxT = arcpy.Describe("ec3m070802080201").PixelType

>>> PxT
u'S32'

>>> arcpy.CopyRaster_management("ec3m070802080201", "newRas", "","","","","",PxT)
    Runtime error  Traceback (most recent call last):   
    File "<string>", line 1, in <module>   
    File "c:\program files (x86)\arcgis\desktop10.3\arcpy\arcpy\management.py", 
    line 12583, in CopyRaster raise e ExecuteError: ERROR 000800: 
      The value is not a member of 
       1_BIT | 2_BIT | 4_BIT | 8_BIT_UNSIGNED | 
       8_BIT_SIGNED | 16_BIT_UNSIGNED | 
       16_BIT_SIGNED | 32_BIT_UNSIGNED | 
       32_BIT_SIGNED | 32_BIT_FLOAT | 64_BIT.  

>>> arcpy.CopyRaster_management("ec3m070802080201", "newRas", "","","","","","32_BIT_SIGNED")
<Result 'D:\\Data\\ArcGISdefaults\\MyDefault.gdb\\newRas'>
1 Comment
Luke_Pinner

Workaround:

pixel_types = {
"U1": "1_BIT",
"U2": "2_BIT",
"U4": "4_BIT",
"S8": "8_BIT_SIGNED",
"U8": "8_BIT_UNSIGNED",
"S16": "16_BIT_UNSIGNED",
"U16": "16_BIT_SIGNED",
"S32": "32_BIT_UNSIGNED",
"U32": "32_BIT_SIGNED",
"F32": "32_BIT_FLOAT",
"F64": "64_BIT"
}

pixel_type = pixel_types[arcpy.Describe("raster").PixelType]
# or
pixel_type = pixel_types[arcpy.da.Describe("raster")["PixelType"]]