Line Density (Spatial Analyst)

License Level:BasicStandardAdvanced

Summary

Calculates a magnitude per unit area from polyline features that fall within a radius around each cell.

Learn more about how Line Density works

Illustration

Line Density illustration
OutRas = LineDensity(InRds, None, 30)

Usage

Syntax

LineDensity (in_polyline_features, population_field, {cell_size}, {search_radius}, {area_unit_scale_factor})
ParameterExplanationData Type
in_polyline_features

The input line features for which to calculate the density.

Feature Layer
population_field

Numeric field denoting population values (the number of times the line should be counted) for each polyline.

Values in the population field may be integer or floating point.

The options and default behaviours for the field are listed below.

  • Use None if no item or special value will be used and each feature will be counted once.

  • You can use Shape if input features contains Z.

  • Otherwise, the default field is POPULATION. The following conditions may also apply.

    • If there is no POPULATION field, but there is a POPULATIONxxxx field, this is used by default. The "xxxx" can be any valid character, such as POPULATION6, POPULATION1974, or POPULATIONROADTYPE.
    • If there is no POPULATION field or POPULATIONxxxx field, but there is a POP field, this is used by default.
    • If there is no POPULATION field, POPULATIONxxxx field, or POP field, but there is a POPxxxx field, this is used by default.
    • If there is no POPULATION field, POPULATIONxxxx field, POP field, or POPxxxx field, NONE is used by default.
Field
cell_size
(Optional)

The cell size for the output raster dataset.

This is the value in the environment if specifically set. If the environment is not set, then cell size is the shorter of the width or height of the output extent in the output spatial reference, divided by 250.

Analysis Cell Size
search_radius
(Optional)

The search radius within which to calculate density. Units are based on the linear unit of the projection of the output spatial reference.

For example, if the units are in meters, to include all features within a one-mile neighborhood, set the search radius equal to 1609.344 (1 mile = 1609.344 meters).

The default is the shortest of the width or height of the output extent in the output spatial reference, divided by 30.

Double
area_unit_scale_factor
(Optional)

The desired area units of the output density values.

A default unit is selected based on the linear unit of the projection of the output spatial reference. You can change this to the appropriate unit if you wish to convert the density output. Values for line density convert the units of both length and area.

For example, if your input units are meters the default output area density units will be square kilometers for point features or kilometers per square kilometer for polyline features.

The default density units based on the input feature units are:

  • SQUARE_MAP_UNITS If the units are unknown, points, or decimal degrees.
  • SQUARE_MILES For feet, yards, miles, or nautical miles.
  • SQUARE_KILOMETERS For meters or kilometers.
  • SQUARE_INCHES For inches.
  • SQUARE_CENTIMETERS For centimeters.
  • SQUARE_MILLIMETERS For millimeters.
String

Return Value

NameExplanationData Type
out_raster

The output line density raster.

It is always a floating point raster.

Raster

Code Sample

LineDensity example 1 (Python window)

This example calculates a density raster on a length field of a polyline shape file.

import arcpy
from arcpy import env
from arcpy.sa import *
env.workspace = "C:/sapyexamples/data"
outLDens = LineDensity("roads.shp", "LENGTH", 45, 1000, "SQUARE_MILES") 
outLDens.save("C:/sapyexamples/output/ldensout")
LineDensity script example 2 (stand-alone script)

This example calculates a density raster on a length field of a polyline shape file.

# Name: LineDensity_Ex_02.py
# Description: Calculates a magnitude per unit area from polyline features
#    that fall within a radius around each cell.
# Requirements: Spatial Analyst Extension

# Import system modules
import arcpy
from arcpy import env
from arcpy.sa import *

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

# Set local variables
inPolylineFeatures = "roads.shp"
populationField = "length"
cellSize = 120
searchRadius = 1500

# Check out the ArcGIS Spatial Analyst extension license
arcpy.CheckOutExtension("Spatial")

# Execute LineDensity
outLineDensity = LineDensity(inPolylineFeatures, populationField, cellSize,
                             searchRadius, "SQUARE_MILES") 

# Save the output 
outLineDensity.save("C:/sapyexamples/output/linedensity")

Environments

Related Topics

Licensing Information

ArcGIS for Desktop Basic: Requires Spatial Analyst
ArcGIS for Desktop Standard: Requires Spatial Analyst
ArcGIS for Desktop Advanced: Requires Spatial Analyst
4/10/2014