I am using ArcGIS 10.4.1. I make a map. I am have two shapefiles: one polyline and one polygon. The polyline is a road and polygon is a building.

The shapefiles overlap. I want to automatically resolve the overlapping features. I want to make a "After" picture.

If polygon is placed at the center of the line, it doesn't matter which direction it moves. You only need to move to either side. I want to moving distance is likely to be 15m-20m away from the road. The building should be located only near the road as shown.

I wonder if ArcGIS can automatically shift buildings by road.

I don't have programming skills. However, the GIS program is well used.I hope to solve this problem with ArcGIS.

How to automatically move overlapping features?

enter image description here

The above figure is one line and the figure below is three lines. The three lines mean the center line of the road and the two outside mean the width of the road

  • 1
    Welcome to Geographic Information Systems. Please follow the tour to learn how to ask a detailed question to attract good answers. Please tell us what you've tried so far and what type of solutions you're open to. That is, do you have programming skills? Or are you after and "out of the box" solution? This type of problem could likely be solved using python and cursors. How much do you want to move the features? How far away from the lines can the polygons be? Can they be touching at all?
    – Fezter
    Commented Mar 6, 2017 at 3:50
  • I agree that there is enough info here. OP has added info as well. It's an interesting question. It should stay open @Fezter
    – jbalk
    Commented Mar 6, 2017 at 7:24
  • @ilmare do you have Advanced License?
    – Bera
    Commented Mar 6, 2017 at 14:23
  • @BERA yes, i have
    – ilmare
    Commented Mar 7, 2017 at 0:24
  • An error occurs: Runtime error Traceback (most recent call last): File "<string>", line 20, in <module> File "c:\program files (x86)\arcgis\desktop10.6\arcpy\arcpy\management.py", line 6560, in AddJoin raise e ExecuteError: ERROR 000229: Cannot open polygon_lyr Failed to execute (AddJoin). Commented Apr 1, 2019 at 17:16

1 Answer 1


Script below use Near tool to calculate distance and angle from polygon centroids to nearest line and then move them either closer or further away depending on the specified desired distance. Create a File Geodatabase and import the shapefiles and use as inputs in script.

You can execute the code in the Python window in ArcMap.

import arcpy,math
#Inputs, change paths and fc names to match your data
#Output, change path (and fc name if you want)
#Desired distance from polygon centroids to nearest line. Change


def bearing_to_radians(bearing):
    return math.radians((450-bearing)%360)

#Create centroid points, calculate near distance and angle and join this to polygons
arcpy.FeatureToPoint_management(in_features=polygon_fc, out_feature_class=temp_points)
arcpy.Near_analysis(in_features=temp_points, near_features=line_fc,location=True, angle=True, method='PLANAR')
arcpy.MakeFeatureLayer_management(in_features=polygon_fc, out_layer='polygon_lyr')
arcpy.AddJoin_management(in_layer_or_view='polygon_lyr', in_field='OBJECTID', join_table=temp_points, 
arcpy.CopyFeatures_management(in_features='polygon_lyr', out_feature_class=output_polygon_fc)

#Move the polygons
with arcpy.da.UpdateCursor(output_polygon_fc,['SHAPE@X','SHAPE@Y','points_NEAR_DIST','points_NEAR_ANGLE']) as cursor:
    for row in cursor:

enter image description here

How to create a File Geodatabase and import shapefiles:

enter image description here

  • An error occurs : --- Runtime error Traceback (most recent call last): File "<string>", line 15, in <module> File "c:\program files (x86)\arcgis\desktop10.4\arcpy\arcpy\management.py", line 2483, in FeatureToPoint raise e ExecuteError: ERROR 000732: Input Features: Dataset C:\TEST.gdb\Sample_points_buffer does not exist or is not supported. --- The path of the data is exactly the same.
    – ilmare
    Commented Mar 7, 2017 at 7:42
  • You need to change the paths to match your data. If you have shapefile inputs i would export them to a file geodatabase and use as inputs.
    – Bera
    Commented Mar 7, 2017 at 7:45
  • I'll try again.
    – ilmare
    Commented Mar 7, 2017 at 7:53
  • An error occurs : --- Runtime error Traceback (most recent call last): File "<string>", line 25, in <module> RuntimeError: A column was specified that does not exist.-----
    – ilmare
    Commented Mar 8, 2017 at 0:43
  • If you add the output polygon to arcgis, do they have the columns 'points_NEAR_DIST' and 'points_NEAR_ANGLE'?
    – Bera
    Commented Mar 8, 2017 at 6:24

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.