3

I have a point feature class and a polygon feature class, and each point is located within one polygon. Is there a way to programmatically calculate the distance from each point to the farthest location on its containing polygon's edge (see example below)?

I have an ArcGIS Desktop basic licence.

Example

  • Can you amend your question to explicitly state the straight line you have drawn must stay within the polygon (as you have drawn it) or is allowed to pass out/in of a polygon to reach the furthest edge (imagine the polygon is C shaped). What about polygons with holes, how do you want to deal with those? – Hornbydd Jul 28 '15 at 14:29
  • This is irrelevant to my data, so there is no need in any restriction. The line doesn't have to stay within the polygon. – isshp Jul 28 '15 at 15:41
  • This is a pretty difficult problem using the Basic license. With the Advanced license, I imagine you would do something like Feature Vertices to Points to create points out of the polygons, then Point Distance to find the distance to every vertex, then Join or Sort the data to pick the largest distance. – John Jul 28 '15 at 15:48
  • 1
    However with the Basic license, you would have to recreate some of these tools with arcpy Geometry methods. There's a script you might find useful in this thread. However, instead of the closest distance, you want the farthest distance, so there's a piece of code that says if currentdist < closestdist:. You'll want to flip the sign to say if currentdist > farthestdist:. How's your Python? – John Jul 28 '15 at 15:54
  • Thank you @John. I'm fine with python, but I needed a way to extract the vertices of the polygon edge. The way suggested by Hornbydd seems like a possible way to do that. – isshp Jul 28 '15 at 17:40
2

As you have specified that the line from the point can pass in/out of the polygon then I think all you need to do is extract the Envelope of the polygon. You also state in the comment above you are look for an arcpy solution and you have a Basic license level.

You can get most of the way with model builder and a sneaky use of the fishnet tool to extract the Envelope. You could take that logic and convert it into a python script.

The image below was created by:

  • Using the fishnet tool to create a grid of one cell around the extent of the selected polygon.
  • I then ran the Intersect tool using the polygon and the generated envelope. This created the red points.
  • The Dashed line is the distance you are seeking. Unfortunately all the tools that would compute this require at least standard license level, very frustrating!

At this point you need to be using arcpy and cursors to cycle through the points and extracting the distance. What you want to look at is the method DistanceTo. So it's all achievable with the basic license level.

Example

  • I know how to work with arcpy.da cursors and geometry objects, and my main problem was how to extract the relevant points from the polygon edge, given the basic licence limitations. I think your (very) creative solution will do the work. Thank you. – isshp Jul 28 '15 at 17:36
  • 2
    Just thinking aloud, the approach I took was from a start in model builder but I reckon you could do all this manipulating arcpy geometries. So rather than run the fishnet tool you could return the extent of a geometry and then use the Intersect method followed by the DistanceTo method. – Hornbydd Jul 28 '15 at 17:48
0

Convert the given polygon into a set of line segments.Find the nearest segment from the given point feature.

You can also use ICurve interface to query the farthest edge.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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