Raster

Summary

Creates a raster object that can be used in Python scripting or in a Map Algebra expression. A raster object is a variable that references a raster dataset.

A raster object can be created in three ways, by supplying the path to an existing raster on disk, by supplying a RasterInfo object, or it can be the result of any Map Algebra statement that results in a raster output.

License:

Either an ArcGIS Spatial Analyst extension or an ArcGIS Image Analyst extension is necessary to execute Map Algebra statements.

Discussion

The raster object created from existing data can be used in subsequent Map Algebra expressions and will have all the associated raster properties and methods.

# out_raster is a resultant raster object
out_raster = Raster("c:/data/inraster")

Any tool or operator (see Working with operators in Map Algebra) that produces an output raster to the left of the equal sign creates a raster object. For example, in the following expression, out_raster is a raster object.

out_raster = Slope("inelevation")

When a Raster object is returned from a Map Algebra expression, by default, the object (the variable and associated dataset) is temporary.

The temporary dataset associated with a raster object can become permanent by calling the raster object's save method.

If the referenced raster is not made permanent, the variable and the referenced raster dataset will be deleted when the variable goes out of scope, such as when a stand-alone script completes or ArcGIS is closed. When a raster object references permanent data on disk, the data is not deleted.

Certain operators exist in both Map Algebra and in Python. If you want an operator to work on a raster (as opposed to a scalar), the input rasters must be cast as a raster object by calling the Raster class constructor: Raster("inRaster").

# The plus operator (available with Spatial Analyst or Image Analyst) is
# used on the input rasters to create an output raster object
out_raster = Raster("input1") + Raster("input2") 
																																												
# The Python plus operator is used on numbers, creating a scalar variable
out_var = 4 + 7 

# When there is a mix of rasters with numbers, the Spatial Analyst
# operator is used, creating an output raster object
out_raster = Raster("input") + 10

Certain properties associated with the raster object are only available if the referenced raster dataset is permanent. When the referenced raster dataset is temporary, these properties will be assigned a value of None. The affected properties are catalogPath, compressionType, format, hasRAT, name, and path.

Once permanent, the referenced raster dataset cannot return to the temporary state.

When a raster object is created by supplying the path to an existing raster on disk, its readOnly property is True by default and its cell values can be read using the [row, column] index notation.

in_raster = Raster('c:/data/inraster')

# Read the cell value at the second row and third column
v = in_raster[1, 2]

When a raster object is created by supplying a RasterInfo object as input, it will create a temporary raster in the ArcGIS temp directory. The readOnly property of such a raster object is False by default and its cell values can be modified using the [row, column] index notation.

in_raster = Raster('c:/data/inraster')
raster_info = in_raster.getRasterInfo()
new_raster = Raster(raster_info)  # Create a new raster

# Modify the cell value at the second row and third column
new_raster[1, 2] = 3
new_raster.save('c:/output/outraster1')

In a RasterCellIterator loop, Raster objects are used to read and write data at cell level using the [row, column] index notation.

Syntax

 Raster (inRaster, {is_multidimensional})
ParameterExplanationData Type
inRaster
[inRaster,...]

The input raster dataset or list of raster datasets.

When multiple multidimensional raster datasets are provided, the files will be interpreted as a single multidimensional dataset, with variables and dimensions unioned together. If two files contain the same variable with the same dimension values, the slices in the output raster will come from the first multidimensional raster in the list.

You can also specify a RasterInfo object as the input inRaster, which will create a new raster dataset on disk. In this case, the is_multidimensional input parameter will be ignored.

Raster
is_multidimensional

Determines whether the input raster will be treated as multidimensional. Specify True if the input is multidimensional and should be processed as multidimensional, where processing occurs for every slice in the dataset. Specify False if the input is not multidimensional, or if it is multidimensional and should not be processed as multidimensional.

(The default value is False)

Boolean

Properties

PropertyExplanationData Type
bandCount
(Read Only)

The number of bands in the referenced raster dataset.

Integer
bandNames
(Read Only)

The band names in the referenced raster dataset.

String
blockSize
(Read Only)

The block size of the referenced raster dataset.

tuple
catalogPath
(Read Only)

The full path and the name of the referenced raster dataset.

String
compressionType
(Read Only)

The compression type. The following are the available types:

  • LZ77
  • JPEG
  • JPEG 2000
  • PACKBITS
  • LZW
  • RLE
  • CCITT GROUP 3
  • CCITT GROUP 4
  • CCITT (1D)
  • None

String
extent
(Read Only)

The extent of the referenced raster dataset.

Extent
format
(Read Only)

The raster format.

  • BIL—Esri Band Interleaved by Line file
  • BIP—Esri Band Interleaved by Pixel file
  • BMP—Bitmap graphic raster dataset format
  • BSQ—Esri Band Sequential file
  • DAT—ENVI DAT file
  • GIF—Graphic Interchange Format for raster datasets
  • Grid—Esri Grid raster dataset format
  • IMAGINE Image—ERDAS IMAGINE raster data format
  • JP2000—JPEG 2000 raster dataset format
  • JPEG—Joint Photographic Experts Group raster dataset format
  • PNG—Portable Network Graphic raster dataset format
  • TIFF—Tag Image File Format for raster datasets

String
hasRAT
(Read and Write)

Identifies whether there is an associated attribute table: True if an attribute table exists, or False if no attribute table exists.

Boolean
hasTranspose
(Read and Write)

Identifies whether there is a transposed version of the multidimensional data associated with the raster: True if there is an associated transpose, False if no transpose exists.

Boolean
height
(Read Only)

The number of rows.

Integer
isInteger
(Read Only)

True if the raster dataset has an integer type.

Boolean
isMultidimensional
(Read Only)

True if the raster dataset is multidimensional.

Boolean
isTemporary
(Read Only)

True if the raster dataset is temporary, or False if it is permanent.

Boolean
maximum
(Read Only)

The maximum value in the referenced raster dataset.

Double
mean
(Read Only)

The mean value in the referenced raster dataset.

Double
meanCellHeight
(Read Only)

The cell size in the y direction.

Double
meanCellWidth
(Read Only)

The cell size in the x direction.

Double
minimum
(Read Only)

The minimum value in the referenced raster dataset.

Double
mdinfo
(Read Only)

The multidimensional information of the raster dataset, including variable names, descriptions and units, and dimension names, units, intervals, units, and ranges. For example, a multidimensional raster containing monthly temperature data over 10 months would return the following: {"variables": [{"name":"Temp", "dimensions":[{"name":"StdTime", "field":"StdTime", "hasRegularIntervals":true, "interval":1, "intervalUnit":"Months", "extent":["1982-01-15T00:00:00", "1982-10-15T00:00:00"], "hasRanges":false,"values":["1982-01-15T00:00:00", "1982-02-15T00:00:00, ... "1982-10-15T00:00:00"]}]}], "layout":1}

If the raster is not a multidimensional raster, this property returns None.

String
name
(Read Only)

The name of the referenced raster dataset.

String
noDataValue
(Read Only)

The NoData value of the referenced raster dataset.

Double
noDataValues
(Read Only)

The NoData value for each band in the referenced multiband raster dataset.

tuple
path
(Read Only)

The full path of the referenced raster dataset.

String
pixelType
(Read Only)

The pixel type of the referenced raster dataset. The types are the following:

  • U1—1 bit
  • U2—2 bits
  • U4—4 bits
  • U8—Unsigned 8-bit integers
  • S8—8-bit integers
  • U16—Unsigned 16-bit integers
  • S16—16-bit integers
  • U32—Unsigned 32-bit integers
  • S32—32-bit integers
  • F32—Single-precision floating point
  • F64—Double-precision floating point

String
properties
(Read Only)

The property name and value pairs in the referenced raster dataset.

Dictionary
RAT
(Read Only)

The attribute table of the referenced raster dataset. For example, the attribute table for a raster dataset with two classes will return {'OID': [0, 1], 'Value': [10, 20], 'ClassName': ['Low', 'High'], 'Red': [178, 56], 'Green': [178, 168], 'Blue': [178, 0], 'Alpha': [255, 255], 'Count': [887412.0, 962159.0]}. If the raster is multidimensional, there will be a Count field for each slice in the dataset.

If no attribute table exists, None is returned.

Dictionary
readOnly
(Read and Write)

Whether the raster cell values are writable using the [row, column] notation. When this property is True, they are not writable. Otherwise, they are writable.

Boolean
slices
(Read Only)

The attribute information of each slice, including its variable name, dimension names, and dimension values returned as a list of dictionaries. For example, a multidimensional raster containing temperature data over 24 months would return the following: [{'variable': 'temp', 'StdTime': '2017-1-15'}, {'variable': 'temp', 'StdTime': '2017-2-15'}, .....{'variable': 'temp', 'StdTime': '2018-12-15'}]

String
spatialReference
(Read Only)

The spatial reference of the referenced raster dataset.

SpatialReference
standardDeviation
(Read Only)

The standard deviation of the values in the referenced raster dataset.

Double
uncompressedSize
(Read Only)

The size of the referenced raster dataset on disk.

Double
variables
(Read Only)

The variable names and their dimensions in the multidimensional raster dataset. For example, a multidimensional raster containing temperature data over 24 months would return the following: ['temp(StdTime=24)']

String
variableNames
(Read Only)

The variable names in the multidimensional raster dataset.

String
width
(Read Only)

The number of columns.

Integer

Method Overview

MethodExplanation
addDimension (variable, new_dimension_name, dimension_value, {dimension_attributes})

Adds a new dimension to a variable in a multidimensional raster object so that the multidimensional raster can be compatible with other multidimensional datasets.

appendSlices (mdRaster)

Appends the slices from another multidimensional raster.

exportImage ({width}, {height}, {format}, {extent}, {spatial_reference}, {mosaic_rule})

Exports the raster object as an IPython Image object to be used for visualization in Jupyter Notebook.

getColormap ({variable_name})

Returns the color map of the raster. If the raster is multidimensional, returns the color map of a variable.

getDimensionAttributes (variable_name, dimension_name)

Returns the attribute information of a dimension for a specific variable in a multidimensional raster dataset, for example, description, unit, and so on.

getDimensionNames (variable_name)

Returns the dimension names associated with a variable in a multidimensional raster dataset.

getDimensionValues (variable_name, dimension_name)

Returns the values of a dimension associated with a variable in a multidimensional raster dataset.

getHistograms ({variable_name})

Returns the histograms of the raster. If the raster is multidimensional, it returns the histogram of a variable. If the raster is multiband, it returns the histogram of each band.

getProperty (property_name)

Returns the value of the given property.

getRasterBands ({band_ids_or_names})

Returns a Raster object for each band specified in a multiband raster dataset.

getRasterInfo ()

Returns a RasterInfo object whose properties are initialized using the raster object properties.

getStatistics ({variable_name})

Returns the statistics of the raster. If the raster is multidimensional, returns the statistics of a variable.

getVariableAttributes (variable_name)

Returns the attribute information of a variable in a multidimensional raster dataset (for example, description, unit, and so on).

read ({upper_left_corner}, {origin_coordinate}, {ncols}, {nrows}, {nodata_to_value}, {cell_size})

Reads a raster and converts the raster to a NumPy array.

removeVariables (variable_names)

Removes a variable or a list of variables from a Cloud Raster Format (CRF) multidimensional raster dataset.

renameVariable (current_variable_name, new_variable_name)

Renames a variable in a Cloud Raster Format (CRF) multidimensional raster dataset.

save ({name})

Permanently saves the dataset referenced by the raster object.

setColormap (color_map, {variable_name})

Sets the color map for the raster. If the raster is multidimensional, it sets the color map for a variable.

setHistograms (histogram_obj, {variable_name})

Sets the histograms of the raster. If the raster is multidimensional, sets the histogram of a variable.

setProperty (property_name, property_value)

Add a customized property to the raster dataset.

If the property name exists, the existing property value will be overwritten.

setStatistics (statistics_obj, {variable_name})

Sets the statistics for the raster. If the raster is multiband, it sets the statistics for each band. If the raster is multidimensional, it sets the statistics for a variable.

setVariableAttributes (variable_name, variable_attributes)

Sets the attribute information of a variable in a multidimensional raster (for example, description, unit, and so on).

write (array, {upper_left_corner}, {origin_coordinate}, {value_to_nodata})

Converts a three- or four-dimensional NumPy array to a raster.

Methods

addDimension (variable, new_dimension_name, dimension_value, {dimension_attributes})
ParameterExplanationData Type
variable

The name of the variable to which the dimension will be added. Only multidimensional rasters in Cloud Raster Format (.crf) are supported.

String
new_dimension_name

The name of the new dimension.

String
dimension_value

The value to assign to the new dimension.

Only one value can be added, as more values (for example, multiple depths) would require new slices to be added to the dataset. To add more than one dimension value along with the new slices, use the addDimension method, then use the Merge function to merge existing data with the raster object.

Double
dimension_attributes

A Python dictionary that contains attribute information to be added to the new dimension, such as description or unit. For example, to add a unit attribute, use {"unit": "meters"}.

(The default value is None)

Dictionary
Return Value
Data TypeExplanation
String

The list of variable names and the corresponding dimensions of the multidimensional raster.

appendSlices (mdRaster)
ParameterExplanationData Type
mdRaster

The multidimensional raster containing the slices to be appended.

This raster must have the same variables, with the same dimension names, as the target raster. The cell sizes, extents, and spatial reference systems must also match.

The slices in this raster must be for dimension values that follow the dimension values of the slices in the target raster.

If a variable has two dimensions, slices will be appended along one dimension. The other dimension must have the same number of slices as the dimension in the target raster. For example, if a salinity variable contains slices over time and depth dimensions, time slices can be appended to another salinity multidimensional raster but only if the same number of depth slices exist in both rasters.

Raster
Return Value
Data TypeExplanation
String

A string containing the variable names and the associated dimensions in the multidimensional raster. For example, if the resulting raster has 10 time slices with precipitation data, it will return 'prcp(StdTime=10)'.

exportImage ({width}, {height}, {format}, {extent}, {spatial_reference}, {mosaic_rule})
ParameterExplanationData Type
width

The width of the output image in pixels. If a value is not specified, but the height is provided, the aspect ratio of the original raster will be maintained. If neither width nor height are specified, the width of the original raster dataset will be used.

(The default value is None)

Integer
height

The height of the output image in pixels. If a value is not specified, but the width is provided, the aspect ratio of the original raster will be maintained. If neither width nor height are specified, the height of the original raster dataset will be used.

(The default value is None)

Integer
format

The image format of the exported data. The supported formats include JPG, PNG, and PNG32.

(The default value is PNG32)

String
extent

The extent or bounding box of the exported image. If a value is not specified, the extent of the raster dataset is used.

(The default value is None)

Extent
spatial_reference

The spatial reference of the exported image. If a value is not specified, the spatial reference of the raster dataset is used.

(The default value is None)

SpatialReference
mosaic_rule

Specifies how the input raster data should be mosaicked. This is applicable when the input raster dataset is a mosaic dataset. For information on how to format the mosaic rule, see Mosaic rule objects.

(The default value is None)

Dictionary
Return Value
Data TypeExplanation
Object

The exported image as an IPython Image object.

getColormap ({variable_name})
ParameterExplanationData Type
variable_name

The variable name of the multidimensional raster dataset. If a variable is not specified and the raster is multidimensional, the color map of the first variable will be returned.

String
Return Value
Data TypeExplanation
Dictionary

A Python dictionary containing the color map of the raster or variable. Pixel values are listed first, followed by the corresponding color map values in HEX color codes—for example, {'type': 'RasterColormap', 'values': [10, 20, 30], 'colors': ['#66FF33', '#0033CC', '#FF00FF']}.

getDimensionAttributes (variable_name, dimension_name)
ParameterExplanationData Type
variable_name

The variable name of the multidimensional raster dataset.

String
dimension_name

The dimension name of the multidimensional raster dataset.

String
Return Value
Data TypeExplanation
String

The attribute information of the dimension, for example, the minimum and maximum dimension values, the time step interval, and the interval units.

getDimensionNames (variable_name)
ParameterExplanationData Type
variable_name

The variable name of the multidimensional raster dataset.

String
Return Value
Data TypeExplanation
String

The dimension names associated with the variable.

getDimensionValues (variable_name, dimension_name)
ParameterExplanationData Type
variable_name

The variable name of the multidimensional raster dataset.

String
dimension_name

The dimension name of the multidimensional raster dataset.

String
Return Value
Data TypeExplanation
String

The dimension values of the variable.

getHistograms ({variable_name})
ParameterExplanationData Type
variable_name

The variable name of the multidimensional raster dataset. If a variable is not specified and the raster is multidimensional, the histogram of the first variable will be returned.

String
Return Value
Data TypeExplanation
Dictionary

The histogram values of the raster or variable—for example, [{'size': 10, 'min': 0.0, 'max': 364.0, 'counts': [882.0, 18.0, 9.0, 0.0, 9.0, 0.0, 18.0, 9.0, 18.0, 0.0]}].

getProperty (property_name)
ParameterExplanationData Type
property_name

The property name of the raster dataset.

String
Return Value
Data TypeExplanation
String

The value of the property.

getRasterBands ({band_ids_or_names})
ParameterExplanationData Type
band_ids_or_names
[band_ids_or_names,...]

The index number or names of the bands to return as Raster objects. If not specified, all bands will be extracted.

(The default value is None)

String
Return Value
Data TypeExplanation
Raster

The Raster object for each band specified.

getRasterInfo ()
Return Value
Data TypeExplanation
Object

A RasterInfo object.

getStatistics ({variable_name})
ParameterExplanationData Type
variable_name

The variable name of the multidimensional raster dataset. If a variable is not specified and the raster is multidimensional, the statistics of the first variable will be returned.

String
Return Value
Data TypeExplanation
Dictionary

The statistics of the raster or variable.

getVariableAttributes (variable_name)
ParameterExplanationData Type
variable_name

The variable name of the multidimensional raster dataset.

String
Return Value
Data TypeExplanation
String

The attribute information of the variable.

read ({upper_left_corner}, {origin_coordinate}, {ncols}, {nrows}, {nodata_to_value}, {cell_size})
ParameterExplanationData Type
upper_left_corner

The coordinates relative to the origin_coordinate from which to extract the processing block to convert to an array. This should be formatted as a tuple with two values indicating the direction to move in the x- and y-direction, respectively. For example, a value of (2,0) indicates that the array should be extracted starting at the pixel that is two pixels away, in the x-direction, from the origin_coordinate.

If no value is specified, (0,0) is used.

(The default value is None)

tuple
origin_coordinate

The point of origin within the Raster object from which to extract the processing block to convert to an array. The coordinates must be in the units of the raster.

If no value is specified, the origin of the raster will be used.

(The default value is None)

Point
ncols

The number of columns from the upper_left_corner in the Raster object to convert to the NumPy array.

If no value is specified, the number of columns of the raster will be used.

(The default value is None)

Integer
nrows

The number of rows from the upper_left_corner in the Raster object to convert to the NumPy array.

If no value is specified, the number of rows of the raster will be used.

(The default value is None)

Integer
nodata_to_value

The pixel value to assign in the NumPy array for those pixels labeled as NoData in the Raster object.

If no value is specified, the NoData value of the raster will be used.

(The default value is None)

Variant
cell_size

The cell size to use in the NumPy array. This should be formatted as a tuple with two values indicating the cell size in the x- and y-direction, respectively, and units should match those used by the raster. For example, a value of (2, 1) indicates the output cell size should be 2 units in the x-direction and 1 unit in the y-direction. If the cell size is different from the data source, the cell values are resampled using bilinear interpolation.

If no value is specified, the cell size of the raster will be used.

(The default value is None)

tuple
Return Value
Data TypeExplanation
NumPyArray

The output NumPy array.

If the raster is a single- or multiband raster, the dimensions of the array will be rows, columns, and number of bands.

If the raster is a multidimensional raster, the dimensions of the array will be number of slices, rows, columns, and number of bands.

removeVariables (variable_names)
ParameterExplanationData Type
variable_names
[variable_names,...]

The variable name or a list of variable names to be removed from the multidimensional raster dataset.

String
renameVariable (current_variable_name, new_variable_name)
ParameterExplanationData Type
current_variable_name

The current name of the variable in a multidimensional raster dataset.

String
new_variable_name

The new name of the variable in a multidimensional raster dataset.

String
save ({name})
ParameterExplanationData Type
name

The name to assign to the raster dataset on disk.

This method supports persisting a multidimensional raster dataset as Cloud Raster Format (CRF).

String
setColormap (color_map, {variable_name})
ParameterExplanationData Type
color_map

The color map to apply to the raster. This can be a string indicating the name of the color map or color ramp to use, for example, NDVI or Yellow To Red, respectively. This can also be a Python dictionary with a custom color map or color ramp object—for example, a custom color map {'values': [0, 1, 2, 3, 4, 5], 'colors': ['#000000', '#DCFFDF', '#B8FFBE', '#85FF90', '#50FF60','#00AB10']} or a custom color ramp {"type": "algorithmic", "fromColor": [115, 76, 0, 255],"toColor": [255, 25, 86, 255], "algorithm": "esriHSVAlgorithm"}.

String
variable_name

The variable name of the multidimensional raster dataset. If a variable is not specified and the raster is multidimensional, the color map of the first variable will be set.

String
setHistograms (histogram_obj, {variable_name})
ParameterExplanationData Type
histogram_obj
[histogram_obj,...]

A list of Python dictionaries containing histogram information to be set—for example, [{'size': 5, 'min': 19.0, 'max': 42.0, 'counts': [275, 17, 3065, 4, 22]}].

If the raster is multiband, the histogram for each band will be set with each dictionary in the list. The first band will use the histogram in the first dictionary. The second band will use the histogram in the second dictionary, and so on.

  • sizeThe number of bins in the histogram
  • minThe minimum pixel value
  • maxThe maximum pixel value
  • countsA list containing the number of pixels in each bin, in the order of bins
Dictionary
variable_name

The variable name of the multidimensional raster dataset. If a variable is not specified and the raster is multidimensional, the histogram will be set for the first variable.

String
setProperty (property_name, property_value)
ParameterExplanationData Type
property_name

The property name of the raster dataset.

String
property_value

The value to assign to the property.

String
setStatistics (statistics_obj, {variable_name})
ParameterExplanationData Type
statistics_obj
[statistics_obj,...]

A list of Python dictionaries containing statistics and corresponding values to set. For example, [{'min': 10, 'max': 20}] sets the minimum and maximum pixel values.

If the raster is multiband, the statistics for each band will be set with each dictionary in the list. The first band will use the statistics in the first dictionary. The second band will use the statistics in the second dictionary, and so on.

  • minThe minimum pixel value
  • maxThe maximum pixel value
  • meanThe mean pixel value
  • medianThe median pixel value
  • standardDeviationThe standard deviation of the pixel values
  • countThe total number of pixels
  • skipXThe horizontal skip factor
  • skipYThe vertical skip factor
List
variable_name

The variable name of the multidimensional raster dataset. If a variable is not specified and the raster is multidimensional, the statistics of the first variable will be set.

String
setVariableAttributes (variable_name, variable_attributes)
ParameterExplanationData Type
variable_name

The variable name of the multidimensional raster dataset.

String
variable_attributes

A Python dictionary that contains attribute information to replace the current attribute information of the variable—for example, {'Description': 'Daily total precipitation', 'Unit': 'mm/day'}.

Dictionary
Return Value
Data TypeExplanation
String

The attribute information of the variable.

write (array, {upper_left_corner}, {origin_coordinate}, {value_to_nodata})
ParameterExplanationData Type
array

The input NumPy array.

(The default value is None)

NumPyArray
upper_left_corner

The coordinates relative to the origin_coordinate from which to extract the processing block to convert to a raster. This should be formatted as a tuple with two values indicating the number of pixels to move along the x- and y- direction, respectively. For example, (2,0), indicates that the position from which the NumPy array will be written into the raster is 2 pixels away, in the x-direction, from the origin_coordinate.

If no value is specified, (0,0) is used.

(The default value is None)

tuple
origin_coordinate

A Point object defining the origin, from which the numpy array will be written into the Raster. The x- and y-values are in th units of the raster. If no value is specified, the upper left corner of the raster, will be used.

If no value is specified, the origin of the raster will be used. This is the default.

(The default value is None)

Point
value_to_nodata

A value in the NumPy array to be used as the NoData value in the Raster. The value can be an integer or a float. If no value is specified, the NoData value of the Raster will be used.

The default value is None.

(The default value is None)

Double

If the raster is a single-band raster, the dimensions of the array must be rows, columns, 1.

If the raster is a multiband raster, the dimensions of the array must be rows, columns, band count.

If the raster is a multidimensional raster, in which each slice is single band, the dimensions of the array must be number of slices, rows, columns, 1.

If the raster is a multidimensional raster, in which each slice is multiband, the dimensions of the array must be number of slices, rows, columns, band count.

Code sample

Raster example 1

Creates a Raster object from a raster dataset and gets properties for analysis.

import arcpy

my_raster = arcpy.Raster('elevation')
my_min = my_raster.minimum
my_max = my_raster.maximum
my_area = (my_raster.width * my_raster.height) * my_raster.meanCellWidth
Raster example 2

Creates a Raster object, gets properties, creates a random error raster (+/- 3 feet), adds it to an elevation raster, and converts its units from feet to meters.

import arcpy
from arcpy.sa import *

elev_raster = Raster('c:/data/elevation')
my_extent = elev_raster.extent
my_cellsize = (elev_raster.meanCellHeight + elev_raster.meanCellWidth) / 2
res01 = arcpy.CreateRandomRaster_management("", "error3", "UNIFORM 0.0 3.0",
                                            my_extent, my_cellsize)
elev_meters = (elev_raster + Raster(res01)) * 0.3048
elev_meters.save("c:/output/fgdb.gdb/elevM_err")
Raster example 3

Creates a Raster object from a multidimensional raster dataset, gets multidimensional information including variables and dimension values.

import arcpy

## Load a netCDF file as a multidimensional raster
mdim_raster = Raster("Precip_2000_2018.nc", True)

## Check if it is multidimensional raster
is_multidimensional = mdim_raster.isMultidimensional

## Return the multidimensional information 
my_mdinfo = mdim_raster.mdinfo

## Return the list of variable names and their dimensions
my_variables = mdim_raster.variables

## Get the time dimension values for the precipitation variable
my_dimensionValues = mdim_raster.getDimensionValues("precip", "StdTime")

# save as a mdim crf
mdim_raster.save("c:/output/Precip_18_yr.crf")