ArcObjects Library Reference (Geometry)  

IEnvelope.Expand Method

Moves the X and Y coordinates of the sides toward or away from each other.

[Visual Basic .NET]
Public Sub Expand ( _
    ByVal dx As Double, _
    ByVal dy As Double, _
    ByVal asRatio As Boolean _
)
[C#]
public void Expand (
    double dx,
    double dy,
    bool asRatio
);
[C++]
HRESULT Expand(
  double dx,
  double dy,
  VARIANT_BOOL asRatio
);
[C++]

Parameters

dx   dx is a parameter of type double dy   dy is a parameter of type double asRatio   asRatio is a parameter of type VARIANT_BOOL

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Description

Expand scales the size of the Envelope.  If asRatio = FALSE, the expansion is additive.

XMin = XMin - dx
YMin = YMin - dy
XMax = XMax + dx
YMax = YMax + dy

If asRatio = TRUE, the expansion is multiplicative.  If the user wants to increase the envelope width by 10%, then dx = 1.1.  On the other hand, if the user intends to decrease the width by 10%, then dx = 0.9.  No negative number allowed when asRation is set to TRUE.

XMin = XMin - (dx-1)*Width/2
YMin = YMin - (dy-1)*Height/2 
XMax = XMax + (dx-1)*Width/2
YMax = YMax + (dy-1)*Height/2

The Envelope remains centered at the same position.

Remarks

 

Envelope Expand Example

[C#]

// The example shows how to expand the Envelope by using a asRatio factor.
private void Expand()
{
    IEnvelope envelope = new EnvelopeClass();
    envelope.PutCoords(100, 100, 200, 200);

    String report1 = "Envelope before expanding: \n" +
                     "LowerLeft  X = " + envelope.LowerLeft.X + "\n" +
                     "LowerLeft  Y = " + envelope.LowerLeft.Y + "\n\n" +
                     "LowerRight X =  " + envelope.LowerRight.X + "\n" +
                     "LowerRight Y =  " + envelope.LowerRight.Y + "\n\n" +
                     "UpperLeft  X = " + envelope.UpperLeft.X + "\n" +
                     "UpperLeft  Y = " + envelope.UpperLeft.Y + "\n\n" +
                     "UpperRight X =  " + envelope.UpperRight.X + "\n" +
                     "UpperRight Y =  " + envelope.UpperRight.Y;
    System.Windows.Forms.MessageBox.Show(report1);

    //expand
    envelope.Expand(0.5, 0.5, true);
    String report2 = "Envelope after expanding: \n" +
                     "LowerLeft  X = " + envelope.LowerLeft.X + "\n" +
                     "LowerLeft  Y = " + envelope.LowerLeft.Y + "\n\n" +
                     "LowerRight X =  " + envelope.LowerRight.X + "\n" +
                     "LowerRight Y =  " + envelope.LowerRight.Y + "\n\n" +
                     "UpperLeft  X = " + envelope.UpperLeft.X + "\n" +
                     "UpperLeft  Y = " + envelope.UpperLeft.Y + "\n\n" +
                     "UpperRight X =  " + envelope.UpperRight.X + "\n" +
                     "UpperRight Y =  " + envelope.UpperRight.Y;
    System.Windows.Forms.MessageBox.Show(report2);
}

[Visual Basic .NET]

    ' The example shows how to expand the Envelope pEnv1 by using a
    ' asRatio factor. In this case the target Envelope is 50% of the
    ' original size.

    Public Sub t_EnvExpand()
        Dim pEnv1 As IEnvelope
        pEnv1 = New Envelope
        pEnv1.PutCoords(100, 100, 200, 200)
        pEnv1.Expand(0.5, 0.5, True)

        Dim dXmin As Double, dYmin As Double, dXmax As Double, dYmax As Double
        pEnv1.QueryCoords(dXmin, dYmin, dXmax, dYmax)

        If pEnv1.IsEmpty Then
            MsgBox("envelope is empty")
        Else
            MsgBox(dXmin & "," & dYmin & "," & dXmax & "," & dYmax)
        End If

    End Sub

See Also

IEnvelope Interface | IEnvelope.Union Method | IEnvelope.Offset Method | IEnvelope.Intersect Method | IEnvelope.CenterAt Method

.NET Snippets

Get All Features from Point Search in GeoFeatureLayer | Zoom by Ratio | Zoom by Ratio and Recenter | Get First Feature from Point Search in GeoFeatureLayer |

.NET Samples

Closest facility solver (Code Files: frmClosestFacilitySolver) | Executing geoprocessing tools in the background (Code Files: RunGPForm) | Location-allocation solver (Code Files: frmLocationAllocationSolver) | Origin-destination cost matrix solver (Code Files: frmODCostMatrixSolver) | RSS weather layer (Code Files: RSSWeatherLayerClass) | Service area solver (Code Files: frmServiceAreaSolver) | Vehicle routing problem solver (Code Files: frmVRPSolver) |

.NET Related Topics

How to perform surface analysis on a terrain dataset | Location | Working with topologically related features |