25
How Kernel Density works Kernel Density calculates the density of features in a neighborhood around those features. It can be calculated for both point and line features. Possible uses include finding density of houses, crime reports or density of roads or utility lines influencing a town or wildlife habitat. The population field could be used to weigh some features more heavily than others, depending on their meaning, or to allow one point to represent several observations. For example, one address might represent a condominium with six units, or some crimes might be weighed more severely than others in determining overall crime levels. For line features a divided highway probably has more impact than a narrow dirt road and a high-tension line has more impact than a standard electric pole. Kernel Density for point features Kernel Density calculates the density of point features around each output raster cell. Conceptually, a smoothly curved surface is fitted over each point. The surface value is highest at the location of the point and diminishes with increasing distance from the point, reaching zero at the Search radius distance from the point. Only a circular neighborhood is possible. The volume under the surface equals the Population field value for the point, or one if NONE is specified. The density at each output raster cell is calculated by adding the values of all the kernel surfaces where they overlay the raster cell center. The kernel function is based on the quadratic kernel function described in Silverman (1986, p. 76, equation 4.5). If a population field setting other than NONE is used, each item's value determines the number of times to count the point. For example, a value of three would cause the point to be counted as three points. The values can be integer or floating point. By default a unit is selected based on the linear unit of the projection definition of the input point feature data or as otherwise specified in the output coordinate system geoprocessing environment setting . If an area unit is selected, the calculated density for the cell is multiplied by the appropriate factor before it is written to the output raster. For example, if the input units are meters, the output area units will default to square kilometers. Comparing a unit scale factor of meters to kilometers will result in the values being different by a multiplier of 1,000,000 (1,000 meters x 1,000 meters). Increasing the radius will not greatly change the calculated density values. Although more points will fall inside the larger neighborhood, this number will be divided by a larger area when calculating density. The main effect of a larger radius is that density is calculated considering a larger number of points, which can be further from the raster cell. This results in a more generalized output raster. Kernel Density for line features Kernel Density calculates the density of linear features in the neighborhood of each output raster cell.

How Kernel Density Works

Embed Size (px)

Citation preview

Page 1: How Kernel Density Works

How Kernel Density worksKernel Density calculates the density of features in a neighborhood around those features. It can be calculated for both point and line features. Possible uses include finding density of houses, crime reports or density of roads or utility lines influencing a town or wildlife habitat. The population field could be used to weigh some features more heavily than others, depending on their meaning, or to allow one point to represent several observations. For example, one address might represent a condominium with six units, or some crimes might be weighed more severely than others in determining overall crime levels. For line features a divided highway probably has more impact than a narrow dirt road and a high-tension line has more impact than a standard electric pole.

Kernel Density for point features

Kernel Density calculates the density of point features around each output raster cell.

Conceptually, a smoothly curved surface is fitted over each point. The surface value is highest at the location of the point and diminishes with increasing distance from the point, reaching zero at the Search radius distance from the point. Only a circular neighborhood is possible. The volume under the surface equals the Population field value for the point, or one if NONE is specified. The density at each output raster cell is calculated by adding the values of all the kernel surfaces where they overlay the raster cell center. The kernel function is based on the quadratic kernel function described in Silverman (1986, p. 76, equation 4.5).

If a population field setting other than NONE is used, each item's value determines the number of times to count the point. For example, a value of three would cause the point to be counted as three points. The values can be integer or floating point.

By default a unit is selected based on the linear unit of the projection definition of the input point feature data or as otherwise specified in the output coordinate system geoprocessing environment setting. If an area unit is selected, the calculated density for the cell is multiplied by the appropriate factor before it is written to the output raster.

For example, if the input units are meters, the output area units will default to square kilometers. Comparing a unit scale factor of meters to kilometers will result in the values being different by a multiplier of 1,000,000 (1,000 meters x 1,000 meters).

Increasing the radius will not greatly change the calculated density values. Although more points will fall inside the larger neighborhood, this number will be divided by a larger area when calculating density. The main effect of a larger radius is that density is calculated considering a larger number of points, which can be further from the raster cell. This results in a more generalized output raster.

Kernel Density for line features

Kernel Density calculates the density of linear features in the neighborhood of each output raster cell.

Conceptually, a smoothly curved surface is fitted over each line. Its value is greatest on the line and diminishes as you move away from the line, reaching zero at the search radius from the line. The surface is defined so the volume under the surface equals the product of line length and the Population field value. The density at each output raster cell is calculated by adding the values of all the kernel surfaces where they overlay the raster cell center. The use of the kernel function for lines is adapted from the quadratic kernel function for point densities as described in Silverman (1986, p. 76, equation 4.5).

Page 2: How Kernel Density Works

Kernel DensityCalculates a magnitude per unit area from point or polyline features using a kernel function to fit a smoothly tapered surface to each point or polyline.

Learn more about how Kernel Density works

Usage tips

Command line and Scripting

Only the points or portions of a line that fall within the neighborhood are considered in calculating density. If no points or line sections fall within the neighborhood of a particular cell, that cell is assigned NoData.

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

If the area unit scale factor units are small relative to the features (distance between points or length of line sections, depending on feature type), the output values may be small. To obtain larger values, select the area unit scale factor for larger units (for example, square kilometers versus square meters).

The values on the output raster will always be floating point.

The following environment settings affect this tool:

o General: Current Workspace, Scratch Workspace, Output Coordinate system, Output Extent, Snap Raster.

o Raster Analysis: Cell size, Mask.

o Raster Storage: See the Raster Storage settings for the particular output raster format selected.

Page 3: How Kernel Density Works

ArcObjects

Only the points or portions of a line that fall within the neighborhood are considered in calculating density. If no points or line sections fall within the neighborhood of a particular cell, that cell is assigned NoData.

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

← Density values calculated in the default units (length per square map unit) may be small. If the output raster appears to have all zero or small values, use a larger unit_scale_factor.

← The values on the output raster will always be floating point.

SyntaxKernelDensity_sa (in_features, population_field, out_raster, cell_size, search_radius, area_unit_scale_factor)

Parameter Explanation Datatype

Input point or polyline features (Required)

The input features (point or line) to calculate the density for.

Composite Geodataset

Population Field (Required)

Field denoting population values for each feature. The Population field is the count or quantity to be spread across the landscape to create a continuous surface.

Values may be integer or floating point.

Use Shape if in_features contains Z.

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

Otherwise, the default field is <POPULATION>. Further to this:

← 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

Page 4: How Kernel Density Works

Output raster (Required) The raster to be created.

Raster Dataset

Output cell size (Optional)

The cell size at which the output raster will be created.

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

Analysis cell size

Search radius (Optional)

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 in a one mile neighbourhood, 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 extent of in_features in the output spatial reference, divided by 30.

Double

Area units (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 denisty 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

Page 5: How Kernel Density Works

Data types for geoprocessing tool parameters

Script Example

# KernelDensity_sample.py

# Description:

# Calculates a magnitude per unit area from point or polyline

# features using a kernel function to fit a smoothly tapered

# surface to each point or polyline.

# Requirements: None

# Author: ESRI

# Date: Sept 6, 2005

# Import system modules

import arcgisscripting

# Create the Geoprocessor object

gp = arcgisscripting.create()

try:

# Set local variables

outRaster = "C:/data/final_1"

inShp = "C:/data/pts.shp"

# Check out Spatial Analyst extension license

gp.CheckOutExtension("Spatial")

# Process: Kernel Density...

gp.KernelDensity_sa(inShp, "NONE", outRaster, "1.7E-02", "1", "SQUARE_MAP_UNITS")

Page 6: How Kernel Density Works

except:

# If an error occurred while running a tool, then print the messages.

print gp.GetMessages()

Map Algebra syntaxSee Line Density or Point Density

ArcObjects syntaxIDensityOp:KernelDensity (sourceFeatures as IGeoDataset, [radiusDistance], [scaleFactor]] As IGeoDataset

Parameter Explanation

sourceFeatures A point or line feature class.

[radiusDistance] Search radius within which to calculate density.

[scaleFactor]

The factor used to convert the map unit of the input dataset to different units. The default value is one. For point source data, the density will be in units of number of points per one square map unit. For line source data, density will be in units of length of line per one square map unit. Output raster values are multiplied by the square of this factor.

ArcObjects example

' Calculates the kernel density

'

' Member of esriGeoAnalyst.IDensityOp

Dim pDensityOp As IDensityOp

Set pDensityOp = New RasterDensityOp

Dim pFClass01 As IFeatureClass

Set pFClass01 = FunctionToOpenPointFeatureClass("C:\data\point01.shp")

Page 7: How Kernel Density Works

' Create FeatureClassDescriptor

Dim pFDescr As IFeatureClassDescriptor

Set pFDescr = New FeatureClassDescriptor

pFDescr.Create pFClass01, Nothing, "NONE"

' RasterDensityOp - Method

Dim pRasOut As IRaster

' Call the Kernel Density method with radius distance = 20 and a scale factor of 5

Set pRasOut = pDensityOp.KernelDensity(pFDescr, 200, 5)

See Also Line Density

Point Density

Using the ArcGIS Spatial Analyst toolbar to calculate density

An overview of the Density tools

Output coordinate system

Specify the coordinate system that will be used for processing and set to the output geodataset. The coordinate system (geographic coordinate system or projected coordinate system) defines the location of the spatial data on the earth.

If the geoprocessing tool has an input feature class, and the coordinate system environment is not set, the coordinate system of the input* will be used as the processing and set as the output feature class' coordinate system. To override this, set the "Coordinate System environment" to the desired coordinate system.

* For tools which have multiple inputs (intersect for example) the coordinate of the first feature class in the list will be used.

Usage tips

← When the coordinate system environment is different than the input feature class' coordinate system, the input features are projected to the output coordinate system during tool execution. This projecting of the features will not affect the input feature class. Keep in mind that a projection can only be done between two known coordinate systems. So if either the input or output dataset's coordinate system is unknown, no projection occurs. Then the input feature's coordinates are assumed to be in the same coordinate system as the processing and output coordinate system.

Page 8: How Kernel Density Works

← The keyword used at the command line or in scripts for this environment setting is OutputCoordinateSystem.

← If not explicitly set and the output does not reside inside a feature dataset, the coordinate system of the first input will be used.

← The coordinate system (geographic or projected) defines the location of the spatial data on the earth.

← Learn more about specifying general settings

← Learn more about environment settings

← Learn more about environment levels and hierarchy

← Learn more about coordinate systems and map projections

← Learn more about map projections

← Learn more about supported map projections

Command line syntaxAn overview of the command line window

OutputCoordinateSystem <outputCoordinateSystem>

Parameters Explanation Datatype

<outputCoordinateSystem>

Specifies the output features coordinate system. If not explicitly set and the output does not reside inside a feature dataset, the spatial reference of the first input will be used.

← Same As Input—If input features have a coordinate system, then the output features will have the same coordinate system. This is the default.

← As specified below—Choose a new coordinate system for output features. You may enter a coordinate system name or use the Spatial Reference Properties dialog box.

Coordinate System

Data types for geoprocessing tool parameters

Command line example

outputCoordinateSystem "Coordinate Systems\Projected Coordinate Systems\Utm\Nad 1983\NAD 1983 UTM Zone 22N.prj"

Scripting syntaxAn overview of scripting in geoprocessing

OutputCoordinateSystem (outputCoordinateSystem)

Page 9: How Kernel Density Works

Parameters Explanation Datatype

outputCoordinateSystem (Required)

Specifies the output features coordinate system. If not explicitly set and the output does not reside inside a feature dataset, the spatial reference of the first input will be used.

← Same As Input—If input features have a coordinate system, then the output features will have the same coordinate system. This is the default.

← As specified below—Choose a new coordinate system for output features. You may enter a coordinate system name or use the Spatial Reference Properties dialog box.

Coordinate System

Data types for geoprocessing tool parameters

Script example

import arcgisscripting

gp = arcgisscripting.create()

gp.workspace = "h:/workspace"

gp.OutputCoordinateSystem = "Coordinate Systems\Projected Coordinate Systems\Utm\Nad 1983\NAD 1983 UTM Zone 22N.prj"

Output extent

Defined area of interest for results from running tools. In the case of feature data, all input features to a tool that pass through the area of interest will be included in the calculation. For raster data, results from running tools will be contained within the extent set.

The extent is a rectangle, specified by identifying the coordinates of the window in map space.

Usage tips

The keyword used at the command line or in scripts for this environment setting is: Extent.

Set this environment if your study area is only a portion of a larger dataset.

The extent entered are assumed to be in the coordinate system in which the data is stored, even if the OutputCoordinateSystem environment is set.

Extent uses keywords at the command line or in scripting. If you set extent using the environments dialog you will notice the keywords are represented with phrases.

Page 10: How Kernel Density Works

Keyword Dialog option Description

MINOFIntersection of Inputs

The minimum area common to all inputs; where all layers overlay. This is the default.

MAXOF Union of Inputs The maximum extent of all inputs; the combined extent of all inputs.

value As specified below User specified XMin, YMin, XMax, YMax values.

N/A Default The maximum extent of all inputs; the combined extent of all inputs.

NOTE: This option is available only on the environments dialog.

When you first specify the extent to be the same as a layer, the extent is read and set. The next time you open up environments, it will read "As specified below". The numbers come from the previously set layer, but the option reverts to "as specified below".

Learn more about specifying general settings

Learn more about environment settings

Learn more about environment levels and hierarchy

In ModelBuilder

← In ModelBuilder, Extent will also show a list of variables. If you create a feature dataset, raster dataset, feature layer, raster layer, or extent variables in your model you will see these as options in the extent drop-down list. These choices are easily recognizable because they appear as either "Same as variable <name>" or "Same as layer <name>".

← The list will also show derived data in the drop down list. Derived data does not already exist before the model is executed and therefore can't be selected as the model extent. So if you are setting the extent for the entire model do not select derived data.

← You can selected derived data only if you are setting the extent for a single process and the derived data will be created before the process will execute. In your model diagram you will see a condition connector line appear that forces the model to first execute the process with the derived data element.

← In ArcGIS 9.2, extent is dynamic which allows for the additional selection of feature dataset, raster dataset, feature layer, raster layer, or extent variables. However, if you open the extent environment and click anywhere in the top/bottom/left/right input boxes the input will display As specified below and the extent will become static. The variable you had selected will no longer define the extent and the connector line will be automatically removed from your model. To make the extent dynamic again you will need to re-set the extent by selecting a drop-down list choice.

Command line syntaxAn overview of the command line window

Extent <MINOF | MAXOF | value>

Parameters Explanation Datatype

Page 11: How Kernel Density Works

<MINOF| MAXOF | value>

Specifies the extent of the study area.

← MINOF (Intersection of Inputs)—The minimum area common to all inputs; where all layers overlay. This is the default.

← MAXOF (Union of Inputs)—The maximum extent of all inputs; the combined extent of all inputs.

← value (As Specified Below)—Specifies the minimum and maximum extent values:

o Left—XMin value

o Right—XMax value

o Bottom—YMin value

o Top—YMax value

String

Data types for geoprocessing tool parameters

Command line examples

Extent MINOF

Extent '1 1 512 512'

Scripting syntaxAn overview of scripting in geoprocessing

Extent (study_area)

Parameters Explanation Datatype

MINOF | MAXOF | value (Required)

Specifies the extent of the study area.

← MINOF (Intersection of Inputs)—The minimum area common to all inputs; where all layers overlay. This is the default.

← MAXOF (Union of Inputs)—The maximum extent of all inputs; the combined extent of all inputs.

← value (As Specified Below)—Specifies the minimum and maximum extent values:

o Left—XMin value

o Right—XMax value

String

Page 12: How Kernel Density Works

o Bottom—YMin value

o Top—YMax value

Data types for geoprocessing tool parameters

Script example

import arcgisscripting

gp = arcgisscripting.create()

gp.workspace = "h:/workspace"

gp.toolbox = "SA"

gp.Extent = "MAXOF"

gp.Extent = "1 1 512 512"

An overview of raster storage settings

The raster storage settings section of the Environment Settings dialog box provides settings for raster dataset results. Included are the following settings that can be changed: the default compression type, the default settings for pyramid creation and calculating statistics, and the tile size used when loading raster data to an existing raster dataset.

Not all settings apply to all storage types. Refer to the Raster storage matrix (below) for more details. File Group 2 consist of the following file formats: BSB, BMP, DEM, ECW, GIF, JPEG, JPEG2000, MAP, PIX, PNG, and XPM. All remaining ArcGIS supported raster file formats fall into File Group 1.

Raster storage matrix Storage settings

File Group 1

File Group 2

personal GDB

File GDB

ArcSDE

Pyramids yes yes yes yes yes

Resampling automatic automatic automatic yes yes

Levels automatic automatic automatic yes yes

Raster statistics automatic yes automatic yes yes

skip factor yes automatic yes yes yes

Page 13: How Kernel Density Works

ignore value yes automatic yes yes yes

Compression yes* yes* yes yes yes

LZ77 yes* no yes yes yes

JPEG no yes* yes yes yes

JPEG 2000 no yes* yes yes yes

Tile size no no no yes yes

NOTE: Compression is dependant on the type of file format. Please refer to the Technical Specifications to see which file formats are able to support compression.

The following subtopics supplement the reference topics found in Environment settings.

Compression typeThe compression type setting is used by any tool whose output is a raster dataset. Three types of compression are supported: LZ77, JPEG, and JPEG2000.

LZ77 (the default) is a lossless compression that preserves all raster cell values. It uses the same compression algorithm as the PNG image format and one similar to ZIP compression. As you can rely on the pixels not changing their values after you compress them, use LZ77 for performing visual or algorithmic analysis.

JPEG is a lossy compression, because raster cell values may not be preserved after compression and decompression. It uses the public domain JPEG (JFIF) compression algorithm and only works for unsigned 8-bit raster data (single-band grayscale or three-band raster data).

JPEG2000 uses wavelet technology to compress rasters, so they visually appear lossless, meaning that although the cell values do get manipulated, the differences between the original and the same raster with compression are not easily distinguishable. Use JPEG or JPEG2000 for rasters that are meant as pictures or backdrop imagery.

If JPEG or JPEG2000 is selected, you can also set the compression quality to control how much loss the image will be subjected to by the compression algorithm. The values of the pixels of an image compressed with a higher compression quality will be closer to those of the original image. Valid value ranges of compression quality for JPEG are from five to 95. Valid value ranges for JPEG 2000 are from 1 to 100. The default compression quality is 75. The amount of compression will depend on the data and compression quality. The more homogeneous the data, the higher the compression ratio. The lower the compression quality, the higher the compression ratio. Lossy compression normally results in higher compression ratios when compared to lossless compression.

The primary benefits of compressing data are that compressed data requires less storage space and data display times will be quicker, as there is less information to transmit.

Pyramidspyramid are reduced-resolution representations of your dataset. They can speed up display of raster datasets by retrieving only the data that is necessary at a specified resolution.

Page 14: How Kernel Density Works

By default, pyramids are created for raster datasets by resampling the original data. There are three resampling methods available: nearest neighbor, bilinear, and cubic.

The default is nearest neighbor. It works for any type of raster dataset. Use nearest neighbor for nominal data or raster datasets with colormaps, such as land use data, scanned maps, and pseudocolor images.

Use bilinear interpolation or cubic convolution for continuous data, such as satellite imagery or aerial photography.

If you uncheck Build pyramids, pyramids will not be created with the output raster. Not building pyramids saves storage space but will lead to slower display speeds, especially for larger raster datasets.

StatisticsThe Statistics option enables you to build statistics for output raster datasets. Statistics are required for your raster dataset to perform certain tasks in ArcMap or ArcCatalog, such as applying a contrast stretch or classifying your data. It is not essential to build statistics if they have not already been calculated, since they are calculated the first time they are needed. However, it is recommended that you calculate statistics for your raster datasets before using them if you want to use certain features that require statistics. The default display of your raster will be improved in most cases if statistics have already been calculated, because a standard deviation stretch is applied if statistics are present.

Setting a Skip factor allows you to speed up the process of calculating statistics by skipping pixels. The Skip factor does not apply for GRID datasets.

Values you set to ignore will not participate in the statistics calculation. Normally, you may want to ignore the values of the background. This only applies to personal geodatabase raster datasets.

Tile sizeThe tile size setting is used by any tools that create raster datasets and are stored in blocks.

The default tile size is 128 by 128, which is good for most cases. However, if the tile size is too big, you will end up bringing up more data than is needed each time you access the data. For example, you want to display a window of 100 by 100 and it only covers one tile. If you set the tile size to 512, you need to get the tile of 512 by 512 pixels. If your tile size is set to 128 by 128, you'll bring up less extra data if the display window is 100 by 100.

See Also

Snap raster

Snap raster is used to snap or align an extent during execution. The lower-left corner of the extent is snapped to a cell corner of the snap raster and then the upper-right corner is adjusted using the output cell size. As a result, when the output cell size is same as the snap raster cell size, the cells in the output raster are aligned with the cells of the snap raster.

Learn more about how Snap Raster works

Usage tips

← In general, the snap raster is applied to tools that output a raster. The extent is not snapped when the output is a feature class, or a table, or a file.

← Snap raster can be used with default output extent. You do not need to specify an extent explicitly in environment to use snap raster.

← It is recommended to use the same cell size for snap and output raster. However, it is possible to have the snap raster cell size different from the output raster cell size. In that case, only the left and

Page 15: How Kernel Density Works

bottom boundaries will align with snap raster cells and the upper-right corner of the output extent may not coincide with a cell corner of the snap raster.

← Specifying snap raster does not change the values in output extent control immediately, however, the extent is adjusted during execution.

← The keyword used at the command line or in scripts for this environment setting is: SnapRaster.

← Snap raster specified as part of extent at the command line or in scripts will continue to work in ArcGIS 9.3 but it is recommended to use the new separate snap raster setting.

← Since the extent could be snapped to a larger extent, the output raster may contain an additional row and/or column of NoData cells.

← The size (i.e. the number of rows or columns) in a snap raster is not important. The origin and the cell size are used to adjust the output extent.

← The extent of the snap raster does not need to be overlapped with the output extent. Therefore, a small raster, located outside of your analysis area could be used for snapping.

← The keyword used at the command line or in scripts for this environment setting is: SnapRaster.

← Learn more about specifying general settings

← Learn more about environment settings

← Learn more about environment levels and hierarchy

Command line syntaxAn overview of the command line window

SnapRaster <raster_dataset>

Parameters Explanation Datatype

<raster_dataset> The raster dataset to be used as the snap raster. Raster Dataset

Data types for geoprocessing tool parameters

Command line example

SnapRaster C:\data\mysnapraster

Scripting syntaxAn overview of scripting in geoprocessing

SnapRaster raster_dataset

Parameters Explanation Datatype

raster_dataset (Required) The raster dataset to be used as the snap raster. Raster Dataset

Data types for geoprocessing tool parameters

Page 16: How Kernel Density Works

Script example

import arcgisscripting

gp = arcgisscripting.create()

gp.workspace = "C:/workspace"

gp.extent = "C:/data/projectbnd"

gp.SnapRaster = "C:/data/mysnapraster"

try:

# Set local variables

InRaster = "C:/data/dem"

OutRaster = "C:/data/aspect"

# Check out ArcGIS Spatial Analyst extension license

gp.CheckOutExtension("Spatial")

# Process: Aspect

gp.Aspect_sa(InRaster, OutRaster)

except:

# If an error occurred while running a tool, then print the messages.

print gp.GetMessages()

See Also

Current workspace

Specifies the workspace for the current session. The location from which inputs are taken and outputs are placed when running tools.

Page 17: How Kernel Density Works

Usage tips

← The keyword used at the command line or in scripts for this environment setting is Workspace.

← As a general rule, multiple users should not simultaneously access the same workspace or the same INFO directory.

← You can only edit one collection of dataset (one workspace) at a time. These can be geodatabase, ArcInfo coverage, or shapefile.

← Explicitly stating the current workspace will allow you to specify only the name of datasets used without the path to their location.

← Learn more about specifying general settings

← Learn more about environment settings

← Learn more about environment levels and hierarchy

Command line syntaxAn overview of the command line window

Workspace <workspace or feature dataset>

Parameters Explanation Datatype

<workspace or feature dataset>

The location from which inputs are taken and outputs are placed when running tools.

Folder | Workspace

Data types for geoprocessing tool parameters

Command line example

workspace d:\myWorkspace

OR

workspace d:\myWorkspace.mdb

Scripting syntaxAn overview of scripting in geoprocessing

Workspace (workspace or feature dataset)

Output coordinate system

Specify the coordinate system that will be used for processing and set to the output geodataset. The coordinate system (geographic coordinate system or projected coordinate system) defines the location of the spatial data on the earth.

Page 18: How Kernel Density Works

If the geoprocessing tool has an input feature class, and the coordinate system environment is not set, the coordinate system of the input* will be used as the processing and set as the output feature class' coordinate system. To override this, set the "Coordinate System environment" to the desired coordinate system.

* For tools which have multiple inputs (intersect for example) the coordinate of the first feature class in the list will be used.

Usage tips

When the coordinate system environment is different than the input feature class' coordinate system, the input features are projected to the output coordinate system during tool execution. This projecting of the features will not affect the input feature class. Keep in mind that a projection can only be done between two known coordinate systems. So if either the input or output dataset's coordinate system is unknown, no projection occurs. Then the input feature's coordinates are assumed to be in the same coordinate system as the processing and output coordinate system.

← The keyword used at the command line or in scripts for this environment setting is OutputCoordinateSystem.

← If not explicitly set and the output does not reside inside a feature dataset, the coordinate system of the first input will be used.

← The coordinate system (geographic or projected) defines the location of the spatial data on the earth.

← Learn more about specifying general settings

← Learn more about environment settings

← Learn more about environment levels and hierarchy

← Learn more about coordinate systems and map projections

← Learn more about map projections

← Learn more about supported map projections

Command line syntaxAn overview of the command line window

OutputCoordinateSystem <outputCoordinateSystem>

Parameters Explanation Datatype

<outputCoordinateSystem>

Specifies the output features coordinate system. If not explicitly set and the output does not reside inside a feature dataset, the spatial reference of the first input will be used.

← Same As Input—If input features have a coordinate system, then the output features will have the same coordinate system. This is the default.

Coordinate System

Page 19: How Kernel Density Works

← As specified below—Choose a new coordinate system for output features. You may enter a coordinate system name or use the Spatial Reference Properties dialog box.

Data types for geoprocessing tool parameters

Command line example

outputCoordinateSystem "Coordinate Systems\Projected Coordinate Systems\Utm\Nad 1983\NAD 1983 UTM Zone 22N.prj"

Scripting syntaxAn overview of scripting in geoprocessing

OutputCoordinateSystem (outputCoordinateSystem)

Parameters Explanation Datatype

outputCoordinateSystem (Required)

Specifies the output features coordinate system. If not explicitly set and the output does not reside inside a feature dataset, the spatial reference of the first input will be used.

← Same As Input—If input features have a coordinate system, then the output features will have the same coordinate system. This is the default.

← As specified below—Choose a new coordinate system for output features. You may enter a coordinate system name or use the Spatial Reference Properties dialog box.

Coordinate System

Data types for geoprocessing tool parameters

Script example

import arcgisscripting

gp = arcgisscripting.create()

gp.workspace = "h:/workspace"

gp.OutputCoordinateSystem = "Coordinate Systems\Projected Coordinate Systems\Utm\Nad 1983\NAD 1983 UTM Zone 22N.prj"

See Also scratch workspace

Page 20: How Kernel Density Works

current workspace

xy tolerance

XY Tolerance

NOTE: In ArcGIS 9.2, the term xy tolerance has been introduced. This term is synonymous with cluster tolerance. In certain contexts the term cluster tolerance has been replaced by the term XY Tolerance.

Specify the XY Tolerance that will be used for processing and set to the output geodataset.

Learn more about XY tolerance

Usage tips

← If the output is a feature class inside a feature dataset and the XY tolerance of the feature dataset is used, the environment will be ignored.

← If the output is a standalone feature class, raster catalog or feature dataset, the tolerance of the input will be used as the processing tolerance and set as the output geodataset's XY tolerance. For tools that have multiple inputs (Intersect for example) the tolerance of the first input in the list will be used as the default. To override these defaults, set the XY tolerance environment to the desired value.

← For tools that do not have an input geodataset (for example, Create Feature Class, Create Feature Dataset, and Create Raster Catalog) and if the environment is left blank, the default XY tolerance is set to 0.001 meters or its equivalent in map units. For example, if your coordinate system is recorded in feet, the default value is 0.003281 feet (0.03937 inches). The default value is 10 * the default XY resolution, and this is recommend for most cases. If coordinates are in latitude-longitude, the default XY tolerance is 0.0000000556 degrees. To override this default, set the environment to the desired value.

← If the tolerance value entered for the XY tolerance environment or parameter is in a different unit than the output coordinate system, the equivalent distance measure in the center of the output coordinate system is used for processing. This may not be desirable, especially when dealing with a projected coordinate system and a angular unit of measurement (degrees, grads) or when dealing with a geographic coordinate system and a linear unit of measurement (feet, meters).

← If the XY tolerance is set to "Unknown" units, the units are assumed to be the same as the output coordinate system's units.

← The XY tolerance is not intended to be used to generalize geometry shapes. Instead, it's intended to integrate line work and boundaries during topological operations. That means integrating coordinates that fall within very small distances of one another. Because coordinates can move in both X and Y by as much as the XY tolerance, many potential problems can be resolved by processing datasets with commands that use the XY tolerance. These include handling of extremely small overshoots or undershoots, automatic sliver removal of duplicate segments, and coordinate thinning along boundary lines.

← To keep movement small, keep the XY tolerance small. However, an XY tolerance that is too small (such as 2 * XY resolution or less) may not properly integrate the line work of shared boundaries.

← Conversely, if your XY tolerance is too large, feature coordinates may collapse on one another. This can compromise the accuracy of feature boundary representations.

← Your XY tolerance should never approach your data capture resolution. For example, at a map scale of 1:12,000, one inch equals 1,000 feet, and 1/50 of an inch still equals 20 feet— a data capture accuracy that would be hard to meet during digitizing and scan conversion. You'll want to keep the coordinate movement using the XY tolerance well under these numbers. Remember, the default XY Tolerance in this case would be 0.003281 feet.

Page 21: How Kernel Density Works

← If the XY tolerance is not at least twice as large as the XY resolution value, the XY tolerance is set to be twice as large as the XY resolution by default.

← Tolerance will not be persisted to a dataset in a pre-92 geodatabase.

← Learn more about specifying general settings

← Learn more about environment settings

← Learn more about environment levels and hierarchy

Command line syntaxAn overview of the command line window

XYTolerance <linear unit>

Parameters Explanation Datatype

<Linear unit>

The minimum distance separating all feature coordinates (nodes and vertices), and the distance a coordinate can move in X or Y (or both).

You can set the value to be higher for data that has less coordinate accuracy and lower for datasets with extremely high accuracy.

The default XY tolerance is set to 0.001 meters or its equivalent in map units.

Linear Unit

Data types for geoprocessing tool parameters

Command line example

XYTolerance 0.02

Scripting syntaxAn overview of scripting in geoprocessing

XYTolerance (Linear unit)

Parameters Explanation Datatype

Linear unit (Required)

The minimum distance separating all feature coordinates (nodes and vertices) , and the distance a coordinate can move in X or Y (or both).

You can set the value to be higher for data that has less coordinate accuracy and lower for datasets with extremely high accuracy.

The default XY tolerance is set to 0.001 meters or its equivalent in map units.

Linear Unit

Data types for geoprocessing tool parameters

Page 22: How Kernel Density Works

Script example

import arcgisscripting

gp = arcgisscripting.create()

gp.workspace = "h:/workspace"

gp.XYTolerance = "0.02"