Layer Info#
Describe#
The Describe function returns a Describe object. The output contains properties such as data type, fields, indexes, and many others. Its properties are dynamic, meaning that depending on what data type is described, different properties will be available.
First, create the object:
import arcpy
layer = r"C:\Temp\layer"
desc = arcpy.Describe(layer)
Then access the object properties with different methods:
File Properties#
Property |
Description |
|---|---|
|
The file path |
|
The file name |
|
The file extension |
|
The type of the element |
|
The spatial reference |
|
The code of spatial reference |
Layer Properties#
Property |
Description |
|---|---|
|
Polygon, Polyline, Point, MultiPoint, MultiPatch |
|
FeatureClass, RasterDataset, Table, Toolbox, etc. |
|
The extent object |
Raster Properties#
Property |
Description |
|---|---|
|
The number of rows |
|
The number of columns |
|
The cell size in Y direction |
|
The cell size in X direction |
|
The NoData value of the raster band |
|
The pixel type: U1 (1 bit), U2 (2 bits), U4 (4 bits), U8 (unsigned 8-bit), S8 (signed 8-bit), U16 (unsigned 16-bit), S16 (signed 16-bit), U32 (unsigned 32-bit), S32 (signed 32-bit), F32 (single precision float), F64 (double precision float) |
|
The number of bands in the raster dataset |
|
The raster format: GRID, ERDAS IMAGINE, TIFF |
Raster Properties#
The GetRasterProperties function returns properties of a raster dataset. The Python result always returns a geoprocessing object. To obtain the actual string value, use result.getOutput(0).
arcpy.GetRasterProperties_management(in_raster, "{property_type}")
Property Types#
Property |
Description |
|---|---|
|
Returns the largest value of all cells in the input raster |
|
Returns the smallest value of all cells in the input raster |
|
The mean value of all cells |
|
The standard deviation value of all cells |
|
The number of unique values |
|
Returns 1 (True) or 0 (False) if the raster has only NoData values |
|
The pixel type: 0=1-bit, 1=2-bit, 2=4-bit, 3=8-bit unsigned, 4=8-bit signed, 5=16-bit unsigned, 6=16-bit signed, 7=32-bit unsigned, 8=32-bit signed, 9=32-bit float, 10=64-bit double, 11=8-bit complex, 12=64-bit complex, 13=16-bit complex, 14=32-bit complex |
|
Returns the top (YMax), left (XMin), right (XMax), or bottom (YMin) value of the extent |
|
Returns the cell size in the X/Y direction |
|
Returns the number of rows/columns in the input raster |
|
Returns the number of bands in the input raster |
>>> elevSTD = arcpy.GetRasterProperties_management("c:/data/elevation", "STD")
>>> elevSTD.getOutput(0)
u'246.54'
Cell Value#
The GetCellValue_management function retrieves the pixel value at a specific X,Y coordinate and (optionally) band.
arcpy.GetCellValue_management(in_raster, xy_point, {band})
>>> pixval = arcpy.GetCellValue_management("C:/data/clc.tif", "4496874 2448865")
>>> cellSize = pixval.getOutput(0)
u'12'