I have about 10 polygons, and I have added their centroids to the map. I want to create lines connecting the centroids of each adjacent polygon. If polygon 1 borders polygon 2 and 3, I would like a line going from 1 to 2 and from 1 to 3. Hopefully this makes sense, and someone can help me out. Also, I would like to indicate the distances between the centroids.

  • 1
    Are you asking how to do this in an automative or manual way? – artwork21 Jun 19 '15 at 19:34
  • if polygons are uniform and evenly distributed then you may have a try github.com/sharifulgeo/ESRI/tree/master/Connect_Points – SIslam Jun 19 '15 at 19:39
  • 1
    With 10 polygons get the centroids using feature to point (advanced license) and draw the lines manually, snapping to the centroid points. At the very most you can expect to draw 100 lines which should take less than 15 minutes. If you don't have advanced license then create the centroids in QGIS. If you had 100+ polygons to connect it would be worth scripting... – Michael Stimson Jun 20 '15 at 0:00
  • 1
    I agree with @MichaelMiles-Stimson. For that few polygons it would be much faster to manually draw the lines than to run through the process of checking for adjacency and then selecting those pairs and drawing the lines. Especially if you don't want double lines (ie 1 to 3 and 3 to 1). Or are you trying to make this part of an automated process so it's easily repeatable, regardless of how many polys you have? Distance will just be the length of the lines. If you just want the distances and don't care about lines, there are Near tools. – Chris W Jun 27 '15 at 22:18

I met the same problem, my solution is create one copy of the polygon first, add one field with the same ID with the centroid points(should be there, don't need to create). Then use the C# arcobjects to judge if the polygons are touched, like this:

ISpatialFilter pSpatialFilter = new SpatialFilterClass();
pSpatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelTouches;

Then record the touched polygons ID, which will be connected to the centroid, then create fromlist and tolist to record the points, create a new polyline feature class to connect those lines.

| improve this answer | |
  • If it possible, you can share me with the shapefile, and I will process it for you. – Zheng Ren Apr 18 '16 at 9:33

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.