# Geometry service Densify method

The Densify method converts nonlinear geometry to linear geometry by adding vertices to the input features.

Densify(SpatialReference SpatialReference, Geometry[] InGeometryArray, double MaxSegmentLength, boolean UseDeviationDensification, double DensificationParameter)

Parameter

Description

SpatialReference

The SpatialReference of the geometries in the InGeometryArray. Cannot be null.

InGeometryArray

The array of Geometry to be densified. All geometries are assumed to be in the coordinate system defined by SpatialReference.

MaxSegmentLength

The maximum allowable length of a segment in densified geometry. See the remarks section below for specific details.

UseDeviationDensification

Determines the method to use when densifying non-linear segments (curves).

DensificationParameter

Either the central angle or maximum distance of a replacement segment from an input curve, depending on the UseDeviationDensification parameter. See the remarks section below for specific details.

## Return Value

An array of Geometry (Geometry[]).

## Remarks

This method replaces each curve segment, and optionally each line segment, in a polyline or polygon with line segments. Other types of input geometries will be ignored. All geometries are assumed to be in the SpatialReference provided which cannot be null. If the input geometries have latitude-longitude coordinates, you should use the DensifyGeodesic method.

When MaxSegmentLength is greater than zero, lines and curves greater than that length will be replaced with lines at most MaxSegmentLength long, and curves shorter than that will be replaced with lines connecting their endpoints. If MaxSegmentLength is 0, then only curve segments will be densified, as explained below.

In general, this method provides three ways to densify curves based on the following:

1. length
2. central angle
3. maximum distance of replacement line from input curve (deviation)

The table shown below explains how the input parameters work together.

If MaxSegmentLength is

And DeviationTolerance is

Then

> 0

0

All segments longer than MaxSegmentLength are replaced with sequences of lines no longer than MaxSegmentLength. Curves shorter than MaxSegmentLength are replaced with lines connecting the curve endpoints. This is method 1, above, for densifying curves.

0

> 0

Input lines are copied to the output geometries. Input curves are densified using either method 2 or method 3, based on the value of the UseDeviationDensification parameter.

> 0

> 0

Lines longer than MaxSegmentLength units are replaced with sequences of lines no longer than MaxSegmentLength; curves are replaced with sequences of lines using either method 2 or method 3, based on the value of the UseDeviationDensification parameter.

Note:

When UseDeviationDensification is false, the DensificationParameter is interpreted as a central angle, instead of a deviation.

## Examples

### C#

``````Geometry_GeometryServer geometryService = new Geometry_GeometryServer();

geometryService.Url = "http://localhost:6080/arcgis/services/Geometry/GeometryServer";

SpatialReference inputSpatialReference = new wsgeometry.ProjectedCoordinateSystem();

// World Mercator

inputSpatialReference.WKID = 54004;

inputSpatialReference.WKIDSpecified = true;

PointN pnt1 = new PointN();

pnt1.X = 500000;

pnt1.Y = 500000;

PointN pnt2 = new PointN();

pnt2.X = 600000;

pnt2.Y = 500000;

PointN pnt3 = new PointN();

pnt3.X = 700000;

pnt3.Y = 500000;

PointN[] pntarray1 = new PointN[] { pnt1, pnt2, pnt3 };

Path inputPath = new Path();

inputPath.PointArray = pntarray1;

Path[] paths = new Path[] { inputPath };

PolylineN inputPolyline = new PolylineN();

inputPolyline.PathArray = paths;

Geometry[] inputGeometry = new Geometry[] { inputPolyline };

double maxSegmentLength = 10000;

bool useDeviationDensification = false;

double densificationParam = 0;

Geometry[] outputGeometry = geometryService.Densify(inputSpatialReference, inputGeometry, maxSegmentLength,

useDeviationDensification, densificationParam);
``````

### VB.NET

``````Dim geomeTryService As Geometry_GeometryServer = New Geometry_GeometryServer()

geomeTryService.Url = "http://localhost:6080/arcgis/services/Geometry/GeometryServer"

Dim inputSpatialReference As SpatialReference = New wsgeomeTry.ProjectedCoordinateSystem()

' World Mercator

inputSpatialReference.WKID = 54004

inputSpatialReference.WKIDSpecified = True

Dim pnt1 As PointN = New PointN()

pnt1.X = 500000

pnt1.Y = 500000

Dim pnt2 As PointN = New PointN()

pnt2.X = 600000

pnt2.Y = 500000

Dim pnt3 As PointN = New PointN()

pnt3.X = 700000

pnt3.Y = 500000

Dim pntarray1() As PointN = New PointN() {pnt1, pnt2, pnt3}

Dim inputPath As Path = New Path()

inputPath.PointArray = pntarray1

Dim paths() As Path = New Path() {inputPath}

Dim inputPolyline As PolylineN = New PolylineN()

inputPolyline.PathArray = paths

Dim inputGeomeTry() As Geometry = New Geometry() {inputPolyline}

Dim maxSegmentLength As Double = 10000

Dim useDeviationDensification As Boolean = False

Dim densificationParam As Double = 0

Dim outputGeomeTry As Geometry() = geomeTryService.Densify(inputSpatialReference, _

inputGeomeTry, maxSegmentLength, useDeviationDensification, densificationParam)
``````

### Java

``````String serviceURL = "http://localhost:6080/arcgis/services/Geometry/GeometryServer";

GeometryServerBindingStub geometryService = new GeometryServerBindingStub(serviceURL);

//Input spatial reference

SpatialReference inputSpatialReference = new ProjectedCoordinateSystem();

inputSpatialReference.setWKID(54004); // World Mercator

//Points that will form a path

PointN p1 = new PointN();

p1.setX(500000);

p1.setY(500000);

PointN p2 = new PointN();

p2.setX(600000);

p2.setY(50000);

PointN p3 = new PointN();

p3.setX(700000);

p3.setY(50000);

PointN[] pointsArray = new PointN[] { p1, p2, p3 };

//Create a path

Path inputPath = new Path();

inputPath.setPointArray(pointsArray);

Path[] paths = new Path[] { inputPath };

//Create a polyline

PolylineN inputPolyline = new PolylineN();

inputPolyline.setPathArray(paths);

//Input geometry

Geometry[] inputGeometry = new Geometry[] { inputPolyline };

//Densify parameters

double maxSegmentLength = 10000;

boolean bUseDeviationDensification = false;

double densificationParam = 0;

//Densify

Geometry[] outputGeometry = geometryService.densify(

inputSpatialReference, inputGeometry, maxSegmentLength,

bUseDeviationDensification, densificationParam);

for (Geometry geom : outputGeometry) {

if (geom instanceof PolylineN){

PolylineN polyline = (PolylineN) geom;

EnvelopeN extent = (EnvelopeN) polyline.getExtent();

System.out.println("Extent - XMin,YMin: " + extent.getXMin() + "," + extent.getYMin() + " XMax,YMax: " + extent.getXMax() + "," + extent.getYMax());

}

}
``````

11/8/2016