ArcGIS Desktop

  • ArcGIS Pro
  • ArcMap

  • My Profile
  • Help
  • Sign Out
ArcGIS Desktop

ArcGIS Online

The mapping platform for your organization

ArcGIS Desktop

A complete professional GIS

ArcGIS Enterprise

GIS in your enterprise

ArcGIS Developers

Tools to build location-aware apps

ArcGIS Solutions

Free template maps and apps for your industry

ArcGIS Marketplace

Get apps and data for your organization

  • Documentation
  • Support
Esri
  • Sign In
user
  • My Profile
  • Sign Out

ArcMap

  • Home
  • Get Started
  • Map
  • Analyze
  • Manage Data
  • Tools
  • Extensions

Line Density

Available with Spatial Analyst license.

  • Summary
  • Illustration
  • Usage
  • Syntax
  • Code sample
  • Environments
  • Licensing information

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

  • Only the portion of a line within the neighborhood is considered when calculating the density. If no lines fall within the neighborhood at a particular cell, that cell is assigned NoData.

  • Larger values of the radius parameter produce a more generalized density raster. Smaller values produce a raster that shows more detail.

  • The values on the output raster will always 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 Cell Size environment if it has been specified. If the parameter cell size or the environment cell size have not been specified, but the Snap Raster environment has been set, the cell size of the snap raster is used. If nothing is 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 is specified using a numeric value, the tool will use it directly for the output raster.

    If the cell size is 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 than the output spatial reference, it will be projected based on the selected Cell Size Projection Method.

  • If the area unit scale factor units are small relative to the features (length of line sections), the output values may be small. To obtain larger values, use the area unit scale factor for larger units (for example, square kilometers versus square meters).

  • See Analysis environments and Spatial Analyst for additional details on the geoprocessing environments that apply to this tool.

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 behaviors 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 of the output raster that will be 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 will be used if specified; otherwise, additional rules will be used to calculate it from the other inputs. See the usage for more detail.

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

If no output spatial reference is specified, the output spatial reference will be the same as the input feature class. The default output density units is determined by the linear units of the output spatial reference as follows. If the output linear units are meters, the output area density units will be set to SQUARE_KILOMETERS, outputting square kilometers for point features or kilometers per square kilometers for polyline features. If the output linear units are feet, the output area density units will be set to SQUARE_MILES.

If the output units is anything other than feet or meters, the output area density units will be set to SQUARE_MAP_UNITS. That is, the output density units will be the square of the linear units of the output spatial reference. For example, if the output linear units is centimeters, the output area density units will be SQUARE_MAP_UNITS, which would result in square centimeters. If the output linear units is kilometers, the output area density units will be SQUARE_MAP_UNITS, which would result in square kilometers.

The available options and their corresponding output density units are the following:

  • SQUARE_MAP_UNITS —For the square of the linear units of the output spatial reference.
  • SQUARE_MILES —For miles (U.S.).
  • SQUARE_KILOMETERS —For kilometers.
  • ACRES —For acres (U.S.).
  • HECTARES —For hectares.
  • SQUARE_YARDS —For yards (U.S.).
  • SQUARE_FEET —For feet (U.S.).
  • SQUARE_INCHES —For inches (U.S.).
  • SQUARE_METERS —For meters.
  • 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

  • Auto Commit
  • Cell Size
  • Cell Size Projection Method
  • Current Workspace
  • Extent
  • Geographic Transformations
  • Mask
  • Output CONFIG Keyword
  • Output Coordinate System
  • Scratch Workspace
  • Snap Raster
  • Tile Size

Licensing information

  • Basic: Requires Spatial Analyst
  • Standard: Requires Spatial Analyst
  • Advanced: Requires Spatial Analyst

Related topics

  • An overview of the Density toolset

ArcGIS Desktop

  • Home
  • Documentation
  • Support

ArcGIS

  • ArcGIS Online
  • ArcGIS Desktop
  • ArcGIS Enterprise
  • ArcGIS
  • ArcGIS Developer
  • ArcGIS Solutions
  • ArcGIS Marketplace

About Esri

  • About Us
  • Careers
  • Esri Blog
  • User Conference
  • Developer Summit
Esri
Tell us what you think.
Copyright © 2021 Esri. | Privacy | Legal