Feature to Raster (Conversion)

Summary

Converts features to a raster dataset.

Usage

  • Any feature class (geodatabase, shapefile, or coverage) containing point, line, or polygon features can be converted to a raster dataset.

  • The input field type determines the type of output raster. If the field is integer, the output raster will be integer; if it is floating point, the output will be floating point.

  • The Output cell size can be defined by a numeric value or obtained from an existing raster dataset. If the cell size hasn’t been explicitly specified as the parameter value, it is derived from the environment Cell Size, if it has been specified. If neither the parameter cell size nor the environment cell size has been specified, but the environment Snap Raster has been set, the cell size of the snap raster is used. If nothing has been specified, the cell size is calculated from the shorter of the width or height of the extent divided by 250, where the extent is in the Output Coordinate System specified in the environment.

  • If the cell size has been specified using a numeric value, the tool will use it directly for the output raster.

    If the cell size has been specified using a raster dataset, the parameter will show the path of the raster dataset instead of the cell size value. The cell size of that raster dataset will be used directly in the analysis, provided the spatial reference of the dataset is the same as the output spatial reference. If the spatial reference of the dataset is different, it will be projected based on the selected Cell Size Projection Method.

  • This tool always uses the cell center to decide the value of a raster pixel. If more control is needed over how different types of input feature geometries are to be converted, refer to the respective specific conversion tools: Point to Raster, Polyline to Raster, and Polygon to Raster.

  • This tool is a complement to the Raster to Point, Raster to Polyline, and Raster to Polygon tools, which convert a raster to different types of feature dataset geometries.

  • When selecting the input feature data, the default field will be the first valid field available. If no other valid fields exist, the ObjectID field (for example, OID or FID) will be the default.

  • For data formats that support Null values, such as file geodatabase feature classes, a Null value will be ignored when used as input.

  • Certain raster storage environments may apply to this tool.

    • For the Pyramid environment, only the Build pyramids setting is honored. The remaining Pyramid environment settings are ignored. More control over the nature of the pyramids can be obtained in a subsequent step using the Build Pyramids tool.

    • For the Compression environment, only the type of compression may be honored. This is for raster formats other than Esri Grid.

Syntax

arcpy.conversion.FeatureToRaster(in_features, field, out_raster, {cell_size})
ParameterExplanationData Type
in_features

The input feature dataset to be converted to a raster dataset.

Feature Layer
field

The field used to assign values to the output raster.

It can be any field of the input feature dataset's attribute table.

If the Shape field of a point or multipoint dataset contains z- or m-values, either of these can be used.

Field
out_raster

The output raster dataset to be created.

If the output raster will not be saved to a geodatabase, specify .tif for TIFF file format, .CRF for CRF file format, .img for ERDAS IMAGINE file format, or no extension for Esri Grid raster format.

Raster Dataset
cell_size
(Optional)

The cell size of the output raster being created.

This parameter can be defined by a numeric value or obtained from an existing raster dataset. If the cell size hasn’t been explicitly specified as the parameter value, the environment cell size value is used, if specified; otherwise, additional rules are used to calculate it from the other inputs. See Usages for more detail.

Analysis Cell Size

Code sample

FeatureToRaster example 1 (Python window)

Converts features to a raster dataset.

import arcpy
from arcpy import env
env.workspace = "c:/data"
arcpy.FeatureToRaster_conversion("roads.shp", "CLASS", "c:/output/roadsgrid", 25)
FeatureToRaster example 2 (stand-alone script)

Converts features to a raster dataset.

# Name: FeatureToRaster_Ex_02.py
# Description: Converts features to a raster dataset.

# Import system modules
import arcpy
from arcpy import env

# Set environment settings
env.workspace = "C:/data"

# Set local variables
inFeature = "roads.shp"
outRaster = "c:/output/roadsgrd"
cellSize = 25
field = "CLASS"

# Execute FeatureToRaster
arcpy.FeatureToRaster_conversion(inFeature, field, outRaster, cellSize)

Licensing information

  • Basic: Yes
  • Standard: Yes
  • Advanced: Yes

Related topics