2

How can I check if a point belongs to a polygon? I want to create a custom identify tool with edit option. I am using C# and ArcMap 10.

My idea is to click on the polygon (building/park/etc) in ArcMap and if the cursor coordinates belongs to polygon, get its parameters from building_layer for further checking (number of building, street name).

mkennedy
19.4k2 gold badges40 silver badges62 bronze badges
asked Sep 30, 2014 at 6:42

1 Answer 1

3

You will want to create a ToolControl button that allows you to click on a map as opposed to a button which does something when you click on it. Then grab the point, create a spatialfilter and query your polygon layer, this returns a Feature object which you can return the various address components and populate some form that you created. The bold words are the key interfaces you need to go away and research. There are many examples in the Help and on the various forums.

answered Sep 30, 2014 at 12:12
7
  • How can I check if polygon is selected? Can you post some code? Commented Oct 1, 2014 at 8:04
  • Having set the spatialfilter you pass that to the IfeatureLayer.Search() method and that will return an IFeatureCursor which you cycle through getting any Features that fulfilled the spatial relationship (in your case point intersects polygon). Commented Oct 1, 2014 at 10:18
  • I really have problem with this situation. public IPoint GetMapCoordinatesFromScreenCoordinates(IPoint screenPoint, IActiveView activeView) {Polygon pol = new Polygon(); ISpatialFilter sp = new SpatialFilterClass(); sp.Geometry = screenPoint; sp.SpatialRel = esriSpatialRelEnum.esriSpatialRelCrosses; ITopologicalOperator topOperator = (ITopologicalOperator)screenPoint; IGeometry resultGeom = (IGeometry)topOperator.Intersect(pol, esriGeometryDimension.esriGeometry0Dimension); Commented Oct 2, 2014 at 5:05
  • TopoOp is the wrong thing to use. Set your spatial filter relationship to be intersect and pass that into search method on feature layer to get the cursor. If the cursor contains features then that point intersected those polygons. Commented Oct 2, 2014 at 9:32
  • help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/… I tried this and feature is always null Commented Oct 2, 2014 at 11:33

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.