Clip Features

This sample demonstrates use of the Geoprocessor to call a ClipFeatures geoprocessing service. To use the sample, specify a distance, then click subsequent points on the map to draw a line. Double-click to finish the line. When the line is finished, county features within the specified distance of the line will be returned and drawn map, with their boundaries clipped to the buffer area.

In the code-behind, a LocalGeoprocessingService is started asynchronously with the path to a Geoprocessing Package ( .gpk), which can be authored in ArcGIS for Desktop. The Url of the LocalGeoprocessingService and the Geoprocessing tool name is passed into the Geoprocessor, which is used to pass the distance and line to the ClipFeatures service. When the results are returned they are added to the map as graphics.

Download Sample Application
XAML C# VB.NET
<UserControl x:Class="ArcGISWPFSDK.LocalClipFeatures"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:esri="http://schemas.esri.com/arcgis/client/2009">
    <Grid x:Name="LayoutRoot" Background="White">
        <Grid.Resources>
            <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
            <esri:SimpleLineSymbol x:Key="ClipLineSymbol" Color="Red" Width="2" />
            <esri:SimpleFillSymbol x:Key="ClipFeaturesFillSymbol" Fill="#770000FF" BorderBrush="#FF0000FF" BorderThickness="1"  />
            <LinearGradientBrush x:Key="PanelGradient" EndPoint="0.5,1" StartPoint="0.5,0">
                <LinearGradientBrush.RelativeTransform>
                    <TransformGroup>
                        <ScaleTransform CenterY="0.5" CenterX="0.5"/>
                        <SkewTransform CenterY="0.5" CenterX="0.5"/>
                        <RotateTransform Angle="176" CenterY="0.5" CenterX="0.5"/>
                        <TranslateTransform/>
                    </TransformGroup>
                </LinearGradientBrush.RelativeTransform>
                <GradientStop Color="#FF145787" Offset="0.16"/>
                <GradientStop Color="#FF3D7FAC" Offset="0.502"/>
                <GradientStop Color="#FF88C5EF" Offset="0.984"/>
            </LinearGradientBrush>
        </Grid.Resources>
        <esri:Map x:Name="_map" Extent="-15000000,2000000,-7000000,8000000" Background="#FFE3E3E3" MinimumResolution="2445.98490512499">
            <esri:ArcGISLocalTiledLayer ID="BaseMap" Path="..\\Data\\TPKs\\Topographic.tpk"/>
            <esri:ArcGISLocalDynamicMapServiceLayer Path="..\\Data\\MPKS\\USCitiesStates.mpk"/>
            <esri:GraphicsLayer x:Name="_resultGraphicsLayer" >
                <esri:GraphicsLayer.MapTip>
                    <Grid Background="LightYellow">
                        <StackPanel Orientation="Horizontal" Margin="5">
                            <TextBlock Text="County name: " FontWeight="Bold" Foreground="Black"/>
                            <TextBlock Text="{Binding [NAME]}" Foreground="Black"/>
                        </StackPanel>
                        <Border BorderBrush="Black" BorderThickness="1" />
                    </Grid>
                </esri:GraphicsLayer.MapTip>
            </esri:GraphicsLayer>
            <esri:GraphicsLayer x:Name="_inputGraphicsLayer" />
        </esri:Map>
        <Grid HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,15,15,0" >
            <Rectangle Fill="{StaticResource PanelGradient}" Stroke="Gray"  RadiusX="10" RadiusY="10" Margin="0,0,0,5">
                <Rectangle.Effect>
                    <DropShadowEffect/>
                </Rectangle.Effect>
            </Rectangle>
            <Rectangle Fill="#FFFFFFFF" Stroke="DarkGray" RadiusX="5" RadiusY="5" Margin="5,5,5,10" />
            <StackPanel Orientation="Vertical" Margin="10,10,10,10" HorizontalAlignment="Left" >
                <TextBlock Text="Clip polygon features - US counties" HorizontalAlignment="Center" FontWeight="Bold" Foreground="Black"
                           Margin="5,5,5,5"/>
                <TextBlock x:Name="InformationTextBlock" Text="Draw a line on the map over the United States. When finished the line will be buffered and the buffer will be used to clip US county polygons."
                    Width="200" TextAlignment="Left" TextWrapping="Wrap" Foreground="Black" />
                <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="5,5,5,10">
                    <TextBlock Text="Distance (in km): " VerticalAlignment="Center" Foreground="Black" />
                    <TextBox x:Name="DistanceTextBox" Text="100" Width="35" TextAlignment="Right" Margin="0,0,5,0" />
                </StackPanel>
                <TextBlock x:Name="ProcessingTextBlock" MaxWidth="150" Margin="5,5,5,5" Visibility="Collapsed" 
                           HorizontalAlignment="Center" Text="Processing." TextWrapping="Wrap" Foreground="Black" />
            </StackPanel>
        </Grid>
        <ProgressBar x:Name="MyProgressBar" IsIndeterminate="True" VerticalAlignment="Bottom" Width="200" Height="20" Margin="10" Visibility="{Binding Path=IsBusy, Converter={StaticResource BooleanToVisibilityConverter}}"></ProgressBar>
    </Grid>
</UserControl>

Sample code usage restrictions
5/16/2014