Geometry service Buffer method
The Buffer method buffers an array of geometries by each distance specified in an array of distances. The distances can be specified in any linear unit of measure. Geometries buffered at a given distance can optionally be unioned together.
Buffer(SpatialReference InSpatialReference, SpatialReference BufferSpatialReference, SpatialReference OutSpatialReference, double[] Distances, Unit Unit, boolean UnionResults, Geometry[] InGeometryArray)
Parameter |
Description |
---|---|
InSpatialReference |
The SpatialReference of the geometries in the InGeometryArray parameter. This cannot be null. |
BufferSpatialReference |
The SpatialReference in which the geometries are buffered. This can be null. |
OutSpatialReference |
The SpatialReference of the geometry returned from the buffer operation. This can be null. |
Distances |
An array of double values. Each value specifies a distance to buffer the input geometries. |
Unit |
The units for each distance specified in the Distances array (optional). |
UnionResults |
If false, each buffer polygon will be added to the output Geometry array separately. If true, then all geometries buffered at a given distance will be unioned into a single (possibly multi-part) polygon and included in the output Geometry array. |
InGeometryArray |
The array of geometry to be buffered by each distance in the array Distances. All geometries are assumed to be in the coordinate system referenced in the InSpatialReference parameter. |
Remarks
Either or both the BufferSpatialReference and OutSpatialReference can be null. If one is not null, the other is used for both buffering and output. In any case, the distances can be specified with a separate unit of measure defined by the Unit parameter to the method. For example, the buffer distances can be specified in feet and the coordinates of the output geometries can be specified in meters, although both the buffer and output geometry share the same spatial reference.
The SpatialReference property for all returned geometry will be null. It is the consumer's responsibility to assign the spatial reference to each geometry returned, if desired. In this case, the spatial reference is assumed to be the output spatial reference defined for the Buffer operation.
Buffering of geometries with latitude-longitude coordinates is only supported for points and multipoints. In order to meaningfully buffer polylines and polygons with such coordinates, you need to specify a planar (projected) coordinate system in which the buffering will happen. Use the BufferSpatialReference parameter to define this coordinate system. When the Buffer method is called, the input features will be projected into this coordinate system (BufferSpatialReference), buffered, and then either inverse projected into the original coordinate system (InSpatialReference) or projected into the output coordinate system (OutSpatialReference).
In order to minimize the errors it is recommended the user chooses a projection appropriate to the geometries for buffering. For a geometry or set of geometries that are in a circular pattern, an azimuthal equidistant projection with a point of tangency at the center of the geometry(s) is recommended. If the geometry or set of geometries have a linear arrangement, then it might be possible to use a hotine (oblique Mercator) projection whose line of tangency falls along the linear trend of the geometry or geometries in question.
Examples
C#
Geometry_GeometryServer geometryService = new Geometry_GeometryServer();
geometryService.Url = "http://localhost:6080/arcgis/services/Geometry/GeometryServer";
SpatialReference inputSpatialReference = new GeographicCoordinateSystem();
inputSpatialReference.WKT = "GEOGCS[\"GCS_WGS_1984\",DATUM[\"D_WGS_1984\",SPHEROID[\"WGS_1984\",6378137.0,298.257223563]],PRIMEM[\"Greenwich\",0.0],UNIT[\"Degree\",0.0174532925199433]]";
SpatialReference bufferSpatialReference = new ProjectedCoordinateSystem();
// USA_Contiguous_Lambert_Conformal_Conic
bufferSpatialReference.WKID = 102004;
bufferSpatialReference.WKIDSpecified = true;
SpatialReference outputSpatialReference = inputSpatialReference;
PointN inputPoint1 = new PointN();
inputPoint1.X = -120;
inputPoint1.Y = 45;
PointN inputPoint2 = new PointN();
inputPoint2.X = -110;
inputPoint2.Y = 40;
Geometry[] inputGeometry = new Geometry[] { inputPoint1, inputPoint2 };
double[] distances = new double[] {200, 400 };
LinearUnit linearUnit = new LinearUnit();
// US survey mile
linearUnit.WKID = 9035;
linearUnit.WKIDSpecified = true;
bool unionResults = false;
Geometry[] outputGeometry = geometryService.Buffer(inputSpatialReference, bufferSpatialReference, outputSpatialReference,
distances, linearUnit, unionResults, inputGeometry);
VB.NET
Dim geomeTryService As Geometry_GeometryServer = New Geometry_GeometryServer()
geomeTryService.Url = "http://localhost:6080/arcgis/services/Geometry/GeometryServer"
Dim inputSpatialReference As SpatialReference = New GeographicCoordinateSystem()
inputSpatialReference.WKT="GEOGCS[""GCS_WGS_1984"",DATUM[""D_WGS_1984"",SPHEROID[""WGS_1984"",6378137.0,298.257223563]],PRIMEM[""Greenwich"",0.0],UNIT[""Degree"",0.0174532925199433]]"
Dim bufferSpatialReference As SpatialReference = New ProjectedCoordinateSystem()
' USA_Contiguous_Lambert_Conformal_Conic
bufferSpatialReference.WKID = 102004
bufferSpatialReference.WKIDSpecified = True
Dim outputSpatialReference As SpatialReference = inputSpatialReference
Dim inputPoint1 As PointN = New PointN()
inputPoint1.X = -120
inputPoint1.Y = 45
Dim inputPoint2 As PointN = New PointN()
inputPoint2.X = -110
inputPoint2.Y = 40
Dim inputGeomeTry() As Geometry = New Geometry() {inputPoint1, inputPoint2}
Dim distances() As Double = New Double() {200, 400}
Dim linearUnit As LinearUnit = New LinearUnit()
' US survey mile
linearUnit.WKID = 9035
linearUnit.WKIDSpecified = True
Dim unionResults As Boolean = False
Dim outputGeomeTry As Geometry() = geomeTryService.Buffer(inputSpatialReference, bufferSpatialReference, _
outputSpatialReference, distances, linearUnit, unionResults, inputGeomeTry)
Java
String serviceURL = "http://localhost:6080/arcgis/services/Geometry/GeometryServer";
GeometryServerBindingStub geometryService = new GeometryServerBindingStub(serviceURL);
SpatialReference inputSpatialReference = new GeographicCoordinateSystem();
inputSpatialReference
.setWKT("GEOGCS[\"GCS_WGS_1984\",DATUM[\"D_WGS_1984\",SPHEROID[\"WGS_1984\",6378137.0,298.257223563]],PRIMEM[\"Greenwich\",0.0],UNIT[\"Degree\",0.0174532925199433]]");
//Set buffer spatial reference
SpatialReference bufferSpatialReference = new ProjectedCoordinateSystem();
bufferSpatialReference.setWKID(102004);// USA_Contiguous_Lambert_Conformal_Conic
//Set output spatial reference
SpatialReference outputSpatialReference = inputSpatialReference;
//Input points
PointN inputPoint1 = new PointN();
inputPoint1.setX(-110);
inputPoint1.setY(40);
PointN inputPoint2 = new PointN();
inputPoint2.setX(-120);
inputPoint2.setY(45);
//Input geometry
Geometry[] inputGeometry = new Geometry[] { inputPoint1, inputPoint2 };
//Distance for buffer for each point
double[] distances = new double[] { 400, 200 };
//Set the unit
LinearUnit linearUnit = new LinearUnit();
linearUnit.setWKID(9035);
boolean bUnionResults = false;
//Run the buffer operation
Geometry[] outputGeometry = geometryService.buffer(
inputSpatialReference, bufferSpatialReference, outputSpatialReference,
distances, linearUnit, bUnionResults, inputGeometry);
for (Geometry geom : outputGeometry) {
if (geom instanceof PolygonN){
PolygonN polygon = (PolygonN) geom;
EnvelopeN extent = (EnvelopeN) polygon.getExtent();
System.out.println("Extent - XMin,YMin: " + extent.getXMin() + "," + extent.getYMin() + " XMax,YMax: " + extent.getXMax() + "," + extent.getYMax());
}
}