Question: 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](https://i.stack.imgur.com/H6kKI.png)](https://i.stack.imgur.com/H6kKI.png)

---

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?

Answer: 
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](http://desktop.arcgis.com/en/arcmap/10.3/tools/editing-toolbox/densify.htm) 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](http://pro.arcgis.com/en/pro-app/tool-reference/analysis/erase.htm) 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.
I think the [near table tool](http://desktop.arcgis.com/en/arcmap/10.3/tools/analysis-toolbox/generate-near-table.htm) 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.
> 
> 
>