Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Say I have an ArcGIS Server GeometryService running, and a map service containing ZIP code polygons (all ArcGIS 10.1).

I want to pass a coordinate, and have it return which ZIP code contains that coordinate. There seem to be many ways to approach "does THIS point fall within THIS polygon?", but how would I find out which polygon among them all contains a point?

In other words, there's this example where, given two points and a polygon, it will return which of the points is contained by the polygon. But what if you only know the point, and the objective is to determine which polygon?

share|improve this question
1  
I feel like this is too easy but would Identify work? resources.arcgis.com/en/help/rest/apiref/identify.html –  mkennedy Jan 31 '13 at 22:42
    
That may just be the answer! I'll check it out... –  yalestar Jan 31 '13 at 23:23
add comment

1 Answer 1

It looks like either the Query or the Identify tasks will do the trick.

I successfully adapted this sample to prototype this functionality using the ArcGIS JavaScript API:

 var qt1="http://localhost:6080/arcgis/rest/services/simple_ny_outline/MapServer/0"
    var queryTask = new esri.tasks.QueryTask(qt1);
    var query = new esri.tasks.Query();
    query.returnGeometry = true;
    query.outFields = ["*"];
    query.outSpatialReference = {"wkid":26918};


    var currentClick = null;
    dojo.connect(map, "onClick", function(evt) {
      map.graphics.clear();
      currentClick = query.geometry = evt.mapPoint;
      query.spatialRelationship = esri.tasks.Query.SPATIAL_REL_INTERSECTS;
      queryTask.execute(query);
      dojo.byId('messages').innerHTML = "<b>Executing Point Intersection Query...</b>";
    });

    var firstGraphic = null;

    dojo.connect(queryTask, "onComplete", function(graphics) {
      firstGraphic = graphics.features[0];

      console.log(firstGraphic.attributes.COUNTY);
      dojo.byId('messages').innerHTML = "<b>" + firstGraphic.attributes.COUNTY +"</b>";
    });
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.