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

In This Topic
    CreateMapPoint(Double,Double,Double,Double,Int32,SpatialReference) Method
    In This Topic
    Convenience method to create a MapPoint instance with the given X, Y, Z, M and ID coordinates. The HasZ, HasM and HasID properties on this instance are set to true.
    Syntax
    public static MapPoint CreateMapPoint( 
       double x,
       double y,
       double z,
       double m,
       int id,
       SpatialReference spatialReference
    )
    Public Overloads Shared Function CreateMapPoint( _
       ByVal x As Double, _
       ByVal y As Double, _
       ByVal z As Double, _
       ByVal m As Double, _
       ByVal id As Integer, _
       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.
    id
    ID value. HasID 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 XML
    {
      MapPoint minPoint = MapPointBuilderEx.CreateMapPoint(1, 1, 1, 1, 3);
      MapPoint maxPoint = MapPointBuilderEx.CreateMapPoint(5, 5, 5);
    
      //
      //  MapPoint
      //
      string xml = minPoint.ToXml();
      MapPoint minPointImport = MapPointBuilderEx.FromXml(xml);
      // minPointImport = minPoint
    
      //
      // Envelope
      //
      Envelope envelopeWithID = EnvelopeBuilderEx.CreateEnvelope(minPoint, maxPoint);
    
      // Envelopes don't have IDs
      // envelopeWithID.HasID = false
      // envelopeWithID.HasM = true
      // envelopeWithID.HasZ = true
    
      xml = envelopeWithID.ToXml();
      Envelope envelopeImport = EnvelopeBuilderEx.FromXml(xml);
    
      //
      // Multipoint
      //
      List<MapPoint> list = new List<MapPoint>();
      list.Add(minPoint);
      list.Add(maxPoint);
    
      Multipoint multiPoint = MultipointBuilderEx.CreateMultipoint(list);
    
      xml = multiPoint.ToXml();
      Multipoint multipointImport = MultipointBuilderEx.FromXml(xml);
      // multipointImport.PointCount == 2
      // multipointImport.HasID = true
      // multipointImport.HasM = true
      // multipointImport.HasZ= true
    }
    Requirements

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

    ArcGIS Pro version: 3.0 or higher.
    See Also