Clip Features Online

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 Geoprocessor is used to pass the distance and line to the ClipFeatures service. When the results are returned, they are checked to see whether they contain any features. If they do not, then the operation generated too many features to be sent back to the client as graphics, and instead generated a result image. In this case, the result image is requested. Once either the graphics or the result image has been retrieved, they are added to the map.

Download Sample Application
XAML C# VB.NET
<UserControl x:Class="ArcGISWPFSDK.ClipFeatures"
    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>
            <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="MyMap" Background="White" Extent="-130,10,-70,60">
            <esri:ArcGISTiledMapServiceLayer ID="StreetMapLayer" 
                    Url="http://services.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer"/>
            <esri:GraphicsLayer ID="MyResultGraphicsLayer" >
                <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 ID="MyGraphicsLayer" />
        </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. Results are returned as a GP map image."
                    Width="200" TextAlignment="Left" TextWrapping="Wrap" Foreground="Black" />
                <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="5,5,5,10">
                    <TextBlock Text="Distance (in miles): " VerticalAlignment="Center" Foreground="Black" />
                    <TextBox x:Name="DistanceTextBox" Text="100" Width="35" TextAlignment="Right" Margin="0,0,5,0" />
                    <Button x:Name="ClearButton" Content="Clear Results" Click="ClearButton_Click" />
                </StackPanel>
                <TextBlock x:Name="ProcessingTextBlock" MaxWidth="150" Margin="5,5,5,5" Visibility="Collapsed" 
                           HorizontalAlignment="Center" Text="Processing." TextWrapping="Wrap" Foreground="Black" />
            </StackPanel>
        </Grid>

    </Grid>
</UserControl>

Sample code usage restrictions
5/16/2014