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

CreateMapPoint(Double,Double,Double,SpatialReference) Method
Convenience method to create a MapPoint instance with the given X, Y, and Z coordinates. The HasZ property on this instance is set to true.
Syntax
public static MapPoint CreateMapPoint( 
   double x,
   double y,
   double z,
   SpatialReference spatialReference
)

Parameters

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

Return Value

Example
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
Requirements

Target Platforms: Windows 11, Windows 10

ArcGIS Pro version: 3 or higher.
See Also