ArcGIS Pro 3.8 API Reference Guide
ArcGIS.Core.Geometry Namespace / EnvelopeBuilderEx Class / CreateEnvelope Method / CreateEnvelope(Double,Double,Double,Double,SpatialReference) Method
Minimum X value of the envelope.
Minimum Y value of the envelope.
Maximum X value of the envelope.
Maximum Y value of the envelope.
(Optional) The SpatialReference. The default value is null.
Example

In This Topic
    CreateEnvelope(Double,Double,Double,Double,SpatialReference) Method
    In This Topic
    Convenience method to create a new instance of the Envelope class.
    Syntax
    Public Overloads Shared Function CreateEnvelope( _
       ByVal xMin As Double, _
       ByVal yMin As Double, _
       ByVal xMax As Double, _
       ByVal yMax As Double, _
       Optional ByVal spatialReference As SpatialReference _
    ) As Envelope

    Parameters

    xMin
    Minimum X value of the envelope.
    yMin
    Minimum Y value of the envelope.
    xMax
    Maximum X value of the envelope.
    yMax
    Maximum Y value of the envelope.
    spatialReference
    (Optional) The SpatialReference. The default value is null.

    Return Value

    Remarks
    The resulting envelope is normalized to ensure its XMin <= XMax, YMin <= YMax. If any of the xy-coordinate values are NaN, then the envelope is set to empty.
    Example
    Union two Envelopes
    {
      // use the convenience builders
      Envelope env1 = EnvelopeBuilderEx.CreateEnvelope(0, 0, 1, 1, SpatialReferences.WGS84);
      Envelope env2 = EnvelopeBuilderEx.CreateEnvelope(0.5, 0.5, 1.5, 1.5, SpatialReferences.WGS84);
    
      Envelope env3 = env1.Union(env2);
    
      double area = env3.Area;
      double depth = env3.Depth;
      double height = env3.Height;
      double width = env3.Width;
      double len = env3.Length;
    
      MapPoint centerPt = env3.Center;
      Coordinate2D coord = env3.CenterCoordinate;
    
      bool isEmpty = env3.IsEmpty;
      int pointCount = env3.PointCount;
    
      // coordinates
      //env3.XMin, env3.XMax, env3.YMin, env3.YMax
      //env3.ZMin, env3.ZMax, env3.MMin, env3.MMax
    
      bool isEqual = env1.IsEqual(env2);    // false
    
      // or use the builderEx constructors which don't need to run on the MCT.
      EnvelopeBuilderEx builderEx = new EnvelopeBuilderEx(0, 0, 1, 1, SpatialReferences.WGS84);
      builderEx.Union(env2);      // builder is updated to the result
    
      depth = builderEx.Depth;
      height = builderEx.Height;
      width = builderEx.Width;
    
      centerPt = builderEx.Center;
      coord = builderEx.CenterCoordinate;
    
      isEmpty = builderEx.IsEmpty;
    
      env3 = builderEx.ToGeometry() as Envelope;
    }
    Intersect two Envelopes
    {
      // use the convenience builders
      Envelope env1 = EnvelopeBuilderEx.CreateEnvelope(0, 0, 1, 1, SpatialReferences.WGS84);
      Envelope env2 = EnvelopeBuilderEx.CreateEnvelope(0.5, 0.5, 1.5, 1.5, SpatialReferences.WGS84);
    
      bool intersects = env1.Intersects(env2); // true
      Envelope env3 = env1.Intersection(env2);
    
    
      // or use the builderEx constructors which don't need to run on the MCT.
      EnvelopeBuilderEx builderEx = new EnvelopeBuilderEx(0, 0, 1, 1, SpatialReferences.WGS84);
      intersects = builderEx.Intersects(env2);
      builderEx.Intersection(env2);   // note this sets the builder to the intersection
      env3 = builderEx.ToGeometry() as Envelope;
    }
    Expand an Envelope
    {
      // Use a builderEx convenience method or use a builderEx constructor.
    
      // convenience methods don't need to run on the MCT.
      Envelope envelope = EnvelopeBuilderEx.CreateEnvelope(100.0, 100.0, 500.0, 500.0);
    
      // shrink the envelope by 50%
      Envelope result = envelope.Expand(0.5, 0.5, true);
    
    
      // builderEx constructors don't need to run on the MCT.
      EnvelopeBuilderEx builderEx = new EnvelopeBuilderEx(100.0, 100.0, 500.0, 500.0);
      builderEx.Expand(0.5, 0.5, true);
      envelope = builderEx.ToGeometry() as Envelope;
    }
    Determine Transformations
    {
      // methods need to run on the MCT
      await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
      {
        //
        // find the first transformation used between spatial references 4267 and 4326
        //
        SpatialReference sr4267 =
             SpatialReferenceBuilder.CreateSpatialReference(4267);
        SpatialReference sr4326 = SpatialReferences.WGS84;
    
        List<ProjectionTransformation> transformations =
               ProjectionTransformation.FindTransformations(sr4267, sr4326);
        // transformations.Count = 1
        ProjectionTransformation projTrans = transformations[0];
        CompositeGeographicTransformation compositeGT =
             projTrans.Transformation as CompositeGeographicTransformation;
        GeographicTransformation gt = compositeGT[0];
        // gt.Wkid = 15851
        // gt.Name = "NAD_1927_To_WGS_1984_79_CONUS"
        // gt.IsForward = true
    
    
        //
        // find the first five transformation used between spatial references 4267 and 4326
        //
        transformations = ProjectionTransformation.FindTransformations(
                                           sr4267, sr4326, numResults: 5);
        // transformations.Count = 5
        projTrans = transformations[0];
        compositeGT = projTrans.Transformation as CompositeGeographicTransformation;
        // compositeGT.Count = 1
        // compositeGT[0].Wkid = 15851
        // compositeGT[0].Name = "NAD_1927_To_WGS_1984_79_CONUS"
        // compositeGT[0].IsForward = true
    
        projTrans = transformations[1];
        compositeGT = projTrans.Transformation as CompositeGeographicTransformation;
        // compositeGT.Count = 1
        // compositeGT[0].Wkid = 1173
        // compositeGT[0].Name = "NAD_1927_To_WGS_1984_4"
        // compositeGT[0].IsForward = true
    
        projTrans = transformations[2];
        compositeGT = projTrans.Transformation as CompositeGeographicTransformation;
        // compositeGT.Count = 1
        // compositeGT[0].Wkid = 1172
        // compositeGT[0].Name = "NAD_1927_To_WGS_1984_3"
        // compositeGT[0].IsForward = true
    
        projTrans = transformations[3];
        compositeGT = projTrans.Transformation as CompositeGeographicTransformation;
        // compositeGT.Count = 2
        // compositeGT[0].Wkid = 1241
        // compositeGT[0].Name = "NAD_1927_To_NAD_1983_NADCON"
        // compositeGT[0].IsForward = true
    
        // compositeGT[1].Wkid = 108190
        // compositeGT[1].Name = "WGS_1984_(ITRF00)_To_NAD_1983"
        // compositeGT[1].IsForward = false
    
        projTrans = transformations[4];
        compositeGT = projTrans.Transformation as CompositeGeographicTransformation;
        // compositeGT.Count = 2
        // compositeGT[0].Wkid = 1241
        // compositeGT[0].Name = "NAD_1927_To_NAD_1983_NADCON"
        // compositeGT[0].IsForward = true
    
        // compositeGT[1].Wkid = 1515
        // compositeGT[1].Name = "NAD_1983_To_WGS_1984_5"
        // compositeGT[1].IsForward = true
    
    
        //
        // find the first transformation used between spatial
        // references 4267 and 4326 within Alaska
        //
    
        // Alaska
        Envelope envelope = EnvelopeBuilderEx.CreateEnvelope(-161, 61, -145, 69);
        transformations = ProjectionTransformation.FindTransformations(
                                                    sr4267, sr4326, envelope);
        // transformations.Count = 1
        projTrans = transformations[0];
        compositeGT = projTrans.Transformation as CompositeGeographicTransformation;
        // compositeGT.Count = 2
        // compositeGT[0].Wkid = 1243
        // compositeGT[0].Name = "NAD_1927_To_NAD_1983_Alaska"
        // compositeGT[0].IsForward = true
    
        // compositeGT[1].Wkid = 108190
        // compositeGT[1].Name = "WGS_1984_(ITRF00)_To_NAD_1983"
        // compositeGT[1].IsForward = false
    
    
        //
        // find the first geographic transformation used between two spatial references with VCS  (use vertical = false)
        //
        SpatialReference inSR =
                        SpatialReferenceBuilder.CreateSpatialReference(4269, 115702);
        SpatialReference outSR =
                        SpatialReferenceBuilder.CreateSpatialReference(4326, 3855);
    
        // Even though each spatial reference has a VCS,
        // vertical = false should return geographic transformations.
        transformations = ProjectionTransformation.FindTransformations(inSR, outSR);
        // transformations.Count = 1
        projTrans = transformations[0];
        compositeGT = projTrans.Transformation as CompositeGeographicTransformation;
        // compositeGT.Count = 1
        // compositeGT[0].Wkid = 108190
        // compositeGT[0].Name = ""WGS_1984_(ITRF00)_To_NAD_1983"
        // compositeGT[0].IsForward = false
    
        //
        // find the first vertical transformation used between two spatial references with VCS  (use vertical = true)
        //
    
        transformations =
                  ProjectionTransformation.FindTransformations(
                                          inSR, outSR, vertical: true);
        // transformations.Count = 1
        projTrans = transformations[0];
    
        CompositeHVDatumTransformation compositeHV =
                projTrans.Transformation as CompositeHVDatumTransformation;
        // compositeHV.Count = 2
        // compositeHV[0].Wkid = 1188
        // compositeHV[0].Name = "NAD_1983_To_WGS_1984_1"
        // compositeHV[0].IsForward = true
    
        // compositeHV[1].Wkid = 110019
        // compositeHV[1].Name = "WGS_1984_To_WGS_1984_EGM2008_2.5x2.5_Height"
        // compositeHV[1].IsForward = true
      });
    }
    Center an envelope around X,Y
    {
      Envelope env = EnvelopeBuilderEx.CreateEnvelope(1.0, 1.0, 5.0, 5.0);
      Envelope centered = GeometryEngine.Instance.CenterAt(env, 2.0, 2.0);
    
      // centered.Center.X = 2.0
      // centered.Center.Y = 2.0
      // centered.XMin = 0
      // centered.YMin = 0
      // centered.XMax = 4
      // centered.YMax = 4
    
      centered = env.CenterAt(4.0, 3.0);
      // centered.Center.X == 4.0
      // centered.Center.Y == 3.0
      // centered.XMin == 2.0
      // centered.YMin == 1.0
      // centered.XMax == 6.0
      // centered.YMax == 5.0
    }
    Clip a Polyline
    {
      // clip a polyline by an envelope
    
      Envelope env = EnvelopeBuilderEx.CreateEnvelope(2.0, 2.0, 4.0, 4.0);
      LineSegment line = LineBuilderEx.CreateLineSegment(new Coordinate2D(0, 3), new Coordinate2D(5.0, 3.0));
      polyline = PolylineBuilderEx.CreatePolyline(line);
    
      Geometry clipGeom = GeometryEngine.Instance.Clip(polyline, env);
    }
    Expand envelopes
    {
      Envelope env = EnvelopeBuilderEx.CreateEnvelope(100.0, 100.0, 500.0, 500.0);
      // env.HasZ = false
    
      Envelope result = GeometryEngine.Instance.Expand(env, 0.5, 0.5, true);
      // result.Center = 300, 300
      // result.XMin = 200
      // result.YMin = 200
      // result.XMax = 400
      // result.YMax = 400
    
      result = GeometryEngine.Instance.Expand(env, 100, 200, false);
      // result.Center = 300, 300
      // result.XMin = 0
      // result.YMin = -100
      // result.XMax = 600
      // result.YMax = 700
    
      try
      {
        // expand in 3 dimensions
        result = GeometryEngine.Instance.Expand(env, 0.5, 0.5, 0.5, true);
      }
      catch (InvalidOperationException)
      {
        // the geometry is not Z-Aware
      }
    
      // expand a 3d envelope
      MapPoint pt1 = MapPointBuilderEx.CreateMapPoint(100, 100, 100);
      MapPoint pt2 = MapPointBuilderEx.CreateMapPoint(200, 200, 200);
    
      env = EnvelopeBuilderEx.CreateEnvelope(pt1, pt2);
      // env.HasZ = true
    
      result = GeometryEngine.Instance.Expand(env, 0.5, 0.5, 0.5, true);
    
      // result.Center = 150, 150, 150
      // result.XMin = 125
      // result.YMin = 125
      // result.ZMin = 125
      // result.XMax = 175
      // result.YMax = 175
      // result.ZMax = 175
    }
    GraphicBuffer
    {
      // mitered join and butt caps
      SpatialReference sr = SpatialReferenceBuilder.CreateSpatialReference(102010);
      List<Coordinate2D> coords =
      [
          new Coordinate2D(1400,6200),
      new Coordinate2D(1600,6300),
      new Coordinate2D(1800,6200)
      ];
    
      polyline = PolylineBuilderEx.CreatePolyline(coords, sr);
    
      polygon = GeometryEngine.Instance.GraphicBuffer(polyline, 50, LineJoinType.Miter, LineCapType.Butt, 10, 0, -1) as Polygon;
    
      // bevelled join and round caps
      Envelope envelope = EnvelopeBuilderEx.CreateEnvelope(0, 0, 10000, 10000, SpatialReferences.WebMercator);
    
      Polygon outPolygon = GeometryEngine.Instance.GraphicBuffer(envelope, 1000, LineJoinType.Bevel, LineCapType.Round, 4, 0, 96) as Polygon;
    }
    Create Map Frame and Set Camera
    {
      //Create a map frame and set its camera by zooming to the extent of an existing bookmark.
      var project = Project.Current;
      await QueuedTask.Run(() =>
      {
    
      //Build 2D envelope geometry
      Coordinate2D mf_ll = new Coordinate2D(6.0, 8.5);
      Coordinate2D mf_ur = new Coordinate2D(8.0, 10.5);
      Envelope mf_env = EnvelopeBuilderEx.CreateEnvelope(mf_ll, mf_ur);
    
      //Reference map, create MF and add to layout
      MapProjectItem mapPrjItem = project.GetItems<MapProjectItem>()
                           .FirstOrDefault(item => item.Name.Equals("Map"));
      Map mfMap = mapPrjItem.GetMap();
      Bookmark bookmark = mfMap.GetBookmarks().FirstOrDefault(
                            b => b.Name == "Great Lakes");
    
      MapFrame mfElm = ElementFactory.Instance.CreateMapFrameElement(
                           layout, mf_env, mfMap, "New Map Frame");
    
      //Zoom to bookmark
      mfElm.SetCamera(bookmark);
      });
    }
    Requirements

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

    ArcGIS Pro version: 3.0 or higher.
    See Also