Clip a geometry with another geometry.
Use case
Create a new set of geometries for analysis (e.g. displaying buffer zones around abandoned coal mine shafts in an area of planned urban development) by clipping intersecting geometries.
How to use the sample
Tap the "Clip" button to clip the blue graphic with the red dashed envelopes.
How it works
- Use the static method
GeometryEngine.Clip()
to generate a clippedGeometry
, passing in an existingGeometry
and anEnvelope
as parameters. The existing geometry will be clipped where it intersects an envelope. - Create a new
Graphic
from the clipped geometry and add it to aGraphicsOverlay
on theMapView
.
Relevant API
- Envelope
- Geometry
- GeometryEngine.Clip
- Graphic
- GraphicsOverlay
Additional information
Note: the resulting geometry may be null if the envelope does not intersect the geometry being clipped.
Tags
analysis, clip, geometry
Sample Code
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage x:Class="ArcGISRuntime.Samples.ClipGeometry.ClipGeometry"
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:esriUI="clr-namespace:Esri.ArcGISRuntime.Xamarin.Forms;assembly=Esri.ArcGISRuntime.Xamarin.Forms">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Button x:Name="ClipButton"
Grid.Row="0"
Clicked="ClipButton_Clicked"
Text="Clip" />
<esriUI:MapView x:Name="MyMapView" Grid.Row="1" />
</Grid>
</ContentPage>