ArcGIS Pro 3.8 API Reference Guide
ArcGIS.Core.Geometry Namespace / MapPointBuilderEx Class / CreateMapPoint Method / CreateMapPoint(Double,Double,Double,Double,SpatialReference) Method
X coordinate.
Y coordinate.
Z coordinate. HasZ is set to true.
Measure value. HasM is set to true.
(Optional) The SpatialReference. The default value is null.
Example

In This Topic
    CreateMapPoint(Double,Double,Double,Double,SpatialReference) Method
    In This Topic
    Convenience method to create a MapPoint instance with the given X, Y, Z and M coordinates. The HasZ and HasM properties on this instance are set to true.
    Syntax
    public static MapPoint CreateMapPoint( 
       double x,
       double y,
       double z,
       double m,
       SpatialReference spatialReference
    )
    Public Overloads Shared Function CreateMapPoint( _
       ByVal x As Double, _
       ByVal y As Double, _
       ByVal z As Double, _
       ByVal m As Double, _
       Optional ByVal spatialReference As SpatialReference _
    ) As MapPoint

    Parameters

    x
    X coordinate.
    y
    Y coordinate.
    z
    Z coordinate. HasZ is set to true.
    m
    Measure value. HasM is set to true.
    spatialReference
    (Optional) The SpatialReference. The default value is null.

    Return Value

    Example
    Builder Properties
    {
      // list of points
      List<MapPoint> pointsForBuilder = new List<MapPoint>
    {
      MapPointBuilderEx.CreateMapPoint(0, 0, 2, 3, 1),
      MapPointBuilderEx.CreateMapPoint(1, 1, 5, 6),
      MapPointBuilderEx.CreateMapPoint(2, 1, 6),
      MapPointBuilderEx.CreateMapPoint(0, 0)
    };
    
      // will have attributes because it is created with convenience method
      Polyline polylineWithAttrs = PolylineBuilderEx.CreatePolyline(pointsForBuilder);
      bool hasZ = polylineWithAttrs.HasZ;          // hasZ = true
      bool hasM = polylineWithAttrs.HasM;          // hasM = true
      bool hasID = polylineWithAttrs.HasID;        // hasID = true
    
      // will not have attributes because it is specified as a parameter
      Polyline polylineWithoutAttrs =
        PolylineBuilderEx.CreatePolyline(pointsForBuilder, AttributeFlags.None);
      hasZ = polylineWithoutAttrs.HasZ;          // hasZ = false
      hasM = polylineWithoutAttrs.HasM;          // hasM = false
      hasID = polylineWithoutAttrs.HasID;        // hasID = false
    
      // will have attributes because it is created with convenience method
      Polygon polygonWithAttrs = PolygonBuilderEx.CreatePolygon(pointsForBuilder);
      hasZ = polygonWithAttrs.HasZ;               // hasZ = true
      hasM = polygonWithAttrs.HasM;               // hasM = true
      hasID = polygonWithAttrs.HasID;             // hasID = true
    
      // will not have attributes because it is specified as a parameter
      Polygon polygonWithoutAttrs =
            PolygonBuilderEx.CreatePolygon(pointsForBuilder, AttributeFlags.None);
      hasZ = polygonWithoutAttrs.HasZ;               // hasZ = false
      hasM = polygonWithoutAttrs.HasM;               // hasM = false
      hasID = polygonWithoutAttrs.HasID;             // hasID = false
    
      // will not have attributes because it is specified as a parameter
      PolylineBuilderEx polylineB =
                 new PolylineBuilderEx(pointsForBuilder, AttributeFlags.None);
      hasZ = polylineB.HasZ;                      // hasZ = false
      hasM = polylineB.HasM;                      // hasM = false
      hasID = polylineB.HasID;                    // hasID = false
    
      // will have attributes because it is passed an attributed polyline
      polylineB = new PolylineBuilderEx(polylineWithAttrs);
      hasZ = polylineB.HasZ;                      // hasZ = true
      hasM = polylineB.HasM;                      // hasM = true
      hasID = polylineB.HasID;                    // hasID = true
    
      // will not have attributes because it is passed a non-attributed polyline
      polylineB = new PolylineBuilderEx(polylineWithoutAttrs);
      hasZ = polylineB.HasZ;                      // hasZ = false
      hasM = polylineB.HasM;                      // hasM = false
      hasID = polylineB.HasID;                    // hasID = false
    
      // will not have attributes because it is specified as a parameter
      PolygonBuilderEx polygonB = new PolygonBuilderEx(pointsForBuilder, AttributeFlags.None);
      hasZ = polygonB.HasZ;                       // hasZ = false
      hasM = polygonB.HasM;                       // hasM = false
      hasID = polygonB.HasID;                     // hasID = false
    
      // will have attributes because it is passed an attributed polygon
      polygonB = new PolygonBuilderEx(polygonWithAttrs);
      hasZ = polygonB.HasZ;                       // hasZ = true
      hasM = polygonB.HasM;                       // hasM = true
      hasID = polygonB.HasID;                     // hasID = true
    
      // will not have attributes because it is passed a non-attributed polygon
      polygonB = new PolygonBuilderEx(polygonWithoutAttrs);
      hasZ = polygonB.HasZ;                       // hasZ = true
      hasM = polygonB.HasM;                       // hasM = true
      hasID = polygonB.HasID;                     // hasID = true
    }
    Construct a MapPoint
    {
      // Use a builder convenience method or use a builder constructor.
    
      // Create a 2D point without a spatial reference
      MapPoint point2D = MapPointBuilderEx.CreateMapPoint(1, 2);
      SpatialReference sr = point2D.SpatialReference; // sr = null
      bool hasZ = point2D.HasZ;   // hasZ = false
      bool hasM = point2D.HasM;   // hasM = false
      bool hasID = point2D.HasID; // hasID = false
      double x = point2D.X;   // x = 1
      double y = point2D.Y;   // y = 2
      double z = point2D.Z;   // z = 0 default value
      double m = point2D.M;   // m is NaN default value
      double id = point2D.ID; // id = 0 default value
    
      // Or use a builderEx which doesn't need to run on the MCT.
      MapPointBuilderEx builderEx = new MapPointBuilderEx(1, 2);
    
      // do something with the builder
      builderEx.Y = 3;
      point2D = builderEx.ToGeometry();
      sr = point2D.SpatialReference; // sr = null
      hasZ = point2D.HasZ;   // hasZ = false
      hasM = point2D.HasM;   // hasM = false
      hasID = point2D.HasID; // hasID = false
      x = point2D.X;   // x = 1
      y = point2D.Y;   // y = 3
      z = point2D.Z;   // z = 0 default value
      m = point2D.M;   // m is NaN default value
      id = point2D.ID; // id = 0 default value
    
      // Create a 2D point with a spatial reference
      SpatialReference spatialReference = SpatialReferenceBuilder.CreateSpatialReference(4269);
      point2D = MapPointBuilderEx.CreateMapPoint(1, 2, spatialReference);
      sr = point2D.SpatialReference; // sr != null
      int wkid = sr.Wkid; // wkid = 4269
    
      // Or use a builder
      builderEx = new MapPointBuilderEx(1, 2, spatialReference);
    
      // Do something with the builder
      builderEx.SetValues(3, 5);
      point2D = builderEx.ToGeometry();
      sr = point2D.SpatialReference; // sr != null
      wkid = sr.Wkid; // wkid = 4269
      x = point2D.X; // x = 3
      y = point2D.Y; // y = 5
    
      // Change the spatial reference of the builder
      builderEx.SpatialReference = SpatialReferences.WGS84;
      point2D = builderEx.ToGeometry();
      sr = point2D.SpatialReference; // sr != null
      wkid = sr.Wkid; // wkid = 4326
      x = point2D.X; // x = 3
      y = point2D.Y; // y = 5
    
      // Create a 3D point with M
      MapPoint pointZM = MapPointBuilderEx.CreateMapPoint(1, 2, 3, 4);
      sr = pointZM.SpatialReference; // sr = null
      hasZ = pointZM.HasZ;   // hasZ = true
      hasM = pointZM.HasM;   // hasM = true
      hasID = pointZM.HasID; // hasID = false
      x = pointZM.X;   // x = 1
      y = pointZM.Y;   // y = 2
      z = pointZM.Z;   // z = 3
      m = pointZM.M;   // m = 4
      id = pointZM.ID; // id = 0 default value
    
      // Create a 3D point with M and a spatial reference
      pointZM = MapPointBuilderEx.CreateMapPoint(1, 2, 3, 4, spatialReference);
      sr = pointZM.SpatialReference; // sr != null
      wkid = sr.Wkid; // wkid = 4269
    
      // Create a point from another point in three ways
      MapPoint clone = pointZM.Clone() as MapPoint; // Has the same values including the spatial reference as pointZM
      MapPoint anotherZM = MapPointBuilderEx.CreateMapPoint(pointZM);  // Has the same values including the spatial reference as pointZM
    
      builderEx = new MapPointBuilderEx(pointZM); // Has the same values including the spatial reference as pointZM
      // Do something with the builder
      builderEx.HasM = false;
      builderEx.ID = 7; // Setting the id also sets HasID = true
      MapPoint pointZId = builderEx.ToGeometry();
      sr = pointZId.SpatialReference; // sr != null
      wkid = sr.Wkid; // wkid = 4269
      hasZ = pointZId.HasZ;   // hasZ = true
      hasM = pointZId.HasM;   // hasM = false
      hasID = pointZId.HasID; // hasID = true
      x = pointZId.X;   // x = 1
      y = pointZId.Y;   // y = 2
      z = pointZId.Z;   // z = 3
      m = pointZId.M;   // m is NaN, default value
      id = pointZId.ID; // id = 7
    
      // Create a point with Z, M, and ID-values
      MapPoint pointZMId = MapPointBuilderEx.CreateMapPoint(1, 2, 3, 4, 5, spatialReference);
      sr = pointZMId.SpatialReference; // sr != null
      wkid = sr.Wkid; // wkid = 4269
      hasZ = pointZMId.HasZ;   // hasZ = true
      hasM = pointZMId.HasM;   // hasM = true
      hasID = pointZMId.HasID; // hasID = true
      x = pointZMId.X;   // x = 1
      y = pointZMId.Y;   // y = 2
      z = pointZMId.Z;   // z = 3
      m = pointZMId.M;   // m = 4
      id = pointZMId.ID; // id = 5
    
      // Pick and choose which attributes to include
      MapPoint point = MapPointBuilderEx.CreateMapPoint(1, 2, false, 3, true, 4, true, 5);
      sr = point.SpatialReference; // sr = null
      hasZ = point.HasZ;   // hasZ = false
      hasM = point.HasM;   // hasM = true
      hasID = point.HasID; // hasID = true
      x = point.X;   // x = 1
      y = point.Y;   // y = 2
      z = point.Z;   // z = 0, default value
      m = point.M;   // m = 4
      id = point.ID; // id = 5
    
      // Or use a builder
      builderEx = new(1, 2, true, 3, false, 4, true, 5);
      // Do something with the builder
      builderEx.ID = 7;
      builderEx.SpatialReference = SpatialReferences.WGS84;
      point = builderEx.ToGeometry();
      sr = point.SpatialReference; // sr != null
      wkid = sr.Wkid; // wkid = 4326
      hasZ = point.HasZ;   // hasZ = true
      hasM = point.HasM;   // hasM = false
      hasID = point.HasID; // hasID = true
      x = point.X;   // x = 1
      y = point.Y;   // y = 2
      z = point.Z;   // z = 0, default value
      m = point.M;   // m is NaN, default value
      id = point.ID; // id = 7
    }
    MapPoint IsEqual
    {
      MapPoint pt1 = MapPointBuilderEx.CreateMapPoint(1, 2, 3, 4, 5);
      int ID = pt1.ID;           // ID = 5
      bool hasID = pt1.HasID;     // hasID = true
    
      MapPoint pt2 = MapPointBuilderEx.CreateMapPoint(1, 2, 3, 4, 0);
      ID = pt2.ID;        // ID = 0
      hasID = pt2.HasID;  // hasID = true
    
      MapPoint pt3 = MapPointBuilderEx.CreateMapPoint(1, 2, 3, 4);
      ID = pt3.ID;          // ID = 0
      hasID = pt3.HasID;    // hasID = false
    
      MapPoint pt4 = MapPointBuilderEx.CreateMapPoint(1, 2, 3, 44);
      ID = pt4.ID;          // ID = 0
      hasID = pt4.HasID;    // hasID = false
      bool hasM = pt4.HasM; // hasM = true
    
      MapPoint pt5 = MapPointBuilderEx.CreateMapPoint(1, 2, 3);
      ID = pt5.ID;          // ID = 0
      hasID = pt5.HasID;    // hasID = false
      hasM = pt5.HasM;      // hasM = false
    
      bool isEqual = pt1.IsEqual(pt2);   // isEqual = false, different IDs
      isEqual = pt2.IsEqual(pt3);        // isEqual = false, HasId is different
      isEqual = pt4.IsEqual(pt3);        // isEqual = false, different Ms
      isEqual = pt1.IsEqual(pt5);        // isEqual = false, pt has M, id but pt5 does not.
    }
    Import and Export Geometries to well-known Text
    {
      // create a point with z, m
      MapPoint point = MapPointBuilderEx.CreateMapPoint(
               100, 200, 300, 400, SpatialReferences.WebMercator);
    
      // set the flags
      WktExportFlags wktExportFlags = WktExportFlags.WktExportDefaults;
      WktImportFlags wktImportFlags = WktImportFlags.WktImportDefaults;
    
      // export and import
      string wktString = GeometryEngine.Instance.ExportToWKT(wktExportFlags, point);
      MapPoint importPointGeom = GeometryEngine.Instance.ImportFromWKT(
            wktImportFlags, wktString, SpatialReferences.WebMercator) as MapPoint;
    
      double x = importPointGeom.X;       // x = 100
      double y = importPointGeom.Y;       // y = 200
      bool hasZ = importPointGeom.HasZ;   // hasZ = true
      double z = importPointGeom.Z;       // z = 300
      bool hasM = importPointGeom.HasM;   // hasM = true
      double m = importPointGeom.M;       // m = 400
    
      // export without z
      WktExportFlags exportFlagsNoZ = WktExportFlags.WktExportStripZs;
      wktString = GeometryEngine.Instance.ExportToWKT(exportFlagsNoZ, point);
      importPointGeom = GeometryEngine.Instance.ImportFromWKT(
        wktImportFlags, wktString, SpatialReferences.WebMercator) as MapPoint;
    
      x = importPointGeom.X;        // x = 100
      y = importPointGeom.Y;        // y = 200
      hasZ = importPointGeom.HasZ;  // hasZ = false
      z = importPointGeom.Z;        // z = 0
      hasM = importPointGeom.HasM;  // hasM = true
      m = importPointGeom.M;        // m = 400
    
      // export without m
      WktExportFlags exportFlagsNoM = WktExportFlags.WktExportStripMs;
      wktString = GeometryEngine.Instance.ExportToWKT(exportFlagsNoM, point);
      importPointGeom = GeometryEngine.Instance.ImportFromWKT(
        wktImportFlags, wktString, SpatialReferences.WebMercator) as MapPoint;
    
      x = importPointGeom.X;        // x = 100
      y = importPointGeom.Y;        // y = 200
      hasZ = importPointGeom.HasZ;  // hasZ = true
      z = importPointGeom.Z;        // z = 300
      hasM = importPointGeom.HasM;  // hasM = false
      m = importPointGeom.M;        // m = Nan
    
      // export without z, m
      wktString = GeometryEngine.Instance.ExportToWKT(
        exportFlagsNoZ | exportFlagsNoM, point);
      importPointGeom = GeometryEngine.Instance.ImportFromWKT(
        wktImportFlags, wktString, SpatialReferences.WebMercator) as MapPoint;
    
      x = importPointGeom.X;        // x = 100
      y = importPointGeom.Y;        // y = 200
      hasZ = importPointGeom.HasZ;  // hasZ = false
      z = importPointGeom.Z;        // z = 0
      hasM = importPointGeom.HasM;  // hasM = false
      m = importPointGeom.M;        // m = Nan
    }
    Import and Export Geometries to EsriShape
    {
      // create an envelope
      List<MapPoint> coordsZM = new List<MapPoint>
    {
      MapPointBuilderEx.CreateMapPoint(1001, 1002, 1003, 1004),
      MapPointBuilderEx.CreateMapPoint(2001, 2002, Double.NaN, 2004),
      MapPointBuilderEx.CreateMapPoint(3001, -3002, 3003, 3004),
      MapPointBuilderEx.CreateMapPoint(1001, -4002, 4003, 4004)
    };
    
      Envelope envelope = EnvelopeBuilderEx.CreateEnvelope(
                 coordsZM[0], coordsZM[2], SpatialReferences.WGS84);
    
      // export and import
      EsriShapeExportFlags exportFlags = EsriShapeExportFlags.EsriShapeExportDefaults;
      EsriShapeImportFlags importFlags = EsriShapeImportFlags.EsriShapeImportDefaults;
      byte[] buffer = GeometryEngine.Instance.ExportToEsriShape(exportFlags, envelope);
      Polygon importedPolygon = GeometryEngine.Instance.ImportFromEsriShape(
                     importFlags, buffer, envelope.SpatialReference) as Polygon;
      Envelope importedEnvelope = importedPolygon.Extent;
    
      // export without z,m
      buffer = GeometryEngine.Instance.ExportToEsriShape(
              EsriShapeExportFlags.EsriShapeExportStripZs |
              EsriShapeExportFlags.EsriShapeExportStripMs, envelope);
      importedPolygon = GeometryEngine.Instance.ImportFromEsriShape(
              importFlags, buffer, SpatialReferences.WGS84) as Polygon;
      importedEnvelope = importedPolygon.Extent;
    
      bool hasZ = importedEnvelope.HasZ;      // hasZ = false
      bool hasM = importedEnvelope.HasM;      // hasM = false
    
      // export with shapeSize
      int bufferSize = GeometryEngine.Instance.GetEsriShapeSize(
                                             exportFlags, envelope);
      buffer = new byte[bufferSize];
    
      bufferSize = GeometryEngine.Instance.ExportToEsriShape(
                                   exportFlags, envelope, ref buffer);
      importedPolygon = GeometryEngine.Instance.ImportFromEsriShape(
                          importFlags, buffer, envelope.SpatialReference) as Polygon;
      importedEnvelope = importedPolygon.Extent;
    
      // or use the envelope and envelopeBuilderEx classes
      buffer = envelope.ToEsriShape();
      // buffer represents a polygon as there is not an envelope Esri shape buffer
      // EnvelopeBuilderEx.FromEsriShape takes a polygon Esri shape buffer and returns the extent of the polygon.
      importedEnvelope = EnvelopeBuilderEx.FromEsriShape(buffer);
    }
    MapPoint - GeoCoordinateString Conversion
    {
      SpatialReference sr = SpatialReferences.WGS84;
      SpatialReference sr2 = SpatialReferences.WebMercator;
    
      // create some points
      MapPoint point0 = MapPointBuilderEx.CreateMapPoint(0, 0, sr);
      MapPoint point1 = MapPointBuilderEx.CreateMapPoint(10, 20, sr);
      MapPoint point2 = GeometryEngine.Instance.Project(point1, sr2) as MapPoint;
      MapPoint pointEmpty = MapPointBuilderEx.CreateMapPoint(sr);
      MapPoint pointwithNoSR = MapPointBuilderEx.CreateMapPoint(1, 1);
      MapPoint pointZM = MapPointBuilderEx.CreateMapPoint(1, 2, 3, 4, sr);
    
      // convert to MGRS
      ToGeoCoordinateParameter mgrsParam =
               new ToGeoCoordinateParameter(GeoCoordinateType.MGRS);
      // 31NAA6602100000
      string geoCoordString = point0.ToGeoCoordinateString(mgrsParam);
    
      // use the builder to create a new point from the string.
      // Coordinates are the same
      // outPoint.x = 0; outPoint.Y = 0
      MapPoint outPoint =
            MapPointBuilderEx.FromGeoCoordinateString(
                      geoCoordString, sr, GeoCoordinateType.MGRS);
    
      // 32QPH0460911794
      // outPoint.X = 10; outPoint.Y = 20
      geoCoordString = point1.ToGeoCoordinateString(mgrsParam);
      outPoint = MapPointBuilderEx.FromGeoCoordinateString(
                 geoCoordString, sr, GeoCoordinateType.MGRS);
    
      // z, m are not transformed
      // outPoint.X = 1; outPoint.Y = 2; outPoint.Z = Nan; outPoint.M = Nan;
      geoCoordString = pointZM.ToGeoCoordinateString(mgrsParam);
      outPoint = MapPointBuilderEx.FromGeoCoordinateString(
        geoCoordString, sr, GeoCoordinateType.MGRS);
    
      // set the number of digits to 2 and convert
      // 32QPH0512
      // outPoint.X = 10; outPoint.Y = 20
      mgrsParam.NumDigits = 2;
      geoCoordString = point1.ToGeoCoordinateString(mgrsParam);
      outPoint = MapPointBuilderEx.FromGeoCoordinateString(
        geoCoordString, sr, GeoCoordinateType.MGRS);
    
    
      // convert to UTM
      ToGeoCoordinateParameter utmParam =
           new ToGeoCoordinateParameter(GeoCoordinateType.UTM);
      // 31N 166021 0000000
      geoCoordString = point0.ToGeoCoordinateString(utmParam);
      // 32Q 604609 2211793
      geoCoordString = point1.ToGeoCoordinateString(utmParam);
    
      // convert to DMS
      ToGeoCoordinateParameter dmsParam =
        new ToGeoCoordinateParameter(GeoCoordinateType.DMS);
      // 00 00 00.00N 000 00 00.00E
      geoCoordString = point0.ToGeoCoordinateString(dmsParam);
      // 20 00 00.00N 010 00 00.00E
      geoCoordString = point1.ToGeoCoordinateString(dmsParam);
    
      // convert to DDM
      ToGeoCoordinateParameter ddmParam =
        new ToGeoCoordinateParameter(GeoCoordinateType.DDM);
      // 00 00.0000N 000 00.0000E
      geoCoordString = point0.ToGeoCoordinateString(ddmParam);
      // 20 00.0000N 010 00.0000E
      geoCoordString = point1.ToGeoCoordinateString(ddmParam);
    
      // convert to DD
      ToGeoCoordinateParameter ddParam =
        new ToGeoCoordinateParameter(GeoCoordinateType.DD);
      // 00.000000N 000.000000E
      geoCoordString = point0.ToGeoCoordinateString(ddParam);
      // 20.000000N 010.000000E
      geoCoordString = point1.ToGeoCoordinateString(ddParam);
    }
    Interpolate M values on a polygon
    {
      List<MapPoint> coords =
      [
        MapPointBuilderEx.CreateMapPoint(0, 0, 0, 0),
        MapPointBuilderEx.CreateMapPoint(0, 1000),
        MapPointBuilderEx.CreateMapPoint(1000, 1000, 10, 50)
      ];
    
      SpatialReference sr = SpatialReferences.WebMercator;
    
      polygon = PolygonBuilderEx.CreatePolygon(coords, sr);
    
      // polygon.HasM = true
      // polygon.Points[1].HasM = true
      // polygon.Points[1].M = NaN
    
      Polygon polygonNoNaNMs = GeometryEngine.Instance.CalculateNonSimpleMs(polygon, 0) as Polygon;
    
      // polygonNoNaNMs.Points[1].HasM = true
      // polygonNoNaNMs.Points[1].M = 25  (halfway between 0 and 50)
    }
    Find the centroid of geometries
    {
      // simple polygon
      List<Coordinate2D> list2D =
      [
        new Coordinate2D(0, 0),
        new Coordinate2D(0, 2),
        new Coordinate2D(2, 2),
        new Coordinate2D(2, 0),
      ];
    
      polygon = PolygonBuilderEx.CreatePolygon(list2D, SpatialReferences.WGS84);
    
      // verify it is simple
      bool isSimple = GeometryEngine.Instance.IsSimpleAsFeature(polygon);
      // find the centroid
      MapPoint centroid = GeometryEngine.Instance.Centroid(polygon);
      // centroid.X = 1
      // centroid.Y = 1
    
      // map Point
      MapPoint pt1 = MapPointBuilderEx.CreateMapPoint(1, 2, 3, 4, SpatialReferences.WGS84);
      MapPoint pt2 = MapPointBuilderEx.CreateMapPoint(5, 2, double.NaN, 7);
    
      // pt1.HasZ = true
      // pt1.HasM = true
      centroid = GeometryEngine.Instance.Centroid(pt1);
      // centroid.HasZ = true
      // centroid.HasM = true
      // pt1.IsEqual(centroid) = true
    
      // multipoint
      List<MapPoint> list = [pt1, pt2];
      Multipoint multipoint = MultipointBuilderEx.CreateMultipoint(list);
      // multipoint.HasZ = true
      // multipoint.HasM = true
    
      centroid = GeometryEngine.Instance.Centroid(multipoint);
      // centroid.X = 3
      // centroid.Y = 2
      // centroid.HasZ = false
      // centroid.HasM = false
    }
    Extend a polyline
    {
      // build a polyline
      polyline = PolylineBuilderEx.CreatePolyline(
      [
        MapPointBuilderEx.CreateMapPoint(1, 1, 10, 20),
        MapPointBuilderEx.CreateMapPoint(0, 0, 10, 20),
        MapPointBuilderEx.CreateMapPoint(1, -1, 10, 20)
      ]);
    
      // build the extender line
      var extender = PolylineBuilderEx.CreatePolyline(
      [
        MapPointBuilderEx.CreateMapPoint(2, 2),
        MapPointBuilderEx.CreateMapPoint(2, -2),
      ]);
    
      // extend
      var result = GeometryEngine.Instance.Extend(polyline, extender, ExtendFlags.KeepEndAttributes);
      Polyline extendedLine = result as Polyline;
      // result.Parts[0].Points[0] = 2, 2, 10, 20
      // result.parts[0].Points[1] = 1, 1, 10, 20
      // result.Parts[0].Points[2] = 0, 0, 10, 20
      // result.Parts[0].Points[3] = 1, -1, 10, 20
      // result.Parts[0].Points[4] = 2, -2, 10, 20
    
      // change the flags
      result = GeometryEngine.Instance.Extend(polyline, extender, ExtendFlags.NoEndAttributes);
      extendedLine = result as Polyline;
      // result.Parts[0].Points[0] = 2, 2, 0
      // result.parts[0].Points[1] = 1, 1, 10, 20
      // result.Parts[0].Points[2] = 0, 0, 10, 20
      // result.Parts[0].Points[3] = 1, -1, 10, 20
      // result.Parts[0].Points[4] = 2, -2, 0
    
      // extend
      result = GeometryEngine.Instance.Extend(polyline, extender, ExtendFlags.KeepEndAttributes | ExtendFlags.NoExtendAtTo);
      extendedLine = result as Polyline;
      // result.Parts[0].Points[0] = 2, 2, 10, 20
      // result.parts[0].Points[1] = 1, 1, 10, 20
      // result.Parts[0].Points[2] = 0, 0, 10, 20
      // result.Parts[0].Points[3] = 1, -1, 10, 20
    
      // extend with no intersection
    
      polyline = PolylineBuilderEx.CreatePolyline(
      [
        MapPointBuilderEx.CreateMapPoint(1, 1),
        MapPointBuilderEx.CreateMapPoint(3, 1)
      ]);
    
      extender = PolylineBuilderEx.CreatePolyline(
      [
        MapPointBuilderEx.CreateMapPoint(1, 4),
        MapPointBuilderEx.CreateMapPoint(3, 4)
      ]);
    
      result = GeometryEngine.Instance.Extend(polyline, extender, ExtendFlags.Default);
      // result = null
    
      result = GeometryEngine.Instance.Extend(polyline, extender, ExtendFlags.KeepEndAttributes | ExtendFlags.NoExtendAtTo);
    
      // Use the result ...
    }
    Get line segments corresponding to the normal at the locations where the specified M values occur along the geometry - GetNormalsAtM
    {
      IList<MapPoint> inPoints =
      [
        MapPointBuilderEx.CreateMapPoint(-3000, -2000, 0, 100),
    MapPointBuilderEx.CreateMapPoint(-3000, 0, 0, 200),
    MapPointBuilderEx.CreateMapPoint(-1000, 0, 0, 300),
    MapPointBuilderEx.CreateMapPoint(-1000, 2000, 0, 100),
    MapPointBuilderEx.CreateMapPoint(3000, 2000, 0, 200),
    MapPointBuilderEx.CreateMapPoint(3000, 0, 0, 300),
    MapPointBuilderEx.CreateMapPoint(1000, 0, 0, 100),
    MapPointBuilderEx.CreateMapPoint(1000, -2000, 0, 200),
    MapPointBuilderEx.CreateMapPoint(-3000, -2000, 0, 300)
      ];
    
      polygon = PolygonBuilderEx.CreatePolygon(inPoints);
      // polygon.HasM = true
    
      polyline = GeometryEngine.Instance.GetNormalsAtM(polygon, 150, 100);
      // polyline.PartCount = 5
      // polyline.PointCount = 10
      // polyline.HasM = false
    
      ReadOnlyPartCollection parts = polyline.Parts;
      ReadOnlySegmentCollection segments = parts[0];
      LineSegment line = segments[0] as LineSegment;
      // line.StartCoordinate = (-3000, -1000)
      // line.EndCoordinate = (-2900, -1000)
    
      segments = parts[1];
      line = segments[0] as LineSegment;
      // line.StartCoordinate = (-1000, 1500)
      // line.EndCoordinate = (-900, 1500)
    
      segments = parts[2];
      line = segments[0] as LineSegment;
      // line.StartCoordinate = (1000, 2000)
      // line.EndCoordinate = (1000, 1900)
    
      segments = parts[3];
      line = segments[0] as LineSegment;
      // line.StartCoordinate = (1500, 0)
      // line.EndCoordinate = (1500, 100)
    
      segments = parts[4];
      line = segments[0] as LineSegment;
      // line.StartCoordinate = (1000, -1000)
      // line.EndCoordinate = (900, -1000)
    }
    Determine if all the M-values are numbers - IsMSimple
    {
      Coordinate2D[] coords = [new Coordinate2D(-2, 2), new Coordinate2D(3, 5), new Coordinate2D(7, 2)];
      polyline = PolylineBuilderEx.CreatePolyline(coords); // polyline.HasM = false
      bool isMSimple = GeometryEngine.Instance.IsMSimple(polyline); // isMSimple = false
    
      PolylineBuilderEx polylineBuilder = new(polyline)
      {
        HasM = true
      };
      polyline = polylineBuilder.ToGeometry();
      isMSimple = GeometryEngine.Instance.IsMSimple(polyline); // isMSimple = false
    
      MapPoint point1 = MapPointBuilderEx.CreateMapPoint(-2, 2, -1, 1);
      MapPoint point2 = MapPointBuilderEx.CreateMapPoint(3, 5, -2, 2);
      MapPoint[] points = [point1, point2];
      polyline = PolylineBuilderEx.CreatePolyline(points, AttributeFlags.HasM);
      isMSimple = GeometryEngine.Instance.IsMSimple(polyline); // isMSimple = true
    }
    MovePointAlongLine
    {
      LineSegment line = LineBuilderEx.CreateLineSegment(MapPointBuilderEx.CreateMapPoint(0, 3), MapPointBuilderEx.CreateMapPoint(5.0, 3.0));
      polyline = PolylineBuilderEx.CreatePolyline(line);
      bool simple = GeometryEngine.Instance.IsSimpleAsFeature(polyline);
    
      // ratio = false
      MapPoint pt = GeometryEngine.Instance.MovePointAlongLine(polyline, 1.0, false, 0.0, SegmentExtensionType.NoExtension);
      // pt = 1.0, 3.0
    
      pt = GeometryEngine.Instance.MovePointAlongLine(polyline, 1.0, false, -1.0, SegmentExtensionType.NoExtension);
      // pt = 1.0, 4.0
    
      pt = GeometryEngine.Instance.MovePointAlongLine(polyline, 1.0, false, 2.0, SegmentExtensionType.NoExtension);
      // pt = 1.0, 1.0
    
      // ratio = true
      pt = GeometryEngine.Instance.MovePointAlongLine(polyline, 0.5, true, 0, SegmentExtensionType.NoExtension);
      // pt = 2.5, 3.0
    
      // move past the line
      pt = GeometryEngine.Instance.MovePointAlongLine(polyline, 7, false, 0, SegmentExtensionType.NoExtension);
      // pt = 5.0, 3.0
    
      // move past the line with extension at "to" point
      pt = GeometryEngine.Instance.MovePointAlongLine(polyline, 7, false, 0, SegmentExtensionType.ExtendEmbeddedAtTo);
      // pt = 7.0, 3.0
    
      // negative distance with extension at "from" point
      pt = GeometryEngine.Instance.MovePointAlongLine(polyline, -2, false, 0, SegmentExtensionType.ExtendEmbeddedAtFrom);
      // pt = -2.0, 3.0
    
      // ratio = true
      pt = GeometryEngine.Instance.MovePointAlongLine(polyline, 0.5, true, 0, SegmentExtensionType.NoExtension);
      // pt = 2.5, 3.0
    
      // line with Z
      List<Coordinate3D> coords3D = [new Coordinate3D(0, 0, 0), new Coordinate3D(1113195, 1118890, 5000)];
      Polyline polylineZ = PolylineBuilderEx.CreatePolyline(coords3D, SpatialReferences.WebMercator);
      // polylineZ.HasZ = true
    
      // ratio = true, no offset
      pt = GeometryEngine.Instance.MovePointAlongLine(polylineZ, 0.5, true, 0, SegmentExtensionType.NoExtension);
      // pt.X = 556597.5
      // pt.Y = 559445
      // pt.Z = 2500
    
      // ratio = true, past the line with "to" extension, no offset
      pt = GeometryEngine.Instance.MovePointAlongLine(polylineZ, 1.5, true, 0, SegmentExtensionType.ExtendEmbeddedAtTo);
      // pt.X = 1669792.5
      // pt.Y = 1678335
      // pt.Z = 7500
    
      // ratio = true, negative distance past the line with no extension, no offset
      pt = GeometryEngine.Instance.MovePointAlongLine(polylineZ, -1.5, true, 0, SegmentExtensionType.NoExtension);
      // pt.X = 0
      // pt.Y = 0
      // pt.Z = -7500
    
      // polyline with Z but 2d distance = 0
      MapPoint pt3 = MapPointBuilderEx.CreateMapPoint(5, 5, 0);
      MapPoint pt4 = MapPointBuilderEx.CreateMapPoint(5, 5, 10);
      List<MapPoint> pts = [pt3, pt4];
    
      polyline = PolylineBuilderEx.CreatePolyline(pts);
      // polyline.HasZ = true
      // polyline.Length3D = 10
      // polyline.Length = 0
    
      MapPoint result = GeometryEngine.Instance.MovePointAlongLine(polyline, 2, false, 0, SegmentExtensionType.NoExtension);
      // result = 5, 5, 2
    
      // polyline with length2d = 0 and length3d = 0
      MapPoint pt5 = MapPointBuilderEx.CreateMapPoint(5, 5, 10);
      MapPoint pt6 = MapPointBuilderEx.CreateMapPoint(5, 5, 10);
      pts.Clear();
      pts.Add(pt5);
      pts.Add(pt6);
    
      polyline = PolylineBuilderEx.CreatePolyline(pts);
      // polyline.HasZ = true
      // polyline.Length3D = 0
      // polyline.Length = 0
    
      result = GeometryEngine.Instance.MovePointAlongLine(polyline, 3, true, 0, SegmentExtensionType.NoExtension);
      // result = 5, 5, 10
    
      result = GeometryEngine.Instance.MovePointAlongLine(polyline, 3, true, 0, SegmentExtensionType.ExtendEmbeddedAtFrom);
      // result = 5, 5, 10
    
      // polyline with Z and M
      List<MapPoint> inputPoints =
      [
          MapPointBuilderEx.CreateMapPoint(1, 2, 3, 4),
        MapPointBuilderEx.CreateMapPoint(1, 2, 33, 44),
    ];
    
      Polyline polylineZM = PolylineBuilderEx.CreatePolyline(inputPoints, SpatialReferences.WGS84);
      // polylineZM.HasZ = true
      // polylineZM.HasM = true
    
      // ratio = true, no offset
      MapPoint pointAlong = GeometryEngine.Instance.MovePointAlongLine(polylineZM, 0.5, true, 0, SegmentExtensionType.NoExtension);
      // pointAlong = 1, 2, 18, 24
    
      // ratio = true with offset
      pointAlong = GeometryEngine.Instance.MovePointAlongLine(polylineZM, 0.2, true, 2.23606797749979, SegmentExtensionType.NoExtension);
      // pointAlong = 1, 2, 9, 12
    }
    Requirements

    Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)

    ArcGIS Pro version: 3.0 or higher.
    See Also