Polyline to Raster (Conversion)

Available with Advanced license.

Summary

Converts polyline features to a raster dataset.

Learn more about how the Polyline to Raster tool works

Usage

  • Any feature class (geodatabase, shapefile or coverage) containing polyline 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.

  • The Cellsize 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 is a complement to the Raster to Polyline tool, which converts a raster to a polyline 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.

  • 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.

Parameters

LabelExplanationData Type
Input Features

The polyline 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
Output Raster Dataset

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 assignment type
(Optional)

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

  • Maximum lengthThe feature with the longest length that covers the cell will determine the value to assign to the cell.
  • Maximum combined lengthIf there is more than one feature in a cell with the same value, the lengths of these features will be combined. The combined feature with the longest length 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 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 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
Build raster attribute table
(Optional)

Specifies whether the output raster will have a raster attribute table.

This parameter only applies to integer rasters.

  • Checked—The output raster will have a raster attribute table. This is the default.
  • Unchecked—The output raster will not have a raster attribute table.
Boolean

arcpy.conversion.PolylineToRaster(in_features, value_field, out_rasterdataset, {cell_assignment}, {priority_field}, {cellsize}, {build_rat})
NameExplanationData Type
in_features

The polyline 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.

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_assignment
(Optional)

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

  • MAXIMUM_LENGTHThe feature with the longest length that covers the cell will determine the value to assign to the cell.
  • MAXIMUM_COMBINED_LENGTHIf there is more than one feature in a cell with the same value, the lengths of these features will be combined. The combined feature with the longest length 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 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 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
build_rat
(Optional)

Specifies whether the output raster will have a raster attribute table.

This parameter only applies to integer rasters.

  • BUILDThe output raster will have a raster attribute table. This is the default.
  • DO_NOT_BUILDThe output raster will not have a raster attribute table.
Boolean

Code sample

PolylineToRaster example 1 (Python window)

Converts polyline features to a raster dataset.

import arcpy
arcpy.env.workspace = "c:/data"
arcpy.conversion.PolylineToRaster("roads.shp", "CLASS", "c:/output/roads.img",
                                  "MAXIMUM_COMBINED_LENGTH", "LENGTH", 30)
PolylineToRaster example 2 (stand-alone script)

Converts polyline features to a raster dataset.

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

# Import system modules
import arcpy

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

# Set local variables
inFeatures = "roads.shp"
valField = "CLASS"
outRaster = "c:/output/roads.tif"
assignmentType = "MAXIMUM_COMBINED_LENGTH"
priorityField = "LENGTH"
cellSize = 30

# Run PolylineToRaster
arcpy.conversion.PolylineToRaster(inFeatures, valField, outRaster, 
                                  assignmentType, priorityField, cellSize)

Related topics