I have two different shapefiles formed by polygons and I need to calculate the max distance of one polygon to the perimeter of the polygon of the other file. I need the output in meters!

The first shapefile contains buildings; the second one contains properties. I need to know the MAXIMUM distance between the PERIMETER of the building to the end of the property:

Example: I need to know, in meters, the max distance between the perimeter of the blue polygon to the perimeter of the black one in which it is contained

I was thinking of some possible solutions, but I have no idea if it make sense:

  1. Maybe there is a way to assign to each building the property and then calculate the max distance?
  2. Maybe I can transform the properties from polygons to lines, maybe this make the computation easier?
  • The following question deals with what seems to me a similar topic: gis.stackexchange.com/questions/198125/… Perhaps you will find it helpful. They recommend a routine utilizing euclidean distance and zonal statistics (which requires the Spatial Analyst license). Does the answer to that question help you with yours? If not, please describe what may be different in your scenario and perhaps we can assist further.
    – Chaz
    Commented Oct 20, 2016 at 13:33
  • That's similar, but in my case that solution doesn't work. I already tried it, but the computation fails (not all the buildings are taken into consideration when I do the table)
    – Mattia
    Commented Oct 20, 2016 at 13:35
  • If I do the same procedure as you recomended I have to type of problems: 1) Not all the properites are considerer (I have 7422 values in the zonal statistic table instead of 53858) 2) The euclidean distance is not in meters but something different (the values are ALL less than 1 Do you think that I should write under that topic instead of this one?
    – Mattia
    Commented Oct 20, 2016 at 14:20
  • You do not state what coordinate system your data is in. If your distances are all coming out less than 1 it would suggest that the data is in WGS84, i.e. latitude/longitude. You would need to project your data into a local coordinate system that is in metres to return meaningful distances.
    – Hornbydd
    Commented Oct 20, 2016 at 14:48
  • 1
    I feel like the way the problem is worded, there is fundamentally not an analytical solution because "Maximum" distance from perimeter of building to the edge of property is undefined. What is the "Maximum"? For example, I could look at any point along the building perimeter and compare it to the vertices of the property polygon. Are we talking about looking at each infinitesimal point along the building perimeter and comparing it to the closest point on the property line and then picking the largest distance?
    – GeoJohn
    Commented Oct 20, 2016 at 14:56

3 Answers 3


Given my understanding of your scenario I think the following routine may be a helpful avenue to explore. Not sure if you are open to a scripting option (scripting may end up being necessary though) but for this answer I am focusing on just general routines that you could follow by manually running ArcMap tools and manipulating tables with field calculator operations.

Set up Unique IDs

Make sure the properties and buildings feature classes have UIDs set so that you can conduct joins and/or reference their original state after doing the procedures below.

Conduct a spatial join

Use the Spatial Join Tool with:

  • Target: Properties FC
  • Join: Buildings
  • Join Operation: One to Many
  • Match Option: Intersect

This will give you a new FC with the geometry of your properties but now you will have a crosswalk table between properties IDs and building IDs that intersect. This will allow you to handle buildings that fall completely within a property but also those that span multiple properties (as shown in your screenshot).

Convert to vertices

Use the Feature Vertices to Points Tool to convert both the properties and buildings FC into point FCs based on their vertices.

Generate Near Table

Use the Generate Near Table Tool and be sure to un-check the "Find only closest" option. Use the vertices point FC version of the properties and buildings as inputs. This will produce a table of ALL distances, near and far from all points. This may end up being very processor intensive though since your data set seems fairly large. You may need to set a "Search Radius". I would recommend something a bit larger than your largest property perimeter.

Join Near Table to Spatial Join FC

This is where things get a bit tricky. The near table should have a way to join the distances back to the buidlings and properties FCs but it will likely use the FID or OID to do so, not the UID that you created in the first step. May need to play around with this concept to figure out how best to join these features. The ultimate goal though would be to have those distance values joined to the spatial join FC from the first step (the crosswalk one that has both UIDs from buildings and properties).


Again, this step is still a bit theoretical and will require some implemntation testing depedning on what your data looks like. The general idea though is that you should hopefully now have a spatial join FC with:

  • building IDs
  • property IDs
  • lots of near distances

You would then want to figure out a way to dissolve the spatial join FC based on the property IDs using the maximum value of the corresponding building ID near distance. There may be a way to munge your data and fields to have the simple Dissolve geoprocessing routine do this, but I think in the end it may require some scripting. Still trying to noodle it out a bit using some dummy data I made based on my understanding of your data and scenario.

Hopefully this helps give you some avenues to test out. Let us know if you are open to a scripted solution. Might be able to help out some more.

  • Unfortunately I'm not an expert of the script (I know only vary basic things about Python) and I dont think I will be able to do something sophisticated. I thope it is possible to do something with ArcMap and the "model builder" inside it...
    – Mattia
    Commented Oct 21, 2016 at 10:18
  • this process should work. it gets very messy as @Chaz points out after you create the near table and need to join the table back to the feature class. Make sure you are conscious of the ID's within your workflow
    – ziggy
    Commented Oct 25, 2016 at 22:30

Analytically speaking, you could run through a series of steps that would give you a decent estimate for the max distance. However, keep in mind that because it is difficult to determine what actually defines the "Max" distance from the property line to the building perimeter, any analytical solution would most likely suffer from inaccuracies to a certain degree. Not a script solution provided, but below I've listed an algorithm that should give decent results.

Foreach "property line" polygon:

1.) Using the densify tool. Add a substantial amount of vertices based on an interval to the property line polygon. Make sure the interval is quite small in order to achieve a smaller margin of error for the final result.

2.) Convert vertices to points for the property line.

3.) Iterate through the new points and draw a new line feature between each point and the centroid of the building perimeter polygon.

4.) Use the erase tool and erase the building perimeter polygon from the new line FC.

5.) Choose the longest line left and get it's distance.

6.) Populate a new field in the building perimeter FC with the the "Max Distance".

Again, I must re-iterate, this is not a perfect solution and will have a margin of error, but should in theory, be pretty close, if you use a small interval for the densify tool. If there are buildings who's shapes "fold" back in on themselves there is potential for lines being generated that do not touch the edge of the property outline. Probably a good idea to filter any out that meet this criteria.

FYI, This algorithm assumes that "Maximum Distance" is defined as the distance between any given point along the property line and where it intersects the building perimeter given a bearing of the centroid of the building.

  • Thank you for the reply. I have "only" two problems: what do you mean in point 3? I have no idea how to do it...moreover, if I'm not wrong this strategy is good but I need to use the centroid of the building, while for the research is fundamental to use the perimeter of the building...
    – Mattia
    Commented Oct 20, 2016 at 16:34
  • To clarify point #3 above: You would have to script a solution that would iterate (i.e. a "for each" statement) that cycled through each point and then continue the algorithm.
    – GeoJohn
    Commented Oct 20, 2016 at 18:30
  • The inherent problem is that "Maximum distance" is not explicit. What does "Maximum distance" actually mean from your point of view. The answer, as "maximum distance" is currently defined, would be a range of possible values.
    – GeoJohn
    Commented Oct 20, 2016 at 18:34
  • The algorithm above assumes that "Distance" is defined as the distance between any given point along the property line and where it intersects the building perimeter given a bearing of the centroid of the building.
    – GeoJohn
    Commented Oct 20, 2016 at 18:35
  • The above solution does use the perimeter of the building. However, it interpolates the "distance" vectors using the centroid(I.E. definition for what we are calling the "distance"). This is where the erase tool comes in. The above would require some proficiency in ArcPy. Unfortunately, I can't really think of another way to do it. You could perform this algorithm manually, but if you have many buildings and many properties, that may not be viable.
    – GeoJohn
    Commented Oct 20, 2016 at 18:43

I think the near table tool would work for what you want but it does require a ArcGIS for Desktop Advanced Licence.

Summary from ArcGIS help:

Calculates distances and other proximity information between features in one or more feature class or layer. Unlike the Near tool, which modifies the input, Generate Near Table writes results to a new stand-alone table and supports finding more than one near feature.

  • I thught the same, but the problem I think is that in that way I find the shortest distance, while I need the longest within the property...
    – Mattia
    Commented Oct 20, 2016 at 13:32

Your Answer

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

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