Method Buffer
Buffer(Geometry, Double)
Creates a buffer polygon at the specified distance around the given geometry. This is a planar buffer operation. Use BufferGeodetic(Geometry, Double, LinearUnit, Double, GeodeticCurveType) to produce geodetic buffers.
Declaration
public static Geometry Buffer(this Geometry geometry, double distance)
Parameters
Type | Name | Description |
---|---|---|
Geometry | geometry | Specifies the input geometry. |
System.Double | distance | The distance to buffer the geometry. It must be in the same units as the geometry's spatial reference. |
Returns
Type | Description |
---|---|
Geometry | A Polygon that represents a buffer at the desired distance relative to the given geometry. |
Remarks
Planar measurements of distance and area can be extremely inaccurate if using an unsuitable spatial reference. Ensure that you understand the potential for error with the geometry's spatial reference. If you need to calculate more accurate results consider using a different spatial reference, or using the geodetic equivalent, BufferGeodetic(Geometry, Double, LinearUnit, Double, GeodeticCurveType). See Spatial References for more information about spatial references.
Supports true curves as input, producing a densified curve as output where applicable.
The polygon geometry that is generated from this Static Method is based upon the SpatialReference of the input geometry. A SpatialReference is a combination of an ellipsoid, datum, and a coordinate system used to display (aka. project) geographic data of the three dimensional Earth on a two dimensional surface (such as a piece of paper of computer monitor). A good article for describing how a spatial reference works can be found here. The important thing to know about creating buffers is that some SpatialReferences are better than others for getting accurate results. To get the most accurate buffer polygons using this method, consider using an 'area preserving' SpatialReference such as: Albers, Lambert, Mollweide, Hammer, Sinusoidal, and the like. If the input geometry to this method is not based on a good 'area preserving' SpatialReference, then there are two options available to produce accurate buffers: (1) use the Project(Geometry, SpatialReference) Static Method to project the geometry to a coordinate system that is better suited for buffers or (2) use the BufferGeodetic(Geometry, Double, LinearUnit, Double, GeodeticCurveType) Static Method which will use an internal projection algorithm to convert the geometry to a spherical coordinate system to obtain the most accurate buffers possible. See the Make measurements topic in the developers guide for more information.
Applies to
Platforms and versions
Target | Versions |
---|---|
.NET Standard 2.0 | 100.3 - 200.5 |
.NET | 100.13 - 200.5 |
.NET Windows | 100.13 - 200.5 |
.NET Android | 200.0 - 200.5 |
.NET iOS | 200.0 - 200.5 |
.NET Framework | 100.0 - 200.5 |
Xamarin.Android | 100.0 - 100.15 |
Xamarin.iOS | 100.0 - 100.15 |
UWP | 100.0 - 200.5 |
Relevant samples
Buffer(IEnumerable<Geometry>, IEnumerable<Double>, Boolean)
Creates and returns a buffer relative to the given geometries. This is a planar buffer operation. Use BufferGeodetic(Geometry, Double, LinearUnit, Double, GeodeticCurveType) to produce geodetic buffers.
Declaration
public static IEnumerable<Geometry> Buffer(IEnumerable<Geometry> geometries, IEnumerable<double> distances, bool unionResult)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<Geometry> | geometries | A collection of geometries. |
System.Collections.Generic.IEnumerable<System.Double> | distances | The distance to buffer each geometry, expressed as a sequence of double. If the size of the distances collection is less than the number of geometries, the last distance value is used for the rest of geometries. |
System.Boolean | unionResult | Returns a single geometry that buffers all the geometries (true), or one buffer for each in the given collection (false). |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<Geometry> | A collection of polygon geometries that represent a buffer at the desired distance(s) around the given geometries.
If |
Remarks
The geometries must have the same spatial reference. Planar measurements of distance and area can be extremely
inaccurate if using an unsuitable spatial reference. Ensure that you understand the potential for error with the
geometry's spatial reference. If you need to calculate
more accurate results consider using a different spatial reference, or using the geodetic equivalent,
BufferGeodetic(IEnumerable<Geometry>, IEnumerable<Double>, LinearUnit, Double, GeodeticCurveType, Boolean).
See the document
Spatial References
for more information about spatial references. If unionResult
is true
, the
output collection will contain a single result. If geometries is empty, an empty array is returned.
Supports true curves as input, producing a densified curve as output where applicable.
This method allows for the creation of different buffered output geometry sizes for each input in the geometries collection based upon the values in the distances collection. Under most circumstances, there would be a one-to-one correspondence of input geometries to the input buffer distances. However, it is possible to have fewer input buffer distances than input geometries. In this case, the last distance value in the buffer distances collection will be used for the rest of the geometries. In an extreme case, one could specify a single buffer value in the input buffer distances collection and that value would apply to all of the input geometries collection.
The polygons generated from this Static Method are based upon the SpatialReference of the input geometries. A SpatialReference is a combination of an ellipsoid, datum, and a coordinate system used to display (aka. project) geographic data of the three dimensional Earth on a two dimensional surface (such as a piece of paper or computer monitor). A good article for describing how a spatial reference works can be found here. The important thing to know about creating buffers is that some SpatialReferences are better than others for getting accurate results. To get the most accurate buffer polygons using this method, consider using an 'area preserving' SpatialReference such as: Albers, Lambert, Mollweide, Hammer, Sinusoidal, and the like. If the input geometries to this method are not based on a good 'area preserving' SpatialReference, then there are two options available to produce accurate buffers: (1) use the Project(Geometry, SpatialReference) Static Method to project the geometry to a coordinate system that is better suited for buffers or (2) use the BufferGeodetic(IEnumerable<Geometry>, IEnumerable<Double>, LinearUnit, Double, GeodeticCurveType, Boolean) Static Method which will use an internal projection algorithm to convert the geometry to a spherical coordinate system to obtain the most accurate buffers possible. See the Make measurements topic in the developers guide for more information.
Applies to
Platforms and versions
Target | Versions |
---|---|
.NET Standard 2.0 | 100.3 - 200.5 |
.NET | 100.13 - 200.5 |
.NET Windows | 100.13 - 200.5 |
.NET Android | 200.2 - 200.5 |
.NET iOS | 200.0 - 200.5 |
.NET Framework | 100.1 - 200.5 |
Xamarin.Android | 100.1 - 100.14 |
Xamarin.iOS | 100.1 - 100.15 |
UWP | 100.1 - 200.5 |