Adjacent Parcel

2562
4
Jump to solution
04-25-2014 11:07 PM
HushamHassan
Occasional Contributor
Hi,   I am using the sample identify query task sl api 3.0 -  I would like when selecting a parcel to select automatically the adjacent Parcel.
with symbol graphic and show their attribute in a data Grid,  Could you please put me in the right direction.

Many thanks
0 Kudos
1 Solution

Accepted Solutions
AhmedEl-Sisi
Occasional Contributor III
Hi Husham,
We should break down this into few points:
First you need to select your parcel and you may use query task.
then you need to get your Adjacent parcels so you should make a spatial query and set your Spatial Relationship to  "esriSpatialRelTouches" to get the parcels that touches the border of your first parcel.
After getting your parcels you can add new attribute with your numbers or order.
using the Number Attribute you can make a custom Symbol to show labels.
It may contains a TextBlock that bind your text to Number value.
You can Add labels either in a different graphics layer with parcel's center point or in the same graphics layer with customized fill symbol.
To dispaly your features in a Data Grid you can use the FeatureDatagrid.
Generally you can start with Spatial Query Sample.
I have also attached sample code to demonstrate the concept.

Regards,

View solution in original post

0 Kudos
4 Replies
HushamHassan
Occasional Contributor
hi, to explain in more detail,  for example when user select Nebraska I need to get the adjacent States with different color and with number and show on Datagrid all selected States with additional column for the number(please attached image).
I am using query with buffer so far

public partial class MainPage : UserControl
    {
        GraphicsLayer _pointAndBufferGraphicsLayer;

        //
        GeometryService _geometryService;
        QueryTask _qTask;



        public MainPage()
        {
            InitializeComponent();
            _pointAndBufferGraphicsLayer = map1.Layers["MyGraphicsLayer"] as GraphicsLayer;

            ////
            _geometryService = new GeometryService("http://tasks.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer");
            _geometryService.BufferCompleted += GeometryService_BufferCompleted;
            _geometryService.Failed += GeometryService_Failed;

            _qTask = new QueryTask("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/5");
            _qTask.ExecuteCompleted += qTask_Completed;
            _qTask.Failed += qTask_Failed;
        }

        private void map1_Click(object sender, ESRI.ArcGIS.Client.Map.MouseEventArgs e)
        {
            Graphic g = new Graphic();
            g.Geometry = e.MapPoint;
            g.Symbol = LayoutRoot.Resources["BlueMarkerSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol;
            _pointAndBufferGraphicsLayer.ClearGraphics();
            _pointAndBufferGraphicsLayer.Graphics.Add(g);

            ////
            //// If buffer spatial reference is GCS and unit is linear, geometry service will do geodesic buffering
            ESRI.ArcGIS.Client.Tasks.BufferParameters bufferParams = new ESRI.ArcGIS.Client.Tasks.BufferParameters()
            {
                BufferSpatialReference = new SpatialReference(4326),
                OutSpatialReference = map1.SpatialReference,
                Unit = LinearUnit.StatuteMile,
            };

            bufferParams.Distances.Add(200);
            bufferParams.Features.Add(g);

            _geometryService.BufferAsync(bufferParams);

        }

        ////
        void GeometryService_BufferCompleted(object sender, GraphicsEventArgs args)
        {
            Graphic bufferGraphic = new Graphic();
            bufferGraphic.Geometry = args.Results[0].Geometry;
            bufferGraphic.Symbol = LayoutRoot.Resources["BufferSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol;
            bufferGraphic.SetZIndex(1);

            _pointAndBufferGraphicsLayer.Graphics.Add(bufferGraphic);


            //Add code here to build a Query and execute a QueryTask
            Query query = new Query();
            query.ReturnGeometry = true;
            query.OutSpatialReference = map1.SpatialReference;
            query.Geometry = bufferGraphic.Geometry;
            query.OutFields.Add("*");
            _qTask.ExecuteAsync(query);
            query.OutFields.Add("*");
        }


        void qTask_Completed(object sender, QueryEventArgs args)
        {
            foreach (Graphic g in args.FeatureSet.Features)
            {

                g.Symbol = LayoutRoot.Resources["selectSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol;
                _pointAndBufferGraphicsLayer.Graphics.Add(g);

            }

        }

        private void qTask_Failed(object sender, TaskFailedEventArgs args)
        {
            MessageBox.Show("Query task failed: " + args.Error);
        }

        ////
        private void GeometryService_Failed(object sender, TaskFailedEventArgs args)
        {
            MessageBox.Show("Geometry service failed: " + args.Error);
        }
0 Kudos
AhmedEl-Sisi
Occasional Contributor III
Hi Husham,
We should break down this into few points:
First you need to select your parcel and you may use query task.
then you need to get your Adjacent parcels so you should make a spatial query and set your Spatial Relationship to  "esriSpatialRelTouches" to get the parcels that touches the border of your first parcel.
After getting your parcels you can add new attribute with your numbers or order.
using the Number Attribute you can make a custom Symbol to show labels.
It may contains a TextBlock that bind your text to Number value.
You can Add labels either in a different graphics layer with parcel's center point or in the same graphics layer with customized fill symbol.
To dispaly your features in a Data Grid you can use the FeatureDatagrid.
Generally you can start with Spatial Query Sample.
I have also attached sample code to demonstrate the concept.

Regards,
0 Kudos
HushamHassan
Occasional Contributor
Ahmed,
Exactly what I want, Many thanks for breaking down the problem..  will try your sample and let you know..

Regards
0 Kudos
HushamHassan
Occasional Contributor
Ahmed,
You Saved too much work for me..   Nice solution, exactly what I need,  thanks. 

husham
0 Kudos