Available with Advanced license.
Summary
Converts polygon features to a raster dataset.
Usage
-
Any feature class (geodatabase, shapefile, or coverage) containing 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.
If the input field contains string values, the output raster will contain an integer value field and a string field.
However, if the field is of type floating point and the values are expressed as integers, then the output raster will be integer.
-
This tool is a complement to the Raster to Polygon tool, which converts a raster to a polygon feature class.
-
When more than one feature is present in an output cell, this tool provides greater control over the assignment of cell values than the Feature to Raster tool.
If stripes or bleeding occur in the output raster, use the Check Geometry and Repair Geometry tools to correct the input feature data.
When converting overlapping polygons, you may want the polygons with the smallest area to be assigned to a cell. An easy way to do this is to add an additional field to the input feature class and calculate it to the inverse area of the polygons; then use this field as the Priority field when running this tool.
Certain Raster storage environments may apply to this tool.
For the Pyramid environment settings, 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 by using the Build Pyramids tool.
For the Compression environment settings, only the type of compression may be honored. This is only for raster formats other than Esri Grid.
Syntax
PolygonToRaster_conversion (in_features, value_field, out_rasterdataset, {cell_assignment}, {priority_field}, {cellsize})
Parameter | Explanation | Data 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.
| String |
priority_field (Optional) | This field is used to determine which feature should take preference over another feature that falls over a cell. When it is used, the feature with the largest positive priority is always selected for conversion irrespective of the Cell assignment type chosen. | 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
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