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).
1 Answer 1
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.
-
How can I check if polygon is selected? Can you post some code?James Tomatov– James Tomatov2014年10月01日 08:04:24 +00:00Commented 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).Hornbydd– Hornbydd2014年10月01日 10:18:58 +00:00Commented 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);James Tomatov– James Tomatov2014年10月02日 05:05:42 +00:00Commented 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.Hornbydd– Hornbydd2014年10月02日 09:32:52 +00:00Commented Oct 2, 2014 at 9:32
-
help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/… I tried this and feature is always nullJames Tomatov– James Tomatov2014年10月02日 11:33:49 +00:00Commented Oct 2, 2014 at 11:33
Explore related questions
See similar questions with these tags.