-
Notifications
You must be signed in to change notification settings - Fork 121
ProSnippets Geometry
Language: C#
Subject: Geometry
Contributor: ArcGIS Pro SDK Team <[email protected]>
Organization: Esri, http://www.esri.com
Date: 7/13/2015
ArcGIS Pro: ArcGIS Pro 1.1
Visual Studio: 2013, 2015
##Construct a SpatialReference - with a Well Known ID
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
// use the builder constructor
SpatialReferenceBuilder srBuilder = new SpatialReferenceBuilder(3857);
SpatialReference sr3857 = srBuilder.ToSpatialReference();
// or use the convenience method
SpatialReference sr_3857 = SpatialReferenceBuilder.CreateSpatialReference(3857);
});
##Construct a SpatialReference - from a string
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
string wkt = "GEOGCS[\"MyGCS84\",DATUM[\"D_WGS_1984\",SPHEROID[\"WGS_1984\",6378137.0,298.257223563]],PRIMEM[\"Greenwich\",0.0],UNIT[\"Radian\",1.0]]";
// use the builder constructor
SpatialReferenceBuilder builder = new SpatialReferenceBuilder(wkt);
SpatialReference sr = builder.ToSpatialReference();
// or use the convenience method
SpatialReference anotherSR = SpatialReferenceBuilder.CreateSpatialReference(wkt);
});
##Use WGS84 SpatialReference
SpatialReference wgs84 = SpatialReferences.WGS84;
bool isProjected = wgs84.IsProjected; // false
bool isGeographic = wgs84.IsGeographic; // true
##Construct a MapPoint
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
// create a 3d point with M
// use the builder constructor
MapPointBuilder mb = new MapPointBuilder(1.0, 2.0, 3.0, 4.0);
MapPoint ptWithM = mb.ToGeometry();
MapPoint clone = ptWithM.Clone() as MapPoint;
// or use the convenience methods
MapPoint anotherPt = MapPointBuilder.CreateMapPoint(1.0, 2.0, 3.0, 4.0);
MapPoint anotherM = MapPointBuilder.CreateMapPoint(ptWithM);
});
##MapPoint Builder Properties
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
MapPointBuilder mb = new MapPointBuilder();
bool isEmpty = mb.IsEmpty; // isEmpty = true
mb.SetValues(1.0, 2.0, 3.0);
bool hasZ = mb.HasZ; // hasZ = true
bool hasM = mb.HasM; // hasM = false
MapPoint pt = mb.ToGeometry();
double x = pt.X;
double y = pt.Y;
double z = pt.Z;
double m = pt.M; // m = Nan
isEmpty = pt.IsEmpty; // isEmpty = false
});
##Construct a Polyline - from an enumeration of MapPoints
// methods need to run on MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
MapPoint startPt = MapPointBuilder.CreateMapPoint(1.0, 1.0);
MapPoint endPt = MapPointBuilder.CreateMapPoint(2.0, 1.0);
List<MapPoint> list = new List<MapPoint>();
list.Add(startPt);
list.Add(endPt);
// use the builder constructor
PolylineBuilder pb = new PolylineBuilder(list);
pb.SpatialReference = SpatialReferences.WGS84;
Polyline polyline1 = pb.ToGeometry();
// or use the convenience method
Polyline polyline2 = PolylineBuilder.CreatePolyline(list, SpatialReferences.WGS84);
});
##Get the points of a Polyline
// get the points as a readonly Collection
ReadOnlyPointCollection pts = polyline.Points;
int numPts = polyline.PointCount;
// get an enumeration of the points
IEnumerator<MapPoint> enumPts = polyline.Points.GetEnumerator();
// get the point coordinates as a readonly list
IReadOnlyList<Coordinate> coordinates = polyline.CopyCoordinatesToList();
##Get the parts of a Polyline
int numParts = polyline.PartCount;
// get the parts as a readonly collection
ReadOnlyPartCollection parts = polyline.Parts;
##Enumerate the parts of a Polyline
ReadOnlyPartCollection polylineParts = polyline.Parts;
// enumerate the segments to get the length
double len = 0;
IEnumerator<ReadOnlySegmentCollection> segments = polylineParts.GetEnumerator();
while (segments.MoveNext())
{
ReadOnlySegmentCollection seg = segments.Current;
foreach (Segment s in seg)
{
len += s.Length;
// perhaps do something specific per segment type
switch (s.SegmentType)
{
case SegmentType.Line:
break;
case SegmentType.Bezier:
break;
case SegmentType.EllipticArc:
break;
}
}
}
##Reverse the order of points in a Polyline
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
PolylineBuilder polylineBuilder = new PolylineBuilder(polyline);
polylineBuilder.ReverseOrientation();
Polyline reversedPolyline = polylineBuilder.ToGeometry();
});
##Build a multi-part Polyline
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
List<MapPoint> firstPoints = new List<MapPoint>();
firstPoints.Add(MapPointBuilder.CreateMapPoint(1.0, 1.0));
firstPoints.Add(MapPointBuilder.CreateMapPoint(1.0, 2.0));
firstPoints.Add(MapPointBuilder.CreateMapPoint(2.0, 2.0));
firstPoints.Add(MapPointBuilder.CreateMapPoint(2.0, 1.0));
List<MapPoint> nextPoints = new List<MapPoint>();
nextPoints.Add(MapPointBuilder.CreateMapPoint(11.0, 1.0));
nextPoints.Add(MapPointBuilder.CreateMapPoint(11.0, 2.0));
nextPoints.Add(MapPointBuilder.CreateMapPoint(12.0, 2.0));
nextPoints.Add(MapPointBuilder.CreateMapPoint(12.0, 1.0));
PolylineBuilder pBuilder = new PolylineBuilder(firstPoints);
pBuilder.AddPart(nextPoints);
Polyline p = pBuilder.ToGeometry();
// polyline p has 2 parts
pBuilder.RemovePart(0);
p = pBuilder.ToGeometry();
// polyline p has 1 part
});
##Split Polyline at distance
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
// create list of points
MapPoint startPt = MapPointBuilder.CreateMapPoint(1.0, 1.0);
MapPoint endPt = MapPointBuilder.CreateMapPoint(2.0, 1.0);
List<MapPoint> list = new List<MapPoint>();
list.Add(startPt);
list.Add(endPt);
// use the PolylineBuilder as we wish to manipulate the geometry
PolylineBuilder polylineBuilder = new PolylineBuilder(list);
// split at a distance 0.75
polylineBuilder.SplitAtDistance(0.75, false);
// get the polyline
Polyline p = polylineBuilder.ToGeometry();
// polyline p should have 3 points (1,1), (1.75, 1), (2,1)
// add another path
MapPoint p1 = MapPointBuilder.CreateMapPoint(4.0, 1.0);
MapPoint p2 = MapPointBuilder.CreateMapPoint(6.0, 1.0);
MapPoint p3 = MapPointBuilder.CreateMapPoint(7.0, 1.0);
List<MapPoint> pts = new List<MapPoint>();
pts.Add(p1);
pts.Add(p2);
pts.Add(p3);
polylineBuilder.AddPart(pts);
p = polylineBuilder.ToGeometry();
// polyline p has 2 parts. Each part has 3 points
// split the 2nd path half way - dont create a new path
polylineBuilder.SplitPartAtDistance(1, 0.5, true, false);
p = polylineBuilder.ToGeometry();
// polyline p still has 2 parts; but now has 7 points
});
##Construct a Polygon - from an enumeration of MapPoints
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
MapPoint pt1 = MapPointBuilder.CreateMapPoint(1.0, 1.0);
MapPoint pt2 = MapPointBuilder.CreateMapPoint(1.0, 2.0);
MapPoint pt3 = MapPointBuilder.CreateMapPoint(2.0, 2.0);
MapPoint pt4 = MapPointBuilder.CreateMapPoint(2.0, 1.0);
List<MapPoint> list = new List<MapPoint>();
list.Add(pt1);
list.Add(pt2);
list.Add(pt3);
list.Add(pt4);
// use the builder constructor
PolygonBuilder pb = new PolygonBuilder(list);
pb.SpatialReference = SpatialReferences.WGS84;
Polygon polygon = pb.ToGeometry();
// or use the convenience method
Polygon anotherPolygon = PolygonBuilder.CreatePolygon(list, SpatialReferences.WGS84);
});
##Construct a Polygon - from an Envelope
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
MapPoint minPt = MapPointBuilder.CreateMapPoint(1.0, 1.0);
MapPoint maxPt = MapPointBuilder.CreateMapPoint(2.0, 2.0);
// Create an envelope
Envelope env = EnvelopeBuilder.CreateEnvelope(minPt, maxPt);
// Create a polygon from the envelope
Polygon polygon = PolygonBuilder.CreatePolygon(env);
});
##Get the points of a Polygon
// get the points as a readonly Collection
ReadOnlyPointCollection pts = poly.Points;
// get an enumeration of the points
IEnumerator<MapPoint> enumPts = poly.Points.GetEnumerator();
// get the point coordinates as a readonly list
IReadOnlyList<Coordinate> coordinates = poly.CopyCoordinatesToList();
##Get the parts of a Polygon
// get the parts as a readonly collection
ReadOnlyPartCollection parts = poly.Parts;
##Enumerate the parts of a Polygon
int numSegments = 0;
IEnumerator<ReadOnlySegmentCollection> segments = poly.Parts.GetEnumerator();
while (segments.MoveNext())
{
ReadOnlySegmentCollection seg = segments.Current;
numSegments += seg.Count;
foreach (Segment s in seg)
{
// do something with the segment
}
}
##Build a donut polygon
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
List<Coordinate2D> outerCoordinates = new List<Coordinate2D>();
outerCoordinates.Add(new Coordinate2D(10.0, 10.0));
outerCoordinates.Add(new Coordinate2D(10.0, 20.0));
outerCoordinates.Add(new Coordinate2D(20.0, 20.0));
outerCoordinates.Add(new Coordinate2D(20.0, 10.0));
// use the PolygonBuilder as we wish to manipulate the parts
PolygonBuilder pb = new PolygonBuilder(outerCoordinates);
Polygon donut = pb.ToGeometry();
double area = donut.Area; // area = 100
// define the inner polygon as anti-clockwise
List<Coordinate2D> innerCoordinates = new List<Coordinate2D>();
innerCoordinates.Add(new Coordinate2D(13.0, 13.0));
innerCoordinates.Add(new Coordinate2D(17.0, 13.0));
innerCoordinates.Add(new Coordinate2D(17.0, 17.0));
innerCoordinates.Add(new Coordinate2D(13.0, 17.0));
pb.AddPart(innerCoordinates);
donut = pb.ToGeometry();
area = donut.Area; // area = 84.0
});
##Construct an Envelope
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
MapPoint minPt = MapPointBuilder.CreateMapPoint(1.0, 1.0);
MapPoint maxPt = MapPointBuilder.CreateMapPoint(2.0, 2.0);
EnvelopeBuilder ev = new EnvelopeBuilder(minPt, maxPt);
Envelope env = ev.ToGeometry();
});
##Union two Envelopes
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
Envelope env1 = EnvelopeBuilder.CreateEnvelope(0, 0, 1, 1, SpatialReferences.WGS84);
Envelope env2 = EnvelopeBuilder.CreateEnvelope(0.5, 0.5, 1.5, 1.5, SpatialReferences.WGS84);
Envelope env3 = env1.Union(env2);
});
##Expand an Envelope
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
Envelope envelope = EnvelopeBuilder.CreateEnvelope(100.0, 100.0, 500.0, 500.0);
Envelope result = envelope.Expand(0.5, 0.5, true);
});
##Construct a Multipoint - from an enumeration of MapPoints
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
List<MapPoint> list = new List<MapPoint>();
list.Add(MapPointBuilder.CreateMapPoint(1.0, 1.0));
list.Add(MapPointBuilder.CreateMapPoint(1.0, 2.0));
list.Add(MapPointBuilder.CreateMapPoint(2.0, 2.0));
list.Add(MapPointBuilder.CreateMapPoint(2.0, 1.0));
// use the builder constructor
MultipointBuilder mpb = new MultipointBuilder(list);
Multipoint mPt = mpb.ToGeometry();
// or use the convenience method
Multipoint multiPoint = MultipointBuilder.CreateMultipoint(list);
});
##Modify the points of a Multipoint
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
// assume a multiPoint has been built from 4 points
// the modified multiPoint will have the first point removed and the last point moved
MultipointBuilder mpb = new MultipointBuilder(multiPt);
// remove the first point
mpb.RemovePoint(0);
// modify the coordinates of the last point
MapPoint pt = mpb.GetMapPoint(mpb.PointCount-1);
mpb.RemovePoint(mpb.PointCount - 1);
MapPoint newPt = MapPointBuilder.CreateMapPoint(pt.X + 1.0, pt.Y + 2.0);
mpb.Add(newPt);
Multipoint modifiedMultiPoint = mpb.ToGeometry();
});
##Construct a LineSegment using two MapPoints
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
MapPoint startPt = MapPointBuilder.CreateMapPoint(1.0, 1.0);
MapPoint endPt = MapPointBuilder.CreateMapPoint(2.0, 1.0);
// use the builder constructor
LineBuilder lb = new LineBuilder(startPt, endPt);
LineSegment line = lb.ToSegment();
// or use the convenience method
LineSegment anotherLine = LineBuilder.CreateLineSegment(startPt, endPt);
});
##Construct a Cubic Bezier - from Coordinates
// builders need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
Coordinate startPt = new Coordinate(1.0, 1.0, 3.0);
Coordinate endPt = new Coordinate(2.0, 2.0, 3.0);
Coordinate2D ctrl1Pt = new Coordinate2D(1.0, 2.0);
Coordinate2D ctrl2Pt = new Coordinate2D(2.0, 1.0);
// use the builder constructor
CubicBezierBuilder cbb = new CubicBezierBuilder(startPt, ctrl1Pt, ctrl2Pt, endPt, SpatialReferences.WGS84);
CubicBezierSegment bezier = cbb.ToSegment();
// or use the convenience method
CubicBezierSegment anotherBezier = CubicBezierBuilder.CreateCubicBezierSegment(startPt, ctrl1Pt, ctrl2Pt, endPt, SpatialReferences.WGS84);
});
##Construct a Cubic Bezier - from MapPoints
// builders need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
MapPoint startPt = MapPointBuilder.CreateMapPoint(1.0, 1.0, SpatialReferences.WGS84);
MapPoint endPt = MapPointBuilder.CreateMapPoint(2.0, 2.0, SpatialReferences.WGS84);
MapPoint ctrl1Pt = MapPointBuilder.CreateMapPoint(1.0, 2.0, SpatialReferences.WGS84);
MapPoint ctrl2Pt = MapPointBuilder.CreateMapPoint(2.0, 1.0, SpatialReferences.WGS84);
// use the builder constructor
CubicBezierBuilder cbb = new CubicBezierBuilder(startPt, ctrl1Pt, ctrl2Pt, endPt);
CubicBezierSegment bezier = cbb.ToSegment();
// or use the convenience method
CubicBezierSegment anotherBezier = CubicBezierBuilder.CreateCubicBezierSegment(startPt, ctrl1Pt, ctrl2Pt, endPt);
});
##Construct a Cubic Bezier - from an enumeration of MapPoints
// builders need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
MapPoint startPt = MapPointBuilder.CreateMapPoint(1.0, 1.0, SpatialReferences.WGS84);
MapPoint endPt = MapPointBuilder.CreateMapPoint(2.0, 2.0, SpatialReferences.WGS84);
MapPoint ctrl1Pt = MapPointBuilder.CreateMapPoint(1.0, 2.0, SpatialReferences.WGS84);
MapPoint ctrl2Pt = MapPointBuilder.CreateMapPoint(2.0, 1.0, SpatialReferences.WGS84);
List<MapPoint> listMapPoints = new List<MapPoint>();
listMapPoints.Add(startPt);
listMapPoints.Add(ctrl1Pt);
listMapPoints.Add(ctrl2Pt);
listMapPoints.Add(endPt);
// use the builder constructor
CubicBezierBuilder cbb = new CubicBezierBuilder(listMapPoints);
CubicBezierSegment bezier = cbb.ToSegment();
// or use the convenience method
CubicBezierSegment anotherBezier = CubicBezierBuilder.CreateCubicBezierSegment(listMapPoints);
});
##Cubic Bezier Builder Properties
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
// retrieve the bezier curve's control points
CubicBezierBuilder cbb = new CubicBezierBuilder(bezierSegment);
MapPoint startPt = cbb.StartPoint;
Coordinate2D ctrlPt1 = cbb.ControlPoint1;
Coordinate2D ctrlPt2 = cbb.ControlPoint2;
MapPoint endPt = cbb.EndPoint;
// or use the QueryCoords method
cbb.QueryCoords(out startPt, out ctrlPt1, out ctrlPt2, out endPt);
});
##Cubic Bezier Properties
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
// retrieve the bezier curve's control points
CubicBezierSegment cb = CubicBezierBuilder.CreateCubicBezierSegment(bezierSegment);
MapPoint startPt = cb.StartPoint;
Coordinate2D ctrlPt1 = cb.ControlPoint1;
Coordinate2D ctrlPt2 = cb.ControlPoint2;
MapPoint endPt = cb.EndPoint;
bool isCurve = cb.IsCurve;
double len = cb.Length;
});
##Construct a Polyline (from a Cubic Bezier)
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
Polyline polyline = PolylineBuilder.CreatePolyline(bezierSegment);
});
##Construct a Circular Arc
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
// Construct a circular arc from (2, 1) to (1, 2) with interior pt (1 + sqrt(2)/2, 1 + sqrt(2)/2).
Coordinate fromPt = new Coordinate(2, 1);
Coordinate toPt = new Coordinate(1, 2);
Coordinate2D interiorPt = new Coordinate2D(1 + Math.Sqrt(2) / 2, 1 + Math.Sqrt(2) / 2);
// use the builder constructor
EllipticArcBuilder cab = new EllipticArcBuilder(fromPt.ToMapPoint(), toPt.ToMapPoint(), interiorPt);
EllipticArcSegment circularArc = cab.ToSegment();
// or use the convenience method
EllipticArcSegment anotherCircularArc = EllipticArcBuilder.CreateEllipticArcSegment(fromPt.ToMapPoint(), toPt.ToMapPoint(), interiorPt);
});
##Construct a Circle
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
// Construct a circle with center at (-1,-1), radius = 2, and oriented clockwise.
Coordinate2D centerPtCoord = new Coordinate2D(-1, -1);
// use the builder constructor
EllipticArcBuilder builder = new EllipticArcBuilder(centerPtCoord, 2, esriArcOrientation.esriArcClockwise);
EllipticArcSegment circle = builder.ToSegment();
// or use the convenience method
EllipticArcSegment anotherCircle = EllipticArcBuilder.CreateEllipticArcSegment(centerPtCoord, 2, esriArcOrientation.esriArcClockwise);
});
##Construct an Ellipse
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
// Construct an ellipse centered at (1, 2) with rotationAngle = -pi/6,
// semiMajorAxis = 5, minorMajorRatio = 0.2, oriented clockwise
Coordinate2D centerPt = new Coordinate2D(1, 2);
// use the builder constructor
EllipticArcBuilder builder = new EllipticArcBuilder(centerPt, -1 * Math.PI / 6, 5, 0.2, esriArcOrientation.esriArcClockwise);
EllipticArcSegment ellipse = builder.ToSegment();
// or use the convenience method
EllipticArcSegment anotherEllipse = EllipticArcBuilder.CreateEllipticArcSegment(centerPt, -1 * Math.PI / 6, 5, 0.2, esriArcOrientation.esriArcClockwise);
});
##Elliptic Arc Builder Properties
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
// retrieve the curve's control points
EllipticArcBuilder builder = new EllipticArcBuilder(arcSegment);
MapPoint startPt = builder.StartPoint;
MapPoint endPt = builder.EndPoint;
Coordinate2D centerPt = builder.CenterPoint;
bool isCircular = builder.IsCircular;
bool isMinor = builder.IsMinor;
});
##Elliptic Arc Properties
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
// retrieve the curve's control points
EllipticArcSegment arc = EllipticArcBuilder.CreateEllipticArcSegment(arcSegment);
MapPoint startPt = arc.StartPoint;
MapPoint endPt = arc.EndPoint;
Coordinate2D centerPt = arc.CenterPoint;
bool isCircular = arc.IsCircular;
bool isMinor = arc.IsMinor;
double startAngle, centralAngle, rotationAngle, semiMajorAxis, semiMinorAxis;
// or use QueryCoords
arc.QueryCoords(out centerPt, out startAngle, out centralAngle, out rotationAngle, out semiMajorAxis, out semiMinorAxis);
});
##Get the individual parts of a multipart feature
/// <summary>
/// This method takes an input multi part geometry and breaks the parts into individual standalone geometries.
/// This method must be called on the MCT. Use QueuedTask.Run.
/// </summary>
/// <param name="inputGeometry">The geometry to be exploded into the individual parts.</param>
/// <returns>An enumeration of individual parts as standalone geometries. The type of geometry is maintained, i.e.
/// if the input geometry is of type Polyline then each geometry in the return is of type Polyline as well.
/// If the input geometry is of type Unknown then an empty list is returned.</returns>
/// <remarks>This method must be called on the MCT. Use QueuedTask.Run.</remarks>
public IEnumerable<Geometry> MultipartToSinglePart(Geometry inputGeometry)
{
// list holding the part(s) of the input geometry
List<Geometry> singleParts = new List<Geometry>();
// check if the input is a null pointer or if the geometry is empty
if (inputGeometry == null || inputGeometry.IsEmpty)
return singleParts;
// based on the type of geometry, take the parts/points and add them individually into a list
switch (inputGeometry.GeometryType)
{
case GeometryType.Envelope:
singleParts.Add(inputGeometry.Clone() as Envelope);
break;
case GeometryType.Multipatch:
singleParts.Add(inputGeometry.Clone() as Multipatch);
break;
case GeometryType.Multipoint:
var multiPoint = inputGeometry as Multipoint;
foreach (var point in multiPoint.Points)
{
// add each point of collection as a standalone point into the list
singleParts.Add(point);
}
break;
case GeometryType.Point:
singleParts.Add(inputGeometry.Clone() as MapPoint);
break;
case GeometryType.Polygon:
var polygon = inputGeometry as Polygon;
foreach (var polygonPart in polygon.Parts)
{
// use the PolygonBuilder turning the segments into a standalone
// polygon instance
singleParts.Add(PolygonBuilder.CreatePolygon(polygonPart));
}
break;
case GeometryType.Polyline:
var polyline = inputGeometry as Polyline;
foreach (var polylinePart in polyline.Parts)
{
// use the PolylineBuilder turning the segments into a standalone
// polyline instance
singleParts.Add(PolylineBuilder.CreatePolyline(polylinePart));
}
break;
case GeometryType.Unknown:
break;
default:
break;
}
return singleParts;
}
##Get the outermost rings of a polygon
/// <summary>
/// The methods retrieves the outer ring(s) of the input polygon.
/// This method must be called on the MCT. Use QueuedTask.Run.
/// </summary>
/// <param name="inputPolygon">Input Polygon.</param>
/// <returns>The outer most (exterior, clockwise) ring(s) of the polygon. If the input is null or empty, a null pointer is returned.</returns>
/// <remarks>This method must be called on the MCT. Use QueuedTask.Run.</remarks>
public Polygon GetOutermostRings(Polygon inputPolygon)
{
if (inputPolygon == null || inputPolygon.IsEmpty)
return null;
PolygonBuilder outerRings = new PolygonBuilder();
List<Polygon> internalRings = new List<Polygon>();
// explode the parts of the polygon into a list of individual geometries
var parts = MultipartToSinglePart(inputPolygon);
// get an enumeration of clockwise geometries (area > 0) ordered by the area
var clockwiseParts = parts.Where(geom => ((Polygon)geom).Area > 0).OrderByDescending(geom => ((Polygon)geom).Area);
// for each of the exterior rings
foreach (var part in clockwiseParts)
{
// add the first (the largest) ring into the internal collection
if (internalRings.Count == 0)
internalRings.Add(part as Polygon);
// use flag to indicate if current part is within the already selection polygons
bool isWithin = false;
foreach (var item in internalRings)
{
if (GeometryEngine.Within(part, item))
isWithin = true;
}
// if the current polygon is not within any polygon of the internal collection
// then it is disjoint and needs to be added to
if (isWithin == false)
internalRings.Add(part as Polygon);
}
// now assemble a new polygon geometry based on the internal polygon collection
foreach (var ring in internalRings)
{
outerRings.AddParts(ring.Parts);
}
// return the final geometry of the outer rings
return outerRings.ToGeometry();
}
##Retrieve Geometry from Geodatabase
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
try
{
// open a gdb
ArcGIS.Core.Data.Geodatabase gdb = new ArcGIS.Core.Data.Geodatabase(@"c:\Temp\MyDatabase.gdb");
//Open a featureClass
ArcGIS.Core.Data.FeatureClass featureClass = gdb.OpenDataset<ArcGIS.Core.Data.FeatureClass>("Polygon") as ArcGIS.Core.Data.FeatureClass;
// find a field
ArcGIS.Core.Data.FeatureClassDefinition featureClassDefinition = featureClass.GetDefinition() as ArcGIS.Core.Data.FeatureClassDefinition;
int fldIndex = featureClassDefinition.FindField("SomeField");
if (fldIndex == -1)
{
return;
}
ArcGIS.Core.Data.QueryFilter filter = new ArcGIS.Core.Data.QueryFilter
{
WhereClause = "OBJECTID = 6"
};
// get the row
ArcGIS.Core.Data.RowCursor rowCursor = featureClass.Search(filter, false);
while (rowCursor.MoveNext())
{
long oid = rowCursor.Current.GetObjectID();
// get the shape from the row
ArcGIS.Core.Data.Feature feature = rowCursor.Current as ArcGIS.Core.Data.Feature;
Polygon polygon = feature.GetShape() as Polygon;
// get the attribute from the row (assume it's a double field)
double value = (double)rowCursor.Current.GetOriginalValue(fldIndex);
// do something here
}
}
catch (Exception ex)
{
// error - handle appropriately
}
});
##Determine the boundary of a multi-part Polygon
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
// create a donut polygon. Must use the PolygonBuilder object
List<Coordinate2D> outerPts = new List<Coordinate2D>();
outerPts.Add(new Coordinate2D(10.0, 10.0));
outerPts.Add(new Coordinate2D(10.0, 20.0));
outerPts.Add(new Coordinate2D(20.0, 20.0));
outerPts.Add(new Coordinate2D(20.0, 10.0));
List<Coordinate2D> innerPts = new List<Coordinate2D>();
innerPts.Add(new Coordinate2D(13.0, 13.0));
innerPts.Add(new Coordinate2D(17.0, 13.0));
innerPts.Add(new Coordinate2D(17.0, 17.0));
innerPts.Add(new Coordinate2D(13.0, 17.0));
// add the outer points
PolygonBuilder pb = new PolygonBuilder(outerPts);
// add the inner points (note they are defined anticlockwise)
pb.AddPart(innerPts);
// get the polygon
Polygon donut = pb.ToGeometry();
// get the boundary
Geometry g = GeometryEngine.Boundary(donut);
Polyline boundary = g as Polyline;
});
##Buffer a MapPoint
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
// buffer a point
MapPoint pt = MapPointBuilder.CreateMapPoint(1.0, 1.0, SpatialReferences.WGS84);
Geometry ptBuffer = GeometryEngine.Buffer(pt, 5.0);
Polygon buffer = ptBuffer as Polygon;
});
##Buffer a Circular Arc
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
// create the circular arc
Coordinate fromPt = new Coordinate(2, 1);
Coordinate toPt = new Coordinate(1, 2);
Coordinate2D interiorPt = new Coordinate2D(1 + Math.Sqrt(2) / 2, 1 + Math.Sqrt(2) / 2);
EllipticArcSegment circularArc = EllipticArcBuilder.CreateEllipticArcSegment(fromPt.ToMapPoint(), toPt.ToMapPoint(), interiorPt);
// buffer the arc
Polyline polyline = PolylineBuilder.CreatePolyline(circularArc);
Geometry lineBuffer = GeometryEngine.Buffer(polyline, 10);
});
##Buffer multiple MapPoints
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
// creates a buffer around each MapPoint
List<MapPoint> pts = new List<MapPoint>();
pts.Add(MapPointBuilder.CreateMapPoint(1.0, 1.0));
pts.Add(MapPointBuilder.CreateMapPoint(1.0, 2.0));
pts.Add(MapPointBuilder.CreateMapPoint(2.0, 2.0));
pts.Add(MapPointBuilder.CreateMapPoint(2.0, 1.0));
Geometry ptsBuffer = GeometryEngine.Buffer(pts, 0.25);
Polygon bufferResult = ptsBuffer as Polygon; // bufferResult will have 4 parts
});
##Clip a Polyline
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
// clip a polyline by an envelope
Envelope env = EnvelopeBuilder.CreateEnvelope(2.0, 2.0, 4.0, 4.0);
LineSegment line = LineBuilder.CreateLineSegment(new Coordinate(0, 3), new Coordinate(5.0, 3.0));
Polyline polyline = PolylineBuilder.CreatePolyline(line);
Geometry clipGeom = GeometryEngine.Clip(polyline, env);
});
##Clip a Polyline by a Polygon
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
// clip a polyline by a polygon
List<Coordinate2D> list = new List<Coordinate2D>();
list.Add(new Coordinate2D(1.0, 1.0));
list.Add(new Coordinate2D(1.0, 4.0));
list.Add(new Coordinate2D(4.0, 4.0));
list.Add(new Coordinate2D(4.0, 1.0));
Polygon polygon = PolygonBuilder.CreatePolygon(list, SpatialReferences.WGS84);
LineSegment crossingLine = LineBuilder.CreateLineSegment(MapPointBuilder.CreateMapPoint(0, 3), MapPointBuilder.CreateMapPoint(5.0, 3.0));
Polyline p = PolylineBuilder.CreatePolyline(crossingLine);
Geometry geometry = GeometryEngine.Clip(p, polygon.Extent);
});
##Polygon contains MapPoints, Polylines, Polygons
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
// build a polygon
List<MapPoint> pts = new List<MapPoint>();
pts.Add(MapPointBuilder.CreateMapPoint(1.0, 1.0));
pts.Add(MapPointBuilder.CreateMapPoint(1.0, 2.0));
pts.Add(MapPointBuilder.CreateMapPoint(2.0, 2.0));
pts.Add(MapPointBuilder.CreateMapPoint(2.0, 1.0));
Polygon poly = PolygonBuilder.CreatePolygon(pts);
// test if an inner point is contained
MapPoint innerPt = MapPointBuilder.CreateMapPoint(1.5, 1.5);
bool contains = GeometryEngine.Contains(poly, innerPt); // contains = true
// test a point on a boundary
contains = GeometryEngine.Contains(poly, poly.Points[0]); // contains = false
// test an interior line
MapPoint innerPt2 = MapPointBuilder.CreateMapPoint(1.25, 1.75);
List<MapPoint> innerLinePts = new List<MapPoint>();
innerLinePts.Add(innerPt);
innerLinePts.Add(innerPt2);
// test an inner polyline
Polyline polyline = PolylineBuilder.CreatePolyline(innerLinePts);
contains = GeometryEngine.Contains(poly, polyline); // contains = true
// test a line that crosses the boundary
MapPoint outerPt = MapPointBuilder.CreateMapPoint(3, 1.5);
List<MapPoint> crossingLinePts = new List<MapPoint>();
crossingLinePts.Add(innerPt);
crossingLinePts.Add(outerPt);
polyline = PolylineBuilder.CreatePolyline(crossingLinePts);
contains = GeometryEngine.Contains(poly, polyline); // contains = false
// test a polygon in polygon
Envelope env = EnvelopeBuilder.CreateEnvelope(innerPt, innerPt2);
contains = GeometryEngine.Contains(poly, env); // contains = true
});
##Intersection between two Polylines
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
// determine intersection between two polylines
List<MapPoint> pts = new List<MapPoint>();
pts.Add(MapPointBuilder.CreateMapPoint(1.0, 1.0));
pts.Add(MapPointBuilder.CreateMapPoint(3.0, 3.0));
pts.Add(MapPointBuilder.CreateMapPoint(5.0, 1.0));
Polyline line1 = PolylineBuilder.CreatePolyline(pts);
List<MapPoint> pts2 = new List<MapPoint>();
pts2.Add(MapPointBuilder.CreateMapPoint(1.0, 3.0));
pts2.Add(MapPointBuilder.CreateMapPoint(3.0, 1.0));
pts2.Add(MapPointBuilder.CreateMapPoint(5.0, 3.0));
Polyline line2 = PolylineBuilder.CreatePolyline(pts2);
bool intersects = GeometryEngine.Intersects(line1, line2); // intersects = true
Geometry g = GeometryEngine.Intersection(line1, line2, GeometryDimension.esriGeometry0Dimension);
Multipoint resultMultipoint = g as Multipoint;
// result is a multiPoint that intersects at (2,2) and (4,2)
});
##Intersection between two Polygons
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
// determine intersection between two polygons
Envelope env1 = EnvelopeBuilder.CreateEnvelope(new Coordinate2D(3.0, 2.0), new Coordinate2D(6.0, 6.0));
Polygon poly1 = PolygonBuilder.CreatePolygon(env1);
Envelope env2 = EnvelopeBuilder.CreateEnvelope(new Coordinate2D(1.0, 1.0), new Coordinate2D(4.0, 4.0));
Polygon poly2 = PolygonBuilder.CreatePolygon(env2);
Polygon polyResult = GeometryEngine.Intersection(poly1, poly2) as Polygon;
});
##Move a MapPoint
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
MapPoint pt = MapPointBuilder.CreateMapPoint(1.0, 3.0);
MapPoint ptResult = GeometryEngine.Move(pt, -3.5, 2.5) as MapPoint;
// ptResult is (-2.5, 5.5)
});
##Move a z-aware MapPoint
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
MapPoint zPt = MapPointBuilder.CreateMapPoint(1.0, 3.0, 2.0);
MapPoint zPtResult = GeometryEngine.Move(zPt, 4, 0.25, 0.5) as MapPoint;
// zPtResult is (5.0, 3.25, 2.5);
});
##Project from WGS84 to WebMercator
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
MapPoint pt = MapPointBuilder.CreateMapPoint(1.0, 3.0, SpatialReferences.WGS84);
Geometry result = GeometryEngine.Project(pt, SpatialReferences.WebMercator);
MapPoint projectedPt = result as MapPoint;
});
##Project from WGS84
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
// create the polygon
List<MapPoint> pts = new List<MapPoint>();
pts.Add(MapPointBuilder.CreateMapPoint(1.0, 1.0, SpatialReferences.WGS84));
pts.Add(MapPointBuilder.CreateMapPoint(1.0, 2.0, SpatialReferences.WGS84));
pts.Add(MapPointBuilder.CreateMapPoint(2.0, 2.0, SpatialReferences.WGS84));
pts.Add(MapPointBuilder.CreateMapPoint(2.0, 1.0, SpatialReferences.WGS84));
Polygon polygon = PolygonBuilder.CreatePolygon(pts);
// ensure it is simple
bool isSimple = GeometryEngine.IsSimpleAsFeature(polygon);
// create the spatial reference to project to
SpatialReference northPole = SpatialReferenceBuilder.CreateSpatialReference(102018); // north pole stereographic
// project
Geometry g = GeometryEngine.Project(polygon, northPole);
});
##Rotate a MapPoint
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
MapPoint pt = MapPointBuilder.CreateMapPoint(1.0, 3.0);
MapPoint rotatePt = MapPointBuilder.CreateMapPoint(3.0, 3.0);
Geometry result = GeometryEngine.Rotate(pt, rotatePt, Math.PI / 2);
// result point is (3, 1)
});
##Rotate a Polyline
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
// rotate a polyline
MapPoint fixedPt = MapPointBuilder.CreateMapPoint(3.0, 3.0);
List<MapPoint> pts = new List<MapPoint>();
pts.Add(MapPointBuilder.CreateMapPoint(1.0, 1.0));
pts.Add(MapPointBuilder.CreateMapPoint(1.0, 5.0));
pts.Add(MapPointBuilder.CreateMapPoint(5, 5));
pts.Add(MapPointBuilder.CreateMapPoint(5.0, 1.0));
Polyline polyline = PolylineBuilder.CreatePolyline(pts);
Polyline rotated = GeometryEngine.Rotate(polyline, fixedPt, Math.PI / 4) as Polyline; // rotate 45 deg
});
##Polygon touches another Polygon
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
// two disjoint polygons
Envelope env = EnvelopeBuilder.CreateEnvelope(MapPointBuilder.CreateMapPoint(4.0, 4.0), MapPointBuilder.CreateMapPoint(8, 8));
Polygon poly1 = PolygonBuilder.CreatePolygon(env);
Envelope env2 = EnvelopeBuilder.CreateEnvelope(MapPointBuilder.CreateMapPoint(1.0, 1.0), MapPointBuilder.CreateMapPoint(5, 5));
Polygon poly2 = PolygonBuilder.CreatePolygon(env2);
bool touches = GeometryEngine.Touches(poly1, poly2); // touches = false
// another polygon that touches the first
Envelope env3 = EnvelopeBuilder.CreateEnvelope(MapPointBuilder.CreateMapPoint(1.0, 1.0), MapPointBuilder.CreateMapPoint(4, 4));
Polygon poly3 = PolygonBuilder.CreatePolygon(env3);
touches = GeometryEngine.Touches(poly1, poly3); // touches = true
});
##Union two MapPoints - creates a Multipoint
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
MapPoint pt1 = MapPointBuilder.CreateMapPoint(1.0, 1.0);
MapPoint pt2 = MapPointBuilder.CreateMapPoint(2.0, 2.5);
Geometry geometry = GeometryEngine.Union(pt1, pt2);
Multipoint multipoint = geometry as Multipoint; // multipoint has point count of 2
});
##Union two Polygons
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
// union two polygons
List<MapPoint> polyPts = new List<MapPoint>();
polyPts.Add(MapPointBuilder.CreateMapPoint(3.0, 2.0));
polyPts.Add(MapPointBuilder.CreateMapPoint(3.0, 6.0));
polyPts.Add(MapPointBuilder.CreateMapPoint(6.0, 6.0));
polyPts.Add(MapPointBuilder.CreateMapPoint(6.0, 2.0));
Polygon poly1 = PolygonBuilder.CreatePolygon(polyPts);
bool isSimple = GeometryEngine.IsSimpleAsFeature(poly1);
Envelope env = EnvelopeBuilder.CreateEnvelope(MapPointBuilder.CreateMapPoint(4.0, 4.0), MapPointBuilder.CreateMapPoint(8, 8));
Polygon poly2 = PolygonBuilder.CreatePolygon(env);
isSimple = GeometryEngine.IsSimpleAsFeature(poly2);
Geometry g = GeometryEngine.Union(poly1, poly2);
Polygon polyResult = g as Polygon;
});
##MapPoints, Polylines, Polygons within Polygon
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
// build a polygon
List<MapPoint> pts = new List<MapPoint>();
pts.Add(MapPointBuilder.CreateMapPoint(1.0, 1.0));
pts.Add(MapPointBuilder.CreateMapPoint(1.0, 2.0));
pts.Add(MapPointBuilder.CreateMapPoint(2.0, 2.0));
pts.Add(MapPointBuilder.CreateMapPoint(2.0, 1.0));
Polygon poly = PolygonBuilder.CreatePolygon(pts);
// an inner point
MapPoint innerPt = MapPointBuilder.CreateMapPoint(1.5, 1.5);
bool within = GeometryEngine.Within(innerPt, poly); // within = true
// point on a boundary
within = GeometryEngine.Within(pts[0], poly); // within = false
// an interior line
MapPoint innerPt2 = MapPointBuilder.CreateMapPoint(1.25, 1.75);
List<MapPoint> innerLinePts = new List<MapPoint>();
innerLinePts.Add(innerPt);
innerLinePts.Add(innerPt2);
Polyline polyline = PolylineBuilder.CreatePolyline(innerLinePts);
within = GeometryEngine.Within(polyline, poly); // within = true
// a line that crosses the boundary
MapPoint outerPt = MapPointBuilder.CreateMapPoint(3, 1.5);
List<MapPoint> crossingLinePts = new List<MapPoint>();
crossingLinePts.Add(innerPt);
crossingLinePts.Add(outerPt);
polyline = PolylineBuilder.CreatePolyline(crossingLinePts);
within = GeometryEngine.Within(polyline, poly); // within = false
// polygon in polygon
Envelope env = EnvelopeBuilder.CreateEnvelope(innerPt, innerPt2);
within = GeometryEngine.Within(env, poly); // within = true
});
##Create Geographic Transformation
GeographicTransformation gt1478 = ArcGIS.Core.Geometry.GeographicTransformation.Create(1478);
string name = gt1478.Name;
string wkt = gt1478.Wkt;
GeographicTransformation another_gt1478 = ArcGIS.Core.Geometry.GeographicTransformation.Create(wkt);
##Create Composite Geographic Transformation
// Create singleton from wkid
CompositeGeographicTransformation cgt = ArcGIS.Core.Geometry.CompositeGeographicTransformation.Create(108272);
int count = cgt.Count; // count = 1
IList<GeographicTransformation> gts = cgt.Transformations as IList<GeographicTransformation>;
gts.Add(ArcGIS.Core.Geometry.GeographicTransformation.Create(1437, false));
count = cgt.Count; // count = 2
cgt = ArcGIS.Core.Geometry.CompositeGeographicTransformation.Create(gts);
GeographicTransformation gt0 = cgt[0];
GeographicTransformation gt1 = cgt[1];
##Create Projection Transformation
// methods need to be on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
SpatialReference sr4267 = SpatialReferenceBuilder.CreateSpatialReference(4267);
SpatialReference sr4326 = SpatialReferences.WGS84;
SpatialReference sr3857 = SpatialReferences.WebMercator;
// Create transformation from 4267 -> 3857
ProjectionTransformation projTransFromSRs = ArcGIS.Core.Geometry.ProjectionTransformation.Create(sr4267, sr3857);
// create an envelope
Envelope env = EnvelopeBuilder.CreateEnvelope(new Coordinate2D(2, 2), new Coordinate2D(3, 3), sr4267);
// Project with one geo transform 4267 -> 3857
Envelope projectedEnvEx = GeometryEngine.ProjectEx(env, projTransFromSRs) as Envelope;
// Create inverse transformation, 3857 -> 4267
ProjectionTransformation projTransFromSRsInverse = ArcGIS.Core.Geometry.ProjectionTransformation.Create(sr3857, sr4267);
// Project the projected envelope back using the inverse transformation
Envelope projectedEnvBack = GeometryEngine.ProjectEx(projectedEnvEx, projTransFromSRsInverse) as Envelope;
bool isEqual = env.IsEqual(projectedEnvBack);
});
##Convert between degrees and radians
// convert 45 degrees to radians
double radians = AngularUnit.Degrees.ConvertToRadians(45);
// convert PI to degrees
double degrees = AngularUnit.Degrees.ConvertFromRadians(Math.PI);
##Convert between feet and meters
// convert 10 feet to meters
double metres = LinearUnit.Feet.ConvertToMeters(10);
// convert 20 meters to feet
double feet = LinearUnit.Feet.ConvertFromMeters(20.0);
##Convert between square feet and square meters
// convert 700 square meters to square feet
double sqFeet = AreaUnit.SquareFeet.ConvertFromSquareMeters(700);
// convert 1100 square feet to square meters
double sqMeters = AreaUnit.SquareFeet.ConvertToSquareMeters(1000);
##Convert between hectares and acres
// convert 2 hectares to acres
double acres = AreaUnit.Hectares.ConvertTo(2, AreaUnit.Acres);
// convert 300 hectares to square miles
double sqMiles = AreaUnit.Hectares.ConvertTo(300, AreaUnit.SquareMiles);
Home | API Reference | Requirements | Download | Samples
-
Construct a SpatialReference - from a well-known ID
-
Construct a SpatialReference - from a string
-
Use WGS84 SpatialReference
-
Construct a SpatialReference with a vertical coordinate system - from well-known IDs
-
Construct a SpatialReference with a vertical coordinate system - from a string
-
Construct a SpatialReference with a custom PCS - from a string
-
SpatialReference Properties
-
SpatialReference WKT2
-
Import and Export Spatial Reference
-
Determine grid convergence for a SpatialReference at a given point
-
Datum
-
SpatialReference Datum and datum properties
-
Vector Polar Coordinates
-
Getting vector inclination
-
Getting vector azimuth
-
Vector Operations
-
2D Vector Operations
-
Construct a Polyline - from an enumeration of MapPoints
-
Get the points of a Polyline
-
Get the parts of a Polyline
-
Enumerate the parts of a Polyline
-
Reverse the order of points in a Polyline
-
Get the segments of a Polyline
-
Build a multi-part Polyline
-
StartPoint of a Polyline
-
Construct a Clothoid by Angle
-
Construct a Clothoid by Length
-
Split Polyline at distance
-
Create 3D Polyline and set Z-values while preserving curve segments
-
Construct a Polygon - from an enumeration of MapPoints
-
Construct a Polygon - from an Envelope
-
Get the points of a Polygon
-
Get the parts of a Polygon
-
Enumerate the parts of a Polygon
-
Get the segments of a Polygon
-
Build a donut polygon
-
Create an N-sided regular polygon
-
Get the exterior rings of a polygon - polygon.GetExteriorRing
-
Construct an Envelope
-
Construct an Envelope - from a JSON string
-
Union two Envelopes
-
Intersect two Envelopes
-
Expand an Envelope
-
Update Coordinates of an Envelope
-
Construct a Multipoint - from an enumeration of MapPoints
-
Construct a Multipoint - using MultipointBuilderEx
-
Modify the points of a Multipoint
-
Retrieve Points, 2D Coordinates, 3D Coordinates from a multipoint
-
Construct a Cubic Bezier - from Coordinates
-
Construct a Cubic Bezier - from MapPoints
-
Construct a Cubic Bezier - from an enumeration of MapPoints
-
Cubic Bezier Builder Properties
-
Cubic Bezier Properties
-
Construct a Polyline - from a Cubic Bezier
-
Construct a Circular Arc - using an interior point
-
Construct a Circular Arc - using a chord length and bearing
-
Construct a Circular Arc - using a center point, angle and radius
-
Construct an Elliptic Arc - using a center point and rotation angle
-
Construct a Circular Arc - using a center point and orientation
-
Construct a Circular Arc - using two segments and radius
-
Construct a Circle
-
Construct an Ellipse
-
Elliptic Arc Builder Properties
-
Elliptic Arc Properties
-
Construct GeometryBag
-
Construct GeometryBag - from an enumeration of geometries
-
Construct GeometryBag - from JSON, Xml
-
Construct GeometryBag - adding or inserting an enumeration of geometries
-
Construct Multipatch via Extrusion of Polygon or Polyline
-
Multipatch Properties
-
Construct Multipatch
-
Construct Multipatch via MultipatchBuilderEx
-
Construct Multipatch from another Multipatch
-
Construct Multipatch from a 3D model file
-
Construct 3D special Multipatch shapes
-
Create BasicMaterial
-
Create BasicMaterial with JPEG texture
-
Create BasicMaterial with Uncompressed texture
-
Get the texture image of a multipatch
-
Get the normal coordinate of a multipatch
-
Get the normals of a multipatch
-
Get the material properties of a multipatch
-
Import and Export Geometries to well-known Text
-
Import and Export Geometries to well-known Binary
-
Import and Export Geometries to EsriShape
-
Import and Export Geometries to JSON
-
Import and Export Geometries to XML
-
Create Geographic Transformation
-
Create Composite Geographic Transformation
-
Create Projection Transformation
-
Create HV Datum Transformation
-
Create Composite HV Datum Transformation
-
Determine Transformations
-
AngularUnit - Convert between degrees and radians
-
AngularUnit - Create an AngularUnit with a factory code
-
AngularUnit - Create a Custom AngularUnit