Polygon to Raster (Conversion)

License Level:BasicStandardAdvanced

Summary

Converts polygon features to a raster dataset.

Learn how the Polygon to Raster tool works

Usage

Syntax

PolygonToRaster_conversion (in_features, value_field, out_rasterdataset, {cell_assignment}, {priority_field}, {cellsize})
ParameterExplanationData Type
in_features

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

Feature Layer
value_field

The field used to assign values to the output raster.

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

Field
out_rasterdataset

The output raster dataset to be created.

When not saving to a geodatabase, specify .tif for a TIFF file format, .img for an ERDAS IMAGINE file format, or no extension for an Esri Grid raster format.

Raster Dataset
cell_assignment
(Optional)

The method to determine how the cell will be assigned a value when more than one feature falls within a cell.

  • CELL_CENTERThe polygon which overlaps the center of the cell yields the attribute to assign to the cell.
  • MAXIMUM_AREAThe single feature with the largest area within the cell yields the attribute to assign to the cell.
  • MAXIMUM_COMBINED_AREA If there is more than one feature in a cell with the same value, the areas of these features will be combined. The combined feature with the largest area within the cell will determine the value to assign to the cell.
String
priority_field
(Optional)

This field is used to determine which feature should take preference over another feature with the same value in the Value field.

Field
cellsize
(Optional)

The cell size for the output raster dataset.

The default cell size is the shortest of the width or height of the extent of the input feature dataset, in the output spatial reference, divided by 250.

Analysis Cell Size

Code Sample

PolygonToRaster example 1 (Python window)

Converts polygon features to a raster dataset.

import arcpy
from arcpy import env
env.workspace = "c:/data"
arcpy.PolygonToRaster_conversion("ca_counties.shp", "NAME", 
                                 "c:/output/ca_counties.img", 
                                 "MAXIMUM_AREA", "MALES", 0.25)
PolygonToRaster example 2 (stand-alone script)

Converts polygon features to a raster dataset.

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

# Import system modules
import arcpy
from arcpy import env

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

# Set local variables
inFeatures = "ca_counties.shp"
valField = "NAME"
outRaster = "c:/output/ca_counties"
assignmentType = "MAXIMUM_AREA"
priorityField = "MALES"
cellSize = 0.5

# Execute PolygonToRaster
arcpy.PolygonToRaster_conversion(inFeatures, valField, outRaster, 
                                 assignmentType, priorityField, cellSize)

Environments

Related Topics

Licensing Information

ArcGIS for Desktop Basic: Requires Spatial Analyst or 3D Analyst
ArcGIS for Desktop Standard: Requires Spatial Analyst or 3D Analyst
ArcGIS for Desktop Advanced: Yes
10/24/2012